/* ── Shared Base Styles ─────────────────────────────── */
/* Used by ALL pages (portfolio + westeros-sejire)      */
/* Nav-specific styles split to shared/nav.css          */

/* ── Breakpoint convention (use only these values) ─── */
/*   600px — mobile / tablet boundary (primary)         */
/*   900px — tablet / desktop boundary                  */
/*   480px — small-phone refinements (landing only)     */
/* Rationale: keeps responsive logic predictable across */
/* shared/components.css, theme.css, project styles. Westeros SCSS */
/* mirrors with $bp-sm=600 / $bp-md=900.                */

/* ── Scrollbar (global + utility) ─────────────────── */
/* Applied site-wide on the page scroller (html), plus to inner scrolls   */
/* (#search-results, .drawer-body) and any element tagged .scrollbar-thin. */
/* Webkit gets a 6px track + rounded thumb in --panel-sep colour;          */
/* Firefox uses scrollbar-width:thin + scrollbar-color (single declaration). */
/* scrollbar-gutter:stable reserves space so layout doesn't jump when */
/* content grows past the viewport.                                        */
html {
  scrollbar-gutter: stable;
}
html,
.scrollbar-thin,
#search-results,
.drawer-body {
  scrollbar-width: thin;
  scrollbar-color: var(--panel-sep, var(--div-top)) transparent;
}
html::-webkit-scrollbar,
.scrollbar-thin::-webkit-scrollbar,
#search-results::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
html::-webkit-scrollbar-track,
.scrollbar-thin::-webkit-scrollbar-track,
#search-results::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track {
  background: transparent;
}
html::-webkit-scrollbar-thumb,
.scrollbar-thin::-webkit-scrollbar-thumb,
#search-results::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--panel-sep, var(--div-top));
  border-radius: 3px;
}
html::-webkit-scrollbar-thumb:hover,
.scrollbar-thin::-webkit-scrollbar-thumb:hover,
#search-results::-webkit-scrollbar-thumb:hover,
.drawer-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Skip link (a11y) ──────────────────────────────── */
/* Visually hidden until keyboard focus jumps to it; jumps the user
   straight to #main-content, bypassing nav/header chrome.                */
.skip-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  z-index: 1000;
  background: var(--header-btn-bg, #000);
  color: var(--header-text, #fff);
  border: 1px solid var(--header-btn-border, currentColor);
  border-radius: var(--win-radius, 4px);
  font-family: inherit;
  font-size: 12px;
  text-decoration: none;
  letter-spacing: 0.04em;
}
.skip-link:focus,
.skip-link:focus-visible {
  width: auto;
  height: auto;
  clip: auto;
  clip-path: none;
  padding: 8px 14px;
  outline: 2px solid var(--nav-active);
  outline-offset: 2px;
}

/* ── Lucide icons ──────────────────────────────────── */
/* Inline SVGs from shared/icons.js. Inherit colour via stroke="currentColor"
   so theme overrides work without per-icon styling.                       */
.lucide,
[data-lucide] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  line-height: 0;
}
.lucide svg,
[data-lucide] svg {
  display: block;
}
/* Side-panel toggle indicator: Lucide chevron-right; rotate to 90° (down)
   when the panel is expanded, smoothly. The icon stays a chevron-right
   in markup; CSS handles the visual orientation.                         */
.side-panel .side-panel-toggle .arrow {
  transition: transform 0.18s ease;
  transform: rotate(90deg);
}
.side-panel.collapsed .side-panel-toggle .arrow {
  transform: rotate(0deg);
}

/* ── Tap target (mobile-only ≥44px utility) ─────────── */
/* Apply to clickable rows / icon-only buttons that are */
/* dense on desktop but should grow on touch. WCAG 2.5.5. */
/* Only sets min-height — does not force flex/align so it */
/* stays compatible with existing layouts.               */
@media (max-width: 600px) {
  .tap-target { min-height: 44px; }
}

/* ── Side panel subhead (shared) ──────────────────── */
/* Small uppercase label used to group items inside a side-panel body. */

.side-panel-subhead {
  font-family: inherit;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 14px 0 6px;
}
.side-panel-body > .side-panel-subhead:first-child { margin-top: 0; }

/* ── Panel description text (shared) ──────────────── */
/* Body copy paragraph for descriptive text inside drawers/panels. */

.panel-desc {
  font-size: 13px;
  line-height: 1.85;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.panel-desc:last-child { margin-bottom: 0; }

/* ── Header button (shared across all pages) ──────── */

.btn-header {
  background: var(--header-btn-bg, transparent);
  border: 1px solid var(--header-btn-border);
  border-radius: var(--win-radius, 0);
  padding: 4px 10px;
  font-family: var(--body-font, 'Cinzel', serif);
  font-size: 10px;
  line-height: 1.4;
  letter-spacing: 0.12em;
  color: var(--header-btn-text, var(--header-text));
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.btn-header:active { opacity: 0.85; }
.btn-header:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-header:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: 2px;
}

@media (hover: hover) and (pointer: fine) {
  .btn-header:hover { border-color: var(--nav-active, var(--header-text)); color: var(--text); }
}

/* ── Site logo / home link ─────────────────────────── */

#site-logo {
  text-decoration: none;
  flex-shrink: 0;
}

/* ── Theme Switcher ────────────────────────────────── */

#theme-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: auto;
}

.ts-group {
  display: flex;
  gap: 2px;
}

.ts-sep {
  width: 1px;
  height: 20px;
  background: var(--header-border, rgba(192,57,43,0.2));
  flex-shrink: 0;
}

.ts-btn {
  padding: 3px 7px;
  font-size: 10px;
  cursor: pointer;
  font-family: var(--body-font, 'Cinzel', serif);
  background: transparent;
  color: var(--header-btn-text, rgba(201,168,76,0.65));
  border: 1px solid var(--header-btn-border, rgba(192,57,43,0.25));
  border-radius: var(--win-radius, 3px);
  white-space: nowrap;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.ts-btn:hover {
  border-color: var(--header-text, #c9a84c);
  color: var(--header-text, #c9a84c);
}
.ts-btn.active {
  background: var(--btn-active-bg, rgba(192,57,43,0.18));
  color: var(--btn-active-fg, #c9a84c);
  border-color: var(--btn-active-fg, #c9a84c);
}

@media (max-width: 600px) {
  #site-header #theme-switcher { display: none; }
  /* Smaller header buttons on mobile across all pages */
  .btn-header { font-size: 9px; padding: 3px 7px; }

  /* Touch-target floor: 44×44 hit-zone via an invisible ::before pseudo
     so the visible chip stays compact (Modern's border-radius: 999px
     would otherwise turn min-width/min-height: 44 into giant circles).
     The pseudo extends beyond the button's box and catches the tap;
     the click bubbles to the button itself. Only applied to icon-only
     header buttons — text buttons ("Back", "Search", "RU") already give
     a comfortable target via natural width. */
  #sidebar-toggle-btn,
  #year-prev,
  #year-next,
  .info-btn,
  .ts-btn[data-prop="mode"],
  #theme-reset {
    position: relative;
  }
  #sidebar-toggle-btn::before,
  #year-prev::before,
  #year-next::before,
  .info-btn::before,
  .ts-btn[data-prop="mode"]::before,
  #theme-reset::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    min-width: 44px;
    min-height: 44px;
    width: 100%;
    height: 100%;
  }

  /* Floating theme switcher on mobile: with 5 themes + 2 modes + reset
     the row overflows on narrow phones. Switch to horizontal scroll —
     keeps natural readable button sizes, reveals overflow with a swipe.
     Scrollbar hidden so the chip-bar looks intentional, not "broken". */
  #theme-switcher {
    left: 10px;
    right: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x proximity;
  }
  #theme-switcher::-webkit-scrollbar { display: none; }
  #theme-switcher .ts-btn { scroll-snap-align: center; }
}

/* ── Segmented control ────────────────────────────── */

.segmented-control {
  display: flex;
  gap: 2px;
  background: var(--win-bg);
  border: 1px solid var(--div-top);
  border-radius: var(--win-radius);
  padding: 3px;
  width: fit-content;
}

.segmented-control-btn {
  padding: 7px 18px;
  font-size: 12px;
  font-family: var(--body-font, 'DM Sans', system-ui, sans-serif);
  font-weight: 500;
  border: none;
  border-radius: var(--win-radius, 6px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.segmented-control-btn:hover {
  background: var(--hover-bg);
  color: var(--hover-fg);
}
.segmented-control-btn.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-fg);
  font-weight: 600;
}

/* On mobile the segmented control fills the row and its buttons share
   space equally — so "Winners / All Nominees" and similar two/three-way
   toggles read full-width instead of clinging to the left margin. */
@media (max-width: 600px) {
  .segmented-control { width: 100%; }
  .segmented-control-btn { flex: 1; }
}

/* ── Search modal ─────────────────────────────────────── */

#search-btn {
  display: flex;
  align-items: center;
  gap: 4px;
}
#search-btn .search-icon { font-size: 13px; line-height: 1; }

#search-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 600;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
#search-modal.open { display: flex; }

#search-box {
  width: min(480px, 92vw);
  background: var(--panel-bg, var(--win-bg));
  border: 1px solid var(--panel-sep, var(--div-top));
  border-radius: var(--win-radius, 0);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.7);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
}

#search-input-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--panel-sep, var(--div-top));
}

#search-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 16px 20px;
  font-size: 15px;
  color: var(--text);
  font-family: var(--body-font, 'DM Sans', system-ui, sans-serif);
}
#search-input:focus { outline: none; }
#search-input:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: -2px;
}
#search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

#search-close {
  border: none;
  border-radius: 0;
  padding: 0 18px;
  font-size: 18px;
  line-height: 1;
}
#search-close:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: -2px;
}

#search-results {
  overflow-y: auto;
  padding: 6px 0;
  max-height: 55vh;
}

.sr-item {
  display: flex;
  gap: 10px;
  padding: 10px 20px;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: background 0.12s;
}
.sr-item:hover,
.sr-item.active {
  background: var(--hover-bg);
  border-left-color: var(--nav-active);
}

#search-empty {
  padding: 24px 20px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Drawer (slide-in panel) ──────────────────────── */

.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 320px;
  max-width: 85vw;
  z-index: 500;
  background: var(--panel-bg, var(--win-bg));
  border-right: 1px solid var(--panel-sep, var(--div-top));
  transform: translateX(calc(-100% - 2px));
  transition: transform 0.3s cubic-bezier(.22, 1, .36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}
.drawer::before {
  content: '';
  display: block;
  height: 2px;
  background: linear-gradient(to right, var(--nav-active), transparent);
  flex-shrink: 0;
}
.drawer.open {
  transform: translateX(0);
  pointer-events: all;
}

.drawer-close,
.drawer-back {
  width: 26px;
  height: 26px;
  background: none;
  border: 1px solid var(--panel-sep, var(--div-top));
  border-radius: 50%;
  font-family: sans-serif;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  z-index: 5;
  transition: border-color 0.15s, color 0.15s;
}
.drawer-close:hover,
.drawer-back:hover {
  border-color: var(--nav-active);
  color: var(--text);
}
.drawer-close:focus-visible,
.drawer-back:focus-visible {
  outline: 2px solid var(--nav-active);
  outline-offset: 2px;
}

.drawer-close {
  top: 12px; right: 16px;
  font-size: 13px;
}

.drawer-back {
  top: 12px; left: 16px;
  font-size: 14px;
  display: none;
}
.drawer-back.show { display: flex; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 38px 26px 40px;
}

.drawer-divider {
  height: 1px;
  background: linear-gradient(to right, var(--panel-sep, rgba(128,128,128,.25)), transparent);
  margin: 18px 0;
}

.drawer-label {
  font-size: 8px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 9px;
}

@media (max-width: 600px) {
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    height: 70vh; max-height: 70vh;
    border-right: none;
    border-top: 1px solid var(--panel-sep, var(--div-top));
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    transform: translateY(100%);
    box-shadow: 0 -10px 40px rgba(0,0,0,.6);
  }
  .drawer.open { transform: translateY(0); }
  .drawer::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 42px; height: 4px;
    background: var(--panel-sep, var(--div-top));
    border-radius: 2px;
  }
  .drawer-body { padding: 24px 20px 30px; }
  .drawer-close { top: 10px; right: 12px; }
}

/* ── Win95 base overrides ──────────────────────────── */

html[data-style="win95"] .btn-header {
  backdrop-filter: none;
  padding: 2px 8px; font-size: 10px; letter-spacing: 0;
  border-radius: 0;
  border: 2px solid;
  border-top-color: var(--btn-lt, #fff); border-left-color: var(--btn-lt, #fff);
  border-right-color: var(--btn-dk, #808080); border-bottom-color: var(--btn-dk, #808080);
  background: var(--win-bg, #c0c0c0); color: var(--text, #000);
}
html[data-style="win95"] .btn-header:hover {
  color: var(--text, #000);
  border-color: var(--btn-dk, #808080);
}
html[data-style="win95"] .btn-header.active {
  border-top-color: var(--btn-dk, #808080); border-left-color: var(--btn-dk, #808080);
  border-right-color: var(--btn-lt, #fff); border-bottom-color: var(--btn-lt, #fff);
  background: var(--btn-active-bg, #000080); color: var(--btn-active-fg, #fff);
}

html[data-style="win95"] .ts-btn {
  letter-spacing: 0; border-radius: 0; font-size: 10px;
  border: 2px solid;
  border-top-color: var(--btn-lt, #fff); border-left-color: var(--btn-lt, #fff);
  border-right-color: var(--btn-dk, #808080); border-bottom-color: var(--btn-dk, #808080);
  padding: 1px 5px;
  background: var(--win-bg, #c0c0c0); color: var(--text, #000);
}
html[data-style="win95"] .ts-btn:hover {
  color: var(--text, #000);
  border-color: var(--btn-dk, #808080);
  background: var(--win-bg, #c0c0c0);
}
html[data-style="win95"] .ts-btn.active {
  border-top-color: var(--btn-dk, #808080); border-left-color: var(--btn-dk, #808080);
  border-right-color: var(--btn-lt, #fff); border-bottom-color: var(--btn-lt, #fff);
  background: var(--btn-active-bg, #000080); color: var(--btn-active-fg, #fff);
}
html[data-style="win95"] .ts-sep { background: var(--btn-dk, #808080); }

html[data-style="win95"] #search-box {
  border-radius: 0;
  border: 2px solid;
  border-top-color: var(--btn-dk, #808080); border-left-color: var(--btn-dk, #808080);
  border-right-color: var(--btn-lt, #fff); border-bottom-color: var(--btn-lt, #fff);
}

/* ── Modern base overrides (visionOS / Apple-glass) ── */

/* Modern: pill shape + light glass on the *header* itself, but not on
   every button. backdrop-filter is expensive — composited per layer —
   so we keep it only where it visibly bites: drawers and the big search
   modal. Buttons sit on a translucent background-color that already gives
   the glass feel without forcing per-button compositing. */
html[data-style="modern"] .btn-header {
  letter-spacing: 0; font-size: 11px; font-weight: 500;
  border-radius: 999px;
}

html[data-style="modern"] .ts-btn {
  letter-spacing: 0; font-size: 10px; font-weight: 500;
  border-radius: 999px;
}
html[data-style="modern"] .ts-btn.active,
html[data-style="modern"] .btn-header.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-fg);
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(0,122,255,0.35);
}
/* Modern search-box: light glass card. The 0.6-alpha --panel-bg let
   page content (category headings, list rows) bleed through too much
   and fight the results for attention. Bumped to 0.92 alpha + a softer
   blur(16px) to keep the visionOS "frosted glass" character without
   the readability hit. */
html[data-style="modern"] #search-box {
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.06);
}
html[data-style="modern"][data-mode="dark"] #search-box {
  background: rgba(26,31,44,0.92);
  border-color: rgba(255,255,255,0.08);
  box-shadow: 0 24px 64px rgba(0,0,0,0.6), 0 1px 2px rgba(0,0,0,0.3);
}
html[data-style="modern"] #search-close {
  border-radius: 0;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  background: transparent;
  border: none;
  padding: 0 18px;
  color: var(--text-muted);
}
html[data-style="modern"] #search-close:hover {
  background: var(--hover-bg);
  color: var(--text);
}
html[data-style="modern"] #search-input:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(0,122,255,0.4);
}
html[data-style="modern"] .drawer {
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  background: var(--panel-bg);
  border-right: 1px solid var(--header-btn-border);
  border-top-right-radius: var(--win-radius, 16px);
  border-bottom-right-radius: var(--win-radius, 16px);
  box-shadow: var(--win-shadow), 0 8px 32px rgba(0,0,0,0.12);
}
html[data-style="modern"] .drawer::before {
  background: transparent;
}
@media (max-width: 600px) {
  html[data-style="modern"] .drawer {
    border-right: none;
    border-radius: var(--win-radius, 16px) var(--win-radius, 16px) 0 0;
  }
  html[data-style="modern"] .drawer::before {
    background: var(--panel-sep, var(--div-top));
  }
  /* Modern keeps its 11px font on desktop; on narrow viewports drop to 10px
     so it slots into the floating theme-switcher row alongside base mobile
     (9px) without overflow. Padding now matches base — kept for font-size only. */
  html[data-style="modern"] .btn-header,
  html[data-style="modern"] .ts-btn {
    font-size: 10px;
  }
}

/* ── Brutal base overrides ─────────────────────────── */

html[data-style="brutal"] .btn-header,
html[data-style="brutal"] .ts-btn {
  letter-spacing: 0; font-size: 11px; font-weight: 500;
  border-width: 2px; border-style: solid; border-radius: var(--win-radius, 8px);
  border-color: var(--header-btn-border);
  background: var(--header-btn-bg);
  color: var(--header-btn-text);
  box-shadow: 2px 2px 0 var(--header-btn-border);
  backdrop-filter: none;
  transition: transform 0.1s, box-shadow 0.1s, background 0.1s;
}
html[data-style="brutal"] .btn-header:hover,
html[data-style="brutal"] .ts-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--header-btn-border);
  background: var(--hover-bg);
  color: var(--hover-fg);
  border-color: var(--header-btn-border);
}
html[data-style="brutal"] .btn-header.active,
html[data-style="brutal"] .ts-btn.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-fg);
  border-color: var(--header-btn-border);
  box-shadow: 2px 2px 0 var(--nav-active);
}
html[data-style="brutal"] .ts-sep {
  background: var(--header-btn-border);
  width: 2px;
}
html[data-style="brutal"] #search-box {
  border: 2px solid var(--header-btn-border);
  border-radius: var(--win-radius, 10px);
  box-shadow: 3px 3px 0 var(--header-btn-border);
}

/* ── Term base overrides ───────────────────────────── */

html[data-style="term"] .btn-header,
html[data-style="term"] .ts-btn {
  letter-spacing: 0.02em; font-size: 10px; font-weight: 400;
  border-radius: 0;
  text-transform: uppercase;
  backdrop-filter: none;
}
html[data-style="term"] .btn-header:hover,
html[data-style="term"] .ts-btn:hover {
  background: var(--hover-bg);
  color: var(--hover-fg);
  border-color: var(--header-btn-border);
}
html[data-style="term"] .ts-btn.active,
html[data-style="term"] .btn-header.active {
  background: var(--btn-active-bg);
  color: var(--btn-active-fg);
  border-color: var(--btn-active-bg);
}
html[data-style="term"] .ts-sep {
  background: var(--header-btn-border);
}
html[data-style="term"] #search-box {
  border: 1px solid var(--header-btn-border);
  border-radius: 0;
}

/* ── Reduced motion ───────────────────────────────── */
/* Strip transitions, animations and smooth-scroll for users who prefer
   reduced motion. Drawer/search modal still toggle visibility, just
   without sliding/fading. Caveat: this can't reach SVG D3 force-simulation
   in westeros — that's controlled in JS (see scripts/main.js).            */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
