/* ============================================================
   Cairn GM Screen — styles.css
   Theme: Dark folk horror / woodland mystery
   ============================================================ */

:root {
    --bg:           #080c08;
    --surface:      #101510;
    --surface-2:    #151d15;
    --surface-3:    #1c2620;
    --accent:       #3a5a20;
    --accent-light: #5a8a30;
    --text:         #d8c8a0;
    --text-dim:     #a09070;
    --muted:        #708060;
    --gold:         #c4a040;
    --gold-dim:     #8a7030;
    --danger:       #8b3010;
    --danger-light: #c45020;
    --border:       #1a2218;
    --border-light: #253025;

    --font-body:    'Georgia', 'Times New Roman', serif;
    --font-ui:      'Segoe UI', system-ui, sans-serif;
    --radius:       4px;
    --radius-lg:    8px;
}

/* ---- Reset / Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ---- Screen layout ---- */
.warden-screen {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---- Header ---- */
.screen-header {
    background: linear-gradient(180deg, #0d150d 0%, var(--surface) 100%);
    border-bottom: 2px solid var(--accent);
    padding: 1.25rem 1.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1.5rem;
}

.screen-header h1 {
    font-family: Georgia, serif;
    font-size: 1.8rem;
    font-weight: normal;
    color: var(--gold);
    letter-spacing: 0.08em;
}

.screen-header .subtitle {
    color: var(--muted);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    flex-grow: 1;
}

.back-link {
    color: var(--accent-light);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    transition: color 0.2s;
}
.back-link:hover { color: var(--gold); }

/* ---- Navigation Bar ---- */
.nav-bar {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.4rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.nav-bar a {
    color: var(--text-dim);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius);
    transition: color 0.2s, background 0.2s;
}
.nav-bar a:hover {
    color: var(--text);
    background: var(--surface-3);
}
.nav-bar .sep {
    color: var(--muted);
    line-height: 1.8;
    font-size: 0.75rem;
}

/* ---- Tabs ---- */
.tabs {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    overflow-x: auto;
}

.tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    padding: 0.65rem 1rem;
    transition: color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
    color: var(--gold);
    border-bottom-color: var(--accent-light);
}

/* ---- Content Panels ---- */
.content-panels {
    flex: 1;
    padding: 1.5rem;
}

.panel { display: none; }
.panel.active { display: block; }

/* ---- Section headers ---- */
.panel > h2 {
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1.3rem;
    font-weight: normal;
    letter-spacing: 0.1em;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
}

/* ---- Rules grid layout ---- */
.rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.rule-section {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
}

.rule-section h3 {
    color: var(--accent-light);
    font-family: Georgia, serif;
    font-size: 1rem;
    font-weight: normal;
    letter-spacing: 0.06em;
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.rule-section h4 {
    color: var(--gold-dim);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin: 0.7rem 0 0.3rem;
}

.rule-section p {
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}

.rule-section ul, .rule-section ol {
    padding-left: 1.2rem;
    margin-bottom: 0.4rem;
}
.rule-section li {
    font-size: 0.9rem;
    margin-bottom: 0.15rem;
    color: var(--text);
}

.rule-section strong { color: var(--gold); }
.rule-section em { color: var(--accent-light); font-style: normal; }

/* ---- Key rule callout ---- */
.key-rule {
    background: var(--surface-3);
    border-left: 3px solid var(--accent);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 0.9rem;
}

/* ---- Inline code / dice notation ---- */
.dice {
    background: var(--surface-3);
    border: 1px solid var(--border-light);
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
    font-family: monospace;
    font-size: 0.85em;
    color: var(--gold);
}

/* ---- Tables ---- */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.88rem;
}
thead tr { background: var(--surface-3); }
th {
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.4rem 0.6rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}
td {
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(58, 90, 32, 0.08); }

/* danger row */
tr.danger td { color: var(--danger-light); }

/* ---- Scars table special coloring ---- */
.scar-low { background: rgba(196,160,64, 0.06); }
.scar-mid { background: rgba(139,48,16, 0.06); }
.scar-high { background: rgba(139,48,16, 0.14); }

/* ---- Combat flow box ---- */
.combat-flow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.flow-step {
    background: var(--surface-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 200px;
}

.flow-num {
    background: var(--accent);
    color: #fff;
    font-size: 0.75rem;
    font-family: var(--font-ui);
    font-weight: bold;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---- Dice Roller (Tab 3) ---- */
.dice-roller-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.roller-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.roller-card h3 {
    color: var(--accent-light);
    font-family: Georgia, serif;
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.dice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}

.dice-btn {
    background: var(--surface-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--gold);
    cursor: pointer;
    font-family: Georgia, serif;
    font-size: 1rem;
    padding: 0.55rem 0.25rem;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    text-align: center;
}
.dice-btn:hover {
    background: var(--accent);
    border-color: var(--accent-light);
    color: #fff;
}
.dice-btn:active { transform: scale(0.95); }

.roll-display {
    background: var(--surface-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    text-align: center;
    padding: 0.6rem;
    margin-bottom: 0.5rem;
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 0.15rem;
}

.roll-result {
    font-size: 2rem;
    font-family: Georgia, serif;
    color: var(--gold);
    line-height: 1;
}

.roll-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    font-family: var(--font-ui);
}

.result-success { color: var(--accent-light) !important; }
.result-fail    { color: var(--danger-light) !important; }

/* ---- Roller inputs ---- */
.roller-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.roller-row label {
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    white-space: nowrap;
}

.roller-row input[type="number"],
.roller-row select {
    background: var(--surface-3);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    padding: 0.3rem 0.5rem;
    width: 70px;
}

.roller-row select { width: auto; }

.roll-btn {
    background: var(--accent);
    border: 1px solid var(--accent-light);
    border-radius: var(--radius);
    color: #fff;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    padding: 0.35rem 0.8rem;
    transition: background 0.15s;
}
.roll-btn:hover { background: var(--accent-light); }

/* ---- Roll History ---- */
.roll-history {
    list-style: none;
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.82rem;
    font-family: var(--font-ui);
}
.roll-history li {
    padding: 0.2rem 0.4rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
}
.roll-history li:last-child { border-bottom: none; }
.roll-history .h-val { color: var(--gold); font-weight: bold; }
.roll-history .h-suc { color: var(--accent-light); }
.roll-history .h-fail { color: var(--danger-light); }

/* ---- Character Tracker (Tab 4) ---- */
.tracker-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.tracker-btn {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    padding: 0.4rem 0.9rem;
    transition: background 0.15s, color 0.15s;
}
.tracker-btn:hover { background: var(--surface-3); color: var(--text); }
.tracker-btn.primary {
    background: var(--accent);
    border-color: var(--accent-light);
    color: #fff;
}
.tracker-btn.primary:hover { background: var(--accent-light); }
.tracker-btn.danger {
    background: none;
    border-color: var(--danger);
    color: var(--danger-light);
}
.tracker-btn.danger:hover { background: var(--danger); color: #fff; }

.characters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.char-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.char-card.deprived-card {
    border-color: var(--danger);
    box-shadow: 0 0 8px rgba(139,48,16,0.25);
}

.char-header {
    background: var(--surface-3);
    border-bottom: 1px solid var(--border-light);
    padding: 0.6rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.char-name-input {
    background: none;
    border: none;
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1rem;
    flex: 1;
    outline: none;
    min-width: 0;
}
.char-name-input::placeholder { color: var(--gold-dim); opacity: 0.6; }

.char-bg-input {
    background: none;
    border: none;
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.8rem;
    flex: 1;
    outline: none;
    min-width: 0;
}
.char-bg-input::placeholder { color: var(--text-dim); opacity: 0.5; }

.char-body {
    padding: 0.75rem 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

/* ---- Ability scores row ---- */
.abilities-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.ability-box {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    text-align: center;
}

.ability-label {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    display: block;
    margin-bottom: 0.2rem;
}

.ability-inputs {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.ability-cur, .ability-max {
    background: none;
    border: none;
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1.1rem;
    width: 2.5rem;
    text-align: center;
    outline: none;
}
.ability-max { color: var(--text-dim); font-size: 0.9rem; }

.ability-sep { color: var(--border-light); font-size: 0.85rem; }

.ability-save {
    font-family: var(--font-ui);
    font-size: 0.7rem;
    color: var(--text-dim);
    display: block;
    margin-top: 0.1rem;
}

/* ---- HP & Armor ---- */
.hp-armor-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.5rem;
}

.stat-box {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.5rem;
    text-align: center;
}

.stat-label {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    display: block;
    margin-bottom: 0.2rem;
}

.stat-input {
    background: none;
    border: none;
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1.1rem;
    width: 3rem;
    text-align: center;
    outline: none;
}

.stat-sep { color: var(--border-light); }

/* ---- Inventory ---- */
.inventory-section { }

.inventory-label {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.inv-count {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--text-dim);
    font-size: 0.75rem;
    padding: 0.05rem 0.3rem;
    font-family: monospace;
}

.inv-slots {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 3px;
    margin-bottom: 0.4rem;
}

.inv-slot {
    aspect-ratio: 1;
    border: 1px solid var(--border-light);
    border-radius: 2px;
    background: var(--surface-3);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    position: relative;
}

.inv-slot.used {
    background: var(--accent);
    border-color: var(--accent-light);
}

.inv-slot.fatigue {
    background: var(--danger);
    border-color: var(--danger-light);
}

.inv-slot:hover { border-color: var(--gold-dim); }

.inv-slot-num {
    position: absolute;
    bottom: 0;
    right: 1px;
    font-size: 8px;
    color: rgba(255,255,255,0.3);
    line-height: 1;
    font-family: var(--font-ui);
}

/* ---- Status toggles ---- */
.status-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.status-toggle {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    padding: 0.25rem 0.55rem;
    transition: all 0.15s;
}
.status-toggle.active-deprived {
    background: rgba(139,48,16,0.3);
    border-color: var(--danger);
    color: var(--danger-light);
}
.status-toggle.active-down {
    background: rgba(139,48,16,0.2);
    border-color: var(--danger);
    color: #e8684a;
}

/* ---- Fatigue counter ---- */
.fatigue-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.fatigue-label {
    font-family: var(--font-ui);
    font-size: 0.78rem;
    color: var(--text-dim);
    min-width: 4rem;
}
.fatigue-btn {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 0.9rem;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.fatigue-btn:hover { background: var(--accent); color: #fff; }
.fatigue-val {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--gold);
    font-family: Georgia, serif;
    font-size: 1rem;
    width: 2rem;
    text-align: center;
    outline: none;
    padding: 0.1rem;
}

/* ---- Notes textarea ---- */
.char-notes {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 0.82rem;
    padding: 0.4rem 0.5rem;
    resize: vertical;
    width: 100%;
    min-height: 3.5rem;
    outline: none;
    transition: border-color 0.15s;
}
.char-notes:focus { border-color: var(--accent); }
.char-notes::placeholder { color: var(--text-dim); opacity: 0.5; }

/* ---- Warden Tools (Tab 5) ---- */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.tool-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
}

.tool-card h3 {
    color: var(--accent-light);
    font-family: Georgia, serif;
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border);
}

.gen-result {
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-family: Georgia, serif;
    font-size: 0.95rem;
    min-height: 2.8rem;
    padding: 0.5rem 0.7rem;
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
}

.gen-result.multi-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
}

.gen-detail {
    font-size: 0.82rem;
    color: var(--text-dim);
    font-family: var(--font-ui);
}

/* ---- Notes (Tab 6) ---- */
.notes-area {
    width: 100%;
    min-height: 70vh;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.7;
    padding: 1rem 1.25rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}
.notes-area:focus { border-color: var(--accent); }

.notes-meta {
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    margin-top: 0.4rem;
    text-align: right;
}

/* ---- NPC Reactions badge ---- */
.reaction-table-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.reaction-badge {
    border-radius: var(--radius);
    padding: 0.25rem 0.6rem;
    font-family: var(--font-ui);
    font-size: 0.78rem;
    text-align: center;
    flex: 1 1 60px;
}
.reaction-hostile  { background: rgba(139,48,16,0.35); border: 1px solid var(--danger); color: var(--danger-light); }
.reaction-wary     { background: rgba(100,70,20,0.35); border: 1px solid #8a6020; color: #c49040; }
.reaction-curious  { background: rgba(50,70,20,0.30); border: 1px solid var(--accent); color: var(--accent-light); }
.reaction-kind     { background: rgba(30,60,40,0.35); border: 1px solid #2a6040; color: #50a070; }
.reaction-helpful  { background: rgba(20,80,60,0.30); border: 1px solid #30a060; color: #60d090; }

/* ---- Morale / Die of Fate ---- */
.fate-die {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* ---- Armor pip display ---- */
.armor-pips {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-top: 0.2rem;
}
.armor-pip {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: var(--border-light);
    border: 1px solid var(--border);
}
.armor-pip.filled {
    background: var(--muted);
    border-color: var(--text-dim);
}

/* ---- Footer ---- */
footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.78rem;
    padding: 0.75rem 1.5rem;
    text-align: center;
}

/* ---- Utility ---- */
.text-gold  { color: var(--gold); }
.text-green { color: var(--accent-light); }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger-light); }

.no-chars-msg {
    color: var(--text-dim);
    font-family: var(--font-ui);
    font-size: 0.9rem;
    padding: 2rem;
    text-align: center;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius-lg);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .screen-header h1 { font-size: 1.4rem; }
    .content-panels { padding: 1rem 0.75rem; }
    .rules-grid { grid-template-columns: 1fr; }
    .dice-roller-layout { grid-template-columns: 1fr; }
    .tools-grid { grid-template-columns: 1fr; }
    .characters-grid { grid-template-columns: 1fr; }
    .abilities-row { grid-template-columns: repeat(3, 1fr); }
    .hp-armor-row { grid-template-columns: repeat(3, 1fr); }
}
