/* ============================================================================
   THEME — REFINED CONTROLS
   ----------------------------------------------------------------------------
   Loaded last. Touches interactive components only — buttons, toggles, inputs,
   selects, pills and badges. Page backgrounds, the three.js canvases, headers,
   layout, spacing and animation are all left exactly as they were.

   Direction: flatter, quieter, fewer gradients, hairline borders, one accent.
   ========================================================================== */

:root {
    --ui-surface:      rgba(255, 255, 255, 0.035);
    --ui-surface-hi:   rgba(255, 255, 255, 0.075);
    --ui-line:         rgba(255, 255, 255, 0.10);
    --ui-line-strong:  rgba(91, 155, 213, 0.42);
    --ui-text:         #e8eaf0;
    --ui-text-dim:     #9aa1ad;
    --ui-accent:       #5b9bd5;
    --ui-accent-2:     #7bc9a6;
    --ui-radius:       10px;
}

/* ── buttons ─────────────────────────────────────────────────────────── */
.nav-button,
.spell-builder-button,
.spell-action-btn,
.column-filter-button,
.runes-filter,
.dc-btn,
.btn-cast,
.btn-remove {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: var(--ui-radius) !important;
    color: var(--ui-text) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease !important;
}

.nav-button:hover,
.spell-builder-button:hover,
.spell-action-btn:hover,
.column-filter-button:hover,
.runes-filter:hover,
.dc-btn:hover,
.btn-cast:hover,
.btn-remove:hover {
    background: var(--ui-surface-hi) !important;
    border-color: var(--ui-line-strong) !important;
    color: #fff !important;
    transform: none !important;
}

.nav-button.active {
    background: rgba(91, 155, 213, 0.16) !important;
    border-color: var(--ui-line-strong) !important;
    color: #fff !important;
}

.btn-remove:hover { border-color: rgba(239, 68, 68, 0.5) !important; }

/* one primary action, one gradient */
.cast-btn,
#drawCastBtn {
    background: linear-gradient(135deg, #5b9bd5 0%, #6fa8bd 50%, #7bc9a6 100%) !important;
    border: none !important;
    border-radius: 12px !important;
    color: #fff !important;
    box-shadow: 0 4px 18px rgba(91, 155, 213, 0.22) !important;
    letter-spacing: 0.08em !important;
    transition: box-shadow 0.2s ease, transform 0.2s ease !important;
}

.cast-btn:hover,
#drawCastBtn:hover:not(:disabled) {
    box-shadow: 0 8px 26px rgba(91, 155, 213, 0.34) !important;
    transform: translateY(-1px) !important;
}

/* ── segmented toggles ───────────────────────────────────────────────── */
.mode-toggle,
.spell-list-toggle {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    padding: 3px !important;
    gap: 2px !important;
}

.mode-toggle-btn,
.spell-list-toggle-btn {
    background: transparent !important;
    border: none !important;
    border-radius: 9px !important;
    color: var(--ui-text-dim) !important;
    box-shadow: none !important;
    text-shadow: none !important;
    transition: background 0.18s ease, color 0.18s ease !important;
}

.mode-toggle-btn:hover,
.spell-list-toggle-btn:hover {
    background: var(--ui-surface) !important;
    color: var(--ui-text) !important;
}

.mode-toggle-btn.active,
.spell-list-toggle-btn.active {
    background: rgba(91, 155, 213, 0.18) !important;
    color: #fff !important;
    box-shadow: none !important;
}

/* ── inputs ──────────────────────────────────────────────────────────── */
textarea,
#spellText,
.rune-search-input,
.dc-search,
.dc-select,
.custom-manager-form input,
.custom-manager-form select,
.custom-manager-form textarea,
.stat-box input {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: var(--ui-radius) !important;
    color: var(--ui-text) !important;
    box-shadow: none !important;
    transition: border-color 0.18s ease, background 0.18s ease !important;
}

textarea:focus,
#spellText:focus,
.rune-search-input:focus,
.dc-search:focus,
.dc-select:focus,
.custom-manager-form input:focus,
.stat-box input:focus {
    background: var(--ui-surface-hi) !important;
    border-color: var(--ui-line-strong) !important;
    box-shadow: none !important;
    outline: none !important;
}

::placeholder { color: var(--ui-text-dim) !important; opacity: 1 !important; }

input[type="checkbox"] { accent-color: var(--ui-accent) !important; }

/* ── pills & badges ──────────────────────────────────────────────────── */
.spell-stat-pill {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
    transition: border-color 0.18s ease, background 0.18s ease !important;
}

.spell-stat-pill:hover {
    background: var(--ui-surface-hi) !important;
    border-color: var(--ui-line-strong) !important;
    transform: none !important;
    box-shadow: none !important;
}

.spell-stat-pill .pill-label {
    color: var(--ui-text-dim) !important;
    letter-spacing: 0.10em !important;
    font-weight: 500 !important;
    text-shadow: none !important;
}

.spell-stat-pill .pill-value {
    color: #fff !important;
    font-weight: 600 !important;
    text-shadow: none !important;
}

.rune-type-badge,
.tier-badge {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: 999px !important;
    box-shadow: none !important;
    text-shadow: none !important;
    font-weight: 500 !important;
}

.rune-type-badge.form     { color: #a78bfa !important; border-color: rgba(167, 139, 250, 0.34) !important; }
.rune-type-badge.essence  { color: #7bc9a6 !important; border-color: rgba(123, 201, 166, 0.34) !important; }
.rune-type-badge.additive { color: #60a5fa !important; border-color: rgba(96, 165, 250, 0.34) !important; }

/* ── stat displays ───────────────────────────────────────────────────── */
.stat-display {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: 12px !important;
    box-shadow: none !important;
}
.stat-display .stat-label { color: var(--ui-text-dim) !important; letter-spacing: 0.08em !important; }
.stat-display .stat-value { color: #fff !important; text-shadow: none !important; }

/* ── menus & dropdowns ───────────────────────────────────────────────── */
.column-filter-dropdown,
.settings-menu {
    border: 1px solid var(--ui-line) !important;
    border-radius: 12px !important;
}

.column-option,
.settings-menu-item {
    border-radius: 8px !important;
    transition: background 0.15s ease !important;
}

.column-option:hover,
.settings-menu-item:hover { background: var(--ui-surface-hi) !important; }

.settings-icon-btn {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: none !important;
}
.settings-icon-btn:hover { background: var(--ui-surface-hi) !important; border-color: var(--ui-line-strong) !important; }

/* ── result table chrome ─────────────────────────────────────────────── */
.result-table-wrapper {
    border: 1px solid var(--ui-line) !important;
    border-radius: 14px !important;
    box-shadow: none !important;
}

.result table th,
.runes-table th {
    background: rgba(255, 255, 255, 0.04) !important;
    color: var(--ui-text-dim) !important;
    border-color: var(--ui-line) !important;
    text-shadow: none !important;
    letter-spacing: 0.06em !important;
    font-weight: 500 !important;
}

.result table td,
.runes-table td { border-color: rgba(255, 255, 255, 0.06) !important; }

.runes-table tbody tr:hover,
.result table tbody tr:hover { background: var(--ui-surface) !important; }

/* ── tooltips: quieter frame, same behaviour ─────────────────────────── */
.grimoire-tooltip {
    border: 1px solid var(--ui-line) !important;
    border-radius: 12px !important;
}

.tooltip-header {
    background: rgba(255, 255, 255, 0.04) !important;
    border-bottom-color: var(--ui-line) !important;
    text-shadow: none !important;
}

.input-help-icon {
    background: var(--ui-surface) !important;
    border: 1px solid var(--ui-line) !important;
    color: var(--ui-text-dim) !important;
    box-shadow: none !important;
}
.input-help-icon:hover {
    background: var(--ui-surface-hi) !important;
    border-color: var(--ui-line-strong) !important;
    color: #fff !important;
}

/* ============================================================================
   SPELL BOOK — density
   Structure and behaviour are unchanged; this removes height and turns the
   section bars from decoration into controls.
   ========================================================================== */

/* ── section headers: left-aligned rows, not centred glowing boxes ────── */
#spellbookPage .collapsible-section {
    background: transparent !important;
    border: none !important;
    border-top: 1px solid var(--ui-line) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
}
#spellbookPage .collapsible-section:last-of-type {
    border-bottom: 1px solid var(--ui-line) !important;
}

#spellbookPage .section-header {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 4px !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    text-align: left !important;
    transition: color .16s ease !important;
}
#spellbookPage .section-header:hover { background: rgba(255,255,255,.03) !important; }

#spellbookPage .section-header h2 {
    font-size: 14.5px !important;
    font-weight: 500 !important;
    letter-spacing: .01em !important;
    margin: 0 !important;
    text-align: left !important;
    text-shadow: none !important;
    color: var(--ui-text-dim) !important;
}
#spellbookPage .section-header:hover h2 { color: var(--ui-text) !important; }

/* a closed section still says what is inside it */
#spellbookPage .sb-peek {
    margin-left: auto;
    font-size: 12px;
    font-style: italic;
    color: var(--ui-text-dim);
    opacity: .75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 52%;
}

#spellbookPage .section-toggle {
    font-size: 11px !important;
    color: var(--ui-text-dim) !important;
    text-shadow: none !important;
    flex: 0 0 auto;
}

#spellbookPage .section-content-inner {
    background: transparent !important;
    border: none !important;
    padding: 2px 4px 14px !important;
}

/* ── one surface: stop the card-inside-card nesting ───────────────────── */
#spellbookPage .spellbook-section {
    background: transparent !important;
    border: none !important;
    border-top: 1px solid var(--ui-line) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin-top: 14px !important;
}
#spellbookPage .spellbook-section > h2 {
    font-size: 13px !important;
    font-weight: 500 !important;
    letter-spacing: .1em !important;
    text-transform: uppercase !important;
    color: var(--ui-text-dim) !important;
    text-align: left !important;
    text-shadow: none !important;
    padding: 12px 4px 8px !important;
    margin: 0 !important;
}

/* ── calculated limits: an inline strip, not six boxes ────────────────── */
#spellbookPage .calculated-stats {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}
#spellbookPage .calculated-stats h3 { display: none !important; }
#spellbookPage .stats-display-grid {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px 22px !important;
}
#spellbookPage .stat-display {
    display: flex !important;
    align-items: baseline !important;
    gap: 7px !important;
    flex-direction: row-reverse !important;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 2px 0 !important;
    min-width: 0 !important;
    box-shadow: none !important;
}
#spellbookPage .stat-display .stat-label {
    font-size: 12.5px !important;
    letter-spacing: 0 !important;
    text-transform: none !important;
    color: var(--ui-text-dim) !important;
}
#spellbookPage .stat-display .stat-value {
    font-size: 14.5px !important;
    font-weight: 600 !important;
    color: var(--ui-text) !important;
    text-shadow: none !important;
}

/* ── empty state: a few lines, not a 437px box ────────────────────────── */
#spellbookPage .empty-spellbook {
    padding: 22px 4px !important;
    text-align: left !important;
    font-size: 13.5px !important;
    line-height: 1.65 !important;
    color: var(--ui-text-dim) !important;
}
#spellbookPage .empty-spellbook-icon { display: none !important; }
#spellbookPage .empty-spellbook p { font-size: 13.5px !important; }

/* ── toggle + list ────────────────────────────────────────────────────── */
#spellbookPage .spell-list-toggle-wrapper { margin: 14px 0 2px !important; }
#spellbookPage .methodology-item {
    background: transparent !important;
    border: none !important;
    border-left: 2px solid var(--ui-line) !important;
    border-radius: 0 !important;
    padding: 2px 0 2px 11px !important;
    margin-bottom: 10px !important;
    font-size: 13.5px !important;
}

@media (max-width: 600px) {
    #spellbookPage .sb-peek { max-width: 44%; font-size: 11.5px; }
    #spellbookPage .section-header { padding: 11px 2px !important; }
    #spellbookPage .stats-display-grid { gap: 5px 16px !important; }
}

/* a long heading must not wrap the header onto a second line */
#spellbookPage .section-header h2 {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 0 1 auto;
}

/* ── synergies-as-runes toggle (pill switch in the settings menu) ─────── */
/* ── synergies-as-runes toggle ────────────────────────────────────────────
   The switch lives in draw-cast.css, which matches the markup synergies.js
   actually emits: .syn-pill is the whole full-width button, with
   .syn-pill-track and .syn-pill-text nested inside it.

   An older revision used .syn-pill as the little 34x19 track with the label as
   a sibling, and those rules used to live here. Because this file loads last
   they were still winning — the button was forced down to 34x19 while its own
   children kept their real size, so "Synergies as runes" and the fused-pair
   count spilled out over RUNES / CUSTOMIZE and the menu items beneath. */
.syn-pill:focus-visible { outline: 2px solid var(--ui-line-strong); outline-offset: -2px; }

/* a synergy in a rune list reads as a pair */
.dc-rune[data-synergy="1"] .dc-rune-name::after,
.runes-table tr[data-synergy="1"] td:first-child::after {
    content: '⚯';
    margin-left: 6px;
    font-size: 10px;
    opacity: .7;
}

/* ── the stat "?" must sit beside the label, not on top of it ─────────────
   spellbook-main.css pins .stat-tooltip-icon to `position:absolute; top:8px;
   right:8px`, which suits the tall card it was written for. The rules above
   flatten each .stat-display into a short inline row, so that corner is where
   the label text already is — the "?" landed straight on it ("Action Spe(?)d",
   "Containment Li(?)it").

   Put it back in the flex flow. The row is row-reverse, so order:-1 sends the
   icon to the visual end, giving "0  Action Speed  ?". */
#spellbookPage .stat-display {
    position: relative;
    flex-wrap: nowrap !important;
}
#spellbookPage .stat-display .stat-tooltip-icon {
    position: static !important;
    top: auto !important;
    right: auto !important;
    order: -1;
    flex: 0 0 auto;
    width: 16px !important;
    height: 16px !important;
    font-size: 9px !important;
    margin-left: 1px;
    align-self: center;
}

/* ── inline "Player Stats" link in the casting-limits note ────────────────
   Reads as part of the sentence, but is a real button: tapping it opens the
   same pill the nav mage icon does. */
.player-stats-inline-link {
    display: inline;
    padding: 1px 8px;
    margin: 0 1px;
    background: rgba(91, 155, 213, 0.12);
    border: 1px solid rgba(91, 155, 213, 0.38);
    border-radius: 999px;
    color: #7ab6e8;
    font-family: inherit;
    font-size: 0.96em;
    font-weight: 600;
    font-style: normal;
    line-height: 1.5;
    cursor: pointer;
    vertical-align: baseline;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.player-stats-inline-link:hover,
.player-stats-inline-link:focus-visible {
    background: rgba(91, 155, 213, 0.26);
    border-color: rgba(91, 155, 213, 0.62);
    color: #a9d2f5;
    outline: none;
}

