/* The interface looks a player can pick in Settings → Interface (#380); see
   public/src/ui-theme.js. The original look is no theme at all: without the
   attribute nothing here applies and style.css keeps its own colours.

   A theme only sets custom properties; the shared rules at the bottom of the
   file are what paint panels, buttons, tabs, slots and scrollbars with them,
   so a new look is a new block of values rather than new selectors. */

/* ---- A: dark wood and brass ---- */
:root[data-ui-theme="wood"] {
  --ui-font-heading: Georgia, "Times New Roman", serif;
  --ui-heading-variant: small-caps;
  --ui-heading-spacing: .04em;
  --ui-heading-transform: none;
  --ui-heading-style: normal;
  --ui-panel-rgb: 33 22 13;
  --ui-well: #170f08;
  --ui-raised: #3b2a17;
  --ui-button-bg: linear-gradient(#5a4122, #2f2112);
  --ui-frame: #8a6a32;
  --ui-frame-dim: #4a3720;
  --ui-frame-bright: #e2c27a;
  --ui-frame-hover: #e2c27a;
  --ui-accent: #f0cf7a;
  --ui-heading: #f0cf7a;
  --ui-text: #f3e6c8;
  --ui-text-body: #ece0c4;
  --ui-text-soft: #dccbaa;
  --ui-text-muted: #c4ad84;
  --ui-text-bright: #fff7e2;
  --ui-rivet: radial-gradient(circle, #f1d48c 0 1.6px, #7a5a26 2.2px, rgba(0, 0, 0, .55) 3px, transparent 3.6px);
  --ui-panel-bg:
    var(--ui-rivet) 3px 3px / 10px 10px no-repeat,
    var(--ui-rivet) right 3px top 3px / 10px 10px no-repeat,
    var(--ui-rivet) left 3px bottom 3px / 10px 10px no-repeat,
    var(--ui-rivet) right 3px bottom 3px / 10px 10px no-repeat,
    var(--ui-panel-fill);
  --ui-panel-fill:
    repeating-linear-gradient(90deg, rgba(255, 224, 170, .028) 0 2px, transparent 2px 9px, rgba(0, 0, 0, .05) 9px 11px, transparent 11px 17px),
    linear-gradient(rgba(62, 42, 24, .96), rgba(30, 20, 12, .97));
  --ui-panel-border: 2px solid #8a6a32;
  --ui-panel-radius: 6px;
  --ui-panel-shadow: inset 0 0 0 1px #1d1209, inset 0 0 0 3px rgba(201, 160, 82, .28), 0 10px 28px rgba(0, 0, 0, .6);
  --ui-button-text: #f6e7c1;
  --ui-button-border: #9b7a3c;
  --ui-button-hover-bg: linear-gradient(#715228, #3c2a16);
  --ui-button-shadow: inset 0 1px 0 rgba(255, 226, 160, .22), 0 1px 2px rgba(0, 0, 0, .6);
  --ui-tab-bg: linear-gradient(#2c1e11, #1f150c);
  --ui-tab-selected-bg: linear-gradient(#6a4c26, #3a2715);
  --ui-tab-lip: #f0cf7a;
  --ui-slot-bg: radial-gradient(circle at 40% 30%, #4a3119, #140c06);
  --ui-slot-border: #8a6a32;
  --ui-scroll-track: rgba(0, 0, 0, .4);
  --ui-scroll-thumb: linear-gradient(90deg, #a07c3c, #6b4e22);
  --ui-backdrop: radial-gradient(circle at 50% 30%, #3a2a17, #0e0905 70%);
}

/* ---- B: forged iron and slate ---- */
:root[data-ui-theme="iron"] {
  --ui-font-heading: Georgia, "Times New Roman", serif;
  --ui-heading-variant: normal;
  --ui-heading-spacing: .14em;
  --ui-heading-transform: uppercase;
  --ui-heading-style: normal;
  --ui-panel-rgb: 19 22 26;
  --ui-well: #0d0f12;
  --ui-raised: #2b3036;
  --ui-button-bg: linear-gradient(#3b4148, #22262b);
  --ui-frame: #5d646d;
  --ui-frame-dim: #343a41;
  --ui-frame-bright: #a9c7d6;
  --ui-frame-hover: #b9c6cf;
  --ui-accent: #9cc6dc;
  --ui-heading: #e2d3a4;
  --ui-text: #e6e5e0;
  --ui-text-body: #dedcd5;
  --ui-text-soft: #c9c7bf;
  --ui-text-muted: #a8acad;
  --ui-text-bright: #ffffff;
  /* a carved mark in each corner, the same angular glyph turned four ways */
  --ui-rune: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 14V2h12M2 2l6 6M5 2v4' fill='none' stroke='%239cc6dc' stroke-opacity='.55' stroke-width='1.3'/%3E%3C/svg%3E");
  --ui-panel-bg:
    var(--ui-rune) 4px 4px / 14px 14px no-repeat,
    var(--ui-panel-fill);
  --ui-panel-fill:
    linear-gradient(rgba(156, 198, 220, .05), transparent 40px),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 5px),
    linear-gradient(160deg, rgba(42, 47, 54, .96), rgba(18, 21, 25, .97));
  --ui-panel-border: 2px solid #5d646d;
  --ui-panel-radius: 3px;
  --ui-panel-shadow: inset 0 1px 0 rgba(255, 255, 255, .09), inset 0 0 0 3px rgba(0, 0, 0, .35), 0 10px 28px rgba(0, 0, 0, .65);
  --ui-button-text: #e7e9ea;
  --ui-button-border: #6c747e;
  --ui-button-hover-bg: linear-gradient(#4a525b, #2a2f35);
  --ui-button-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 1px 2px rgba(0, 0, 0, .7);
  --ui-tab-bg: linear-gradient(#22262b, #181b1f);
  --ui-tab-selected-bg: linear-gradient(#3a424b, #262b31);
  --ui-tab-lip: #9cc6dc;
  --ui-slot-bg: radial-gradient(circle at 40% 30%, #353b42, #0e1013);
  --ui-slot-border: #5d646d;
  --ui-scroll-track: rgba(0, 0, 0, .45);
  --ui-scroll-thumb: linear-gradient(90deg, #7d8790, #4a525b);
  --ui-backdrop: radial-gradient(circle at 50% 30%, #2a3138, #08090b 70%);
}

/* ---- C: illuminated manuscript ---- */
:root[data-ui-theme="codex"] {
  --ui-font-heading: Georgia, "Times New Roman", serif;
  --ui-heading-variant: normal;
  --ui-heading-spacing: .01em;
  --ui-heading-transform: none;
  --ui-heading-style: italic;
  --ui-panel-rgb: 24 13 15;
  --ui-well: #120a0b;
  --ui-raised: #3a1d20;
  --ui-button-bg: linear-gradient(#55262a, #33171a);
  --ui-frame: #b08d47;
  --ui-frame-dim: #5a4325;
  --ui-frame-bright: #e8c56b;
  --ui-frame-hover: #f0d58c;
  --ui-accent: #e8c56b;
  --ui-heading: #e8c56b;
  --ui-text: #f1e2c0;
  --ui-text-body: #eadbb9;
  --ui-text-soft: #dccaa4;
  --ui-text-muted: #c2a97a;
  --ui-text-bright: #fff6dd;
  --ui-fleuron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M3 3c5 0 8 2 9 6-4-1-6 0-9 3 1-3 1-6 0-9z' fill='%23d4ad5a'/%3E%3Ccircle cx='13.5' cy='13.5' r='1.6' fill='%23b0402f'/%3E%3C/svg%3E");
  --ui-panel-bg:
    var(--ui-fleuron) 5px 5px / 16px 16px no-repeat,
    var(--ui-panel-fill);
  --ui-panel-fill:
    radial-gradient(ellipse at 50% 0, rgba(232, 197, 107, .07), transparent 60%),
    linear-gradient(rgba(40, 21, 24, .96), rgba(19, 10, 12, .97));
  --ui-panel-border: 4px double #b08d47;
  --ui-panel-radius: 2px;
  --ui-panel-shadow: 0 10px 28px rgba(0, 0, 0, .6);
  --ui-button-text: #f1e2c0;
  --ui-button-border: #b08d47;
  --ui-button-hover-bg: linear-gradient(#6d3035, #3f1c20);
  --ui-button-shadow: inset 0 1px 0 rgba(240, 213, 140, .15), 0 1px 2px rgba(0, 0, 0, .6);
  --ui-tab-bg: linear-gradient(#2a1416, #1c0e10);
  --ui-tab-selected-bg: linear-gradient(#4f2227, #31161a);
  --ui-tab-lip: #e8c56b;
  --ui-slot-bg: radial-gradient(circle at 40% 30%, #3d1d21, #0e0708);
  --ui-slot-border: #8c6f37;
  --ui-scroll-track: rgba(0, 0, 0, .4);
  --ui-scroll-thumb: linear-gradient(90deg, #c9a456, #8a6a2e);
  --ui-backdrop: radial-gradient(circle at 50% 30%, #3a1a1e, #0b0506 70%);
  /* text that is read rather than glanced at sits on vellum */
  --ui-vellum: linear-gradient(#ecdfbf, #dbc89e);
  --ui-ink: #2d1f14;
  --ui-ink-soft: #5b4630;
}

/* ---- shared rules: the same components, whichever look is chosen ---- */

:root[data-ui-theme] :is(
  .window, #inventoryPanel, #splitPanel, #dialoguePanel, #vendorPanel,
  #lootPanel, .loot-roll, #characterPanel, #spellbookPanel, #worldMapPanel,
  #login .panel, #tradePanel, .bots-panel, .player-notes, .tooltip
) {
  background: var(--ui-panel-bg);
  border: var(--ui-panel-border);
  border-radius: var(--ui-panel-radius);
  box-shadow: var(--ui-panel-shadow);
}

/* Unit frames keep their text hard against the corners, where an ornament
   would sit on the level number, so they take the material without it. */
:root[data-ui-theme] .frame {
  background: var(--ui-panel-fill);
  border: var(--ui-panel-border);
  border-radius: var(--ui-panel-radius);
  box-shadow: var(--ui-panel-shadow);
}

:root[data-ui-theme] :is(.window, #inventoryPanel, #dialoguePanel, #vendorPanel, #lootPanel,
  #characterPanel, #spellbookPanel, #worldMapPanel, #login, #tradePanel, .player-notes) :is(h1, h2, h3) {
  font-family: var(--ui-font-heading);
  font-variant: var(--ui-heading-variant);
  font-style: var(--ui-heading-style);
  letter-spacing: var(--ui-heading-spacing);
  text-transform: var(--ui-heading-transform);
  color: var(--ui-heading);
  text-shadow: 0 1px 2px #000;
}

:root[data-ui-theme] :is(.window button, .language-picker button, .loot-roll button,
  .bots-panel button, .player-notes button, #genderPicker button):not([role="tab"]):not(.panel-close),
:root[data-ui-theme] #loginEnter {
  background: var(--ui-button-bg);
  border: 1px solid var(--ui-button-border);
  border-radius: 3px;
  color: var(--ui-button-text);
  box-shadow: var(--ui-button-shadow);
}
:root[data-ui-theme] :is(.window button, .language-picker button, .loot-roll button,
  .bots-panel button, .player-notes button, #genderPicker button, #loginEnter):not([role="tab"]):not(.panel-close):is(:hover:where(:not(.own-cursor *)), .hovered) {
  background: var(--ui-button-hover-bg);
  border-color: var(--ui-frame-hover);
  color: var(--ui-text-bright);
}
:root[data-ui-theme] :is(.model-options, .language-picker, #genderPicker) button[aria-pressed="true"] {
  background: var(--ui-tab-selected-bg);
  border-color: var(--ui-frame-bright);
  color: var(--ui-text-bright);
}
:root[data-ui-theme] button:disabled { opacity: .5; }

:root[data-ui-theme] .tab-strip > [role="tab"] { background: var(--ui-tab-bg); color: var(--ui-text-muted); }
:root[data-ui-theme] .tab-strip > [role="tab"]:is(:hover:where(:not(.own-cursor *)), .hovered) { color: var(--ui-text); }
:root[data-ui-theme] .tab-strip > [role="tab"][aria-selected="true"] {
  background: var(--ui-tab-selected-bg);
  border-color: var(--ui-frame);
  border-bottom-color: transparent;
  color: var(--ui-heading);
}
:root[data-ui-theme] .tab-strip > [role="tab"][aria-selected="true"]::before { background: var(--ui-tab-lip); }

:root[data-ui-theme] .slot { background: var(--ui-slot-bg); border-color: var(--ui-slot-border); }
:root[data-ui-theme] .slot-cell { background: var(--ui-well); border-color: var(--ui-frame-dim); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .6); }
:root[data-ui-theme] .slot-cell.filled { background: var(--ui-slot-bg); border-color: var(--ui-slot-border); }
:root[data-ui-theme] .scroll-bar { background: var(--ui-scroll-track); }
:root[data-ui-theme] .scroll-thumb { background: var(--ui-scroll-thumb); }
:root[data-ui-theme] .scroll-thumb:is(:hover:where(:not(.own-cursor *)), .hovered) { filter: brightness(1.25); }

:root[data-ui-theme] #login { background: var(--ui-backdrop); }

/* the manuscript's vellum pages: conversations and a quest's text. The doubled
   attribute matches the panel list above, whose `#login .panel` lifts the whole
   list to an id and a class; without it this rule would lose to that one. */
:root[data-ui-theme="codex"][data-ui-theme] :is(#dialoguePanel, #questLogDetail) {
  background: var(--ui-fleuron) 5px 5px / 16px 16px no-repeat, var(--ui-vellum);
  color: var(--ui-ink);
  text-shadow: none;
}
:root[data-ui-theme="codex"][data-ui-theme] :is(#dialoguePanel, #questLogDetail) :is(h2, h3) { color: #7a2a1e; text-shadow: none; }
:root[data-ui-theme="codex"] :is(#dialoguePanel, #questLogDetail) :is(p, li, span, div) { text-shadow: none; }
:root[data-ui-theme="codex"] #dialoguePanel :is(.dialogue-text, .quest-detail, .quest-detail *) { color: var(--ui-ink); }
:root[data-ui-theme="codex"] #dialoguePanel .quest-detail { background: rgba(255, 250, 235, .35); border-color: #b39a6a; }
:root[data-ui-theme="codex"] #dialoguePanel .quest-detail :is(h3, h4) { color: #7a2a1e; }
:root[data-ui-theme="codex"] #dialoguePanel .dialogue-option {
  background: rgba(255, 250, 235, .4); border-color: #b39a6a; color: #3b2414;
}
:root[data-ui-theme="codex"] #dialoguePanel .dialogue-option:is(:hover:where(:not(.own-cursor *)), .hovered) { background: rgba(255, 250, 235, .75); border-color: #7a2a1e; color: #1a0f08; }
:root[data-ui-theme="codex"] #dialoguePanel .dialogue-option.farewell { color: var(--ui-ink-soft); }
:root[data-ui-theme="codex"] #dialoguePanel .panel-close { color: var(--ui-ink); border-color: #b39a6a; }
:root[data-ui-theme="codex"] #questLogDetail :is(.quest-log-level, ul, .quest-log-destination) { color: var(--ui-ink-soft); }
:root[data-ui-theme="codex"] #questLogDetail .done { color: #1f5a2a; }
