/* ===== 0. Theme variables ===== */
:root {
  /* Dark foundation (PRD-13) */
  --bg:           #0B0B12;
  --surface:      #14141F;
  --surface-2:    #1C1C2C;
  --text:         #EAEAF2;
  --muted:        #8B8B99;
  --border:       rgba(255, 255, 255, 0.08);
  --card-bg:      #181826;

  /* Neon accents (blade-runner × vapor-wave) */
  --accent:       #00E1FF;
  --accent-2:     #FF2C7A;
  --accent-3:     #9D7BFF;
  --accent-tint:  rgba(0, 225, 255, 0.12);

  /* macOS traffic lights (functional, PRD-13) */
  --traffic-close:    #FF5F57;
  --traffic-minimize: #FEBC2E;
  --traffic-maximize: #28C840;

  /* Desktop shell vars */
  --window-bg:        #14141F;
  --titlebar-bg:      rgba(22, 22, 34, 0.72);
  --titlebar-text:    #EAEAF2;
  --window-shadow:    0 12px 32px rgba(0, 0, 0, 0.4);
  --window-ring:      0 0 0 3px var(--accent-tint);
  --backdrop-bg:      rgba(5, 5, 10, 0.62);
  --glass-bg:         rgba(15, 15, 24, 0.72);
  --glass-blur:       saturate(160%) blur(14px);
  --desktop-glow:     radial-gradient(ellipse 80% 50% at 50% 0%, rgba(0, 225, 255, 0.06), transparent 70%);
  --desktop-grid:     radial-gradient(circle, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  --menu-bar-h:       52px;
  --status-bar-h:     40px;

  /* Shadows (dark-adjusted) */
  --shadow-sm:    0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg:    0 8px 20px rgba(0, 0, 0, 0.4);

  /* AI:
     what: Apple HIG SF type-scale tokens — single source of truth for §3 mappings.
     why:  PRD-13 chrome left typography to Bootstrap; aligns to Apple HIG hierarchy.
     ref:  PRD-24 §1
  */
  /* macOS typography (PRD-24) */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", Monaco, Menlo, Consolas, "Liberation Mono", monospace;

  /* Apple HIG type scale (rem; px values in comments) */
  --fs-caption2: 0.6875rem;   /*  11 */
  --fs-caption1: 0.75rem;     /*  12 */
  --fs-footnote: 0.8125rem;   /*  13 */
  --fs-subhead:  0.9375rem;   /*  15 */
  --fs-body:     1rem;       /*  16 */
  --fs-headline: 1.0625rem;  /*  17 */
  --fs-title3:   1.25rem;    /*  20 */
  --fs-title2:   1.375rem;   /*  22 */
  --fs-title1:   1.75rem;    /*  28 */

  /* Weights */
  --fw-regular:  400;
  --fw-medium:   500;
  --fw-semibold: 600;
  --fw-bold:     700;

  /* Spacing tokens */
  --space-2xs: 4px;
  --space-xs:  8px;
  --space-sm:  12px;
  --space-md:  16px;
  --space-lg:  24px;

  /* Radii */
  --radius-window:   10px;
  --radius-dropdown: 12px;
  --radius-button:    6px;
  --radius-card:      8px;
}

/* ===== 1. Base & typography ===== */
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* AI:
   what: Screen-reader-only utility — keeps the site name a11y-visible without on-screen menu-bar text.
   why:  PRD-13 removes the visible brand element but retains a single <h1> for screen readers (AGENTS §Accessibility single-h1 rule); PRD's spec verbatim.
   ref:  PRD-13 §index.html changes */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ===== 2. Menu bar & shell ===== */
.os-menu-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--menu-bar-h);
  padding: 0.5rem 1rem;
  background-color: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 1px 10px rgba(0, 0, 0, 0.4);
}

.os-menu-items {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.os-menu-item {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  color: var(--muted);
  background-color: transparent;
  border: none;
  border-radius: var(--radius-button);
  cursor: pointer;
  transition: background-color 150ms ease, color 150ms ease;
}
.os-menu-item:hover,
.os-menu-item:focus-visible {
  background-color: var(--surface-2);
  color: var(--accent);
}

.os-menu-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.os-status-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.os-status-glyph {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.2;
  pointer-events: none;
}

.os-status-item time {
  font-size: var(--fs-caption1);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* PRD-18: Play button — hidden on mobile (<768px), shown on desktop */
.os-menu-item--play {
  display: none;
}
@media (min-width: 768px) {
  .os-menu-item--play {
    display: inline-block;
  }
}

/* PRD-18: Exit button — hidden unless game is active */
.os-menu-item--exit {
  display: none;
}
body.is-game-active .os-menu-item--exit {
  display: inline-block;
}

/* PRD-18: In ACTIVE mode, hide all menu items except Exit */
body.is-game-active .os-menu-item:not(.os-menu-item--exit) {
  display: none;
}

/* ===== 3. Desktop area ===== */

/* PRD-17/18: p5 sketch background host. Fixed full-viewport, below all shell chrome. */
#bg-sketch-host {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
#bg-sketch-host canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none; /* PRD-18: IDLE default — let clicks pass through to desktop below */
}

/* PRD-18: ACTIVE game mode — lift host above desktop+window-ledger, enable canvas clicks */
body.is-game-active #bg-sketch-host {
  z-index: 99; /* above .os-desktop (tree-order step 3) and .os-window-ledger (z-index 50), below .os-menu-bar (100) */
}
body.is-game-active #bg-sketch-host canvas {
  pointer-events: auto; /* p5's mousePressed fires only now — bullets spawn */
}

.os-desktop {
  position: relative;
  min-height: calc(100vh - var(--menu-bar-h) - var(--status-bar-h));
  background-image: var(--desktop-grid), var(--desktop-glow);
  background-size: 24px 24px, 100% 100%;
  background-repeat: repeat, no-repeat;
  background-position: top left, center top;
}

.os-window-ledger {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* ===== 4. Desktop icons ===== */

/* Mobile-first: horizontal scrollable strip (PRD-9). */
.os-desktop {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 1rem;
  gap: 0.75rem;
}

/* ≥768px: absolute icons; left/top set via JS at render (vertical column layout, PRD-13). */
@media (min-width: 768px) {
  .os-desktop {
    display: block;
    overflow-x: visible;
  }
  .desktop-icon {
    position: absolute;
  }
}

.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 88px;
  min-width: 44px;
  padding: 0.5rem;
  background-color: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 150ms ease, transform 150ms ease;
}

.desktop-icon:hover,
.desktop-icon:focus-visible {
  background-color: var(--accent-tint);
}

.desktop-icon:hover {
  transform: translateY(-2px) scale(1.02);
}

.desktop-icon__glyph {
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.desktop-icon__glyph svg {
  width: 32px;
  height: 32px;
}

.desktop-icon__label {
  font-size: 0.8rem;
  color: var(--text);
  text-align: center;
  margin-top: 0.35rem;
}

/* ===== 5. Window chrome & stacking ===== */

/* AI:
   what: macOS-style rounded dark-frosted window element with brand-tinted focus ring + entrance animation.
   why:  PRD-13 supersedes PRD-8's single-close shell with traffic-light chrome; dark frosted aesthetic via --window-bg/--border; .is-focused box-shadow is the accessibility focus signal (color not the only differentiator).
   ref:  PRD-13 §Window chrome, §Drag-and-drop */
.os-window {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--window-bg);
  border: 1px solid var(--border);
  border-radius: 0;
  box-shadow: var(--window-shadow);
  z-index: 1000;
  pointer-events: auto;
  animation: window-open 160ms ease-out;
}

.os-window-titlebar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0.85rem;
  background-color: var(--titlebar-bg);
  color: var(--titlebar-text);
  flex-shrink: 0;
}

/* AI:
   what: Non-overlapping inline-flex cluster of traffic-light controls (gap: 0).
   why:  PRD-32 enforces 44x44 touch target on mobile; desktop shrinks buttons to 20x32px so 12px discs sit 8px edge-to-edge (macOS) with no overlap.
   ref:  PRD-32 §3 */
.os-window-controls {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.os-window-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  position: relative;
}

.os-window-btn > span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  line-height: 1;
  color: rgba(0, 0, 0, 0.85);
  opacity: 0;
  pointer-events: none;
  transition: opacity 130ms ease;
}

/* AI:
   what: 12px colored disc in ::before over a 44px transparent button.
   why:  PRD-32 keeps the visible disc at 12px (PRD-13 spec) while the button provides a 44px hit area.
   ref:  PRD-32 §1, §2 */
.os-window-btn::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--traffic-maximize);
}

.os-window-btn--close::before    { background-color: var(--traffic-close); }
.os-window-btn--minimize::before { background-color: var(--traffic-minimize); }
.os-window-btn--maximize::before { background-color: var(--traffic-maximize); }

.os-window-btn--close:hover::before { background-color: var(--traffic-close); }

.os-window-btn:hover > span,
.os-window-btn:focus-visible > span {
  opacity: 1;
}

.os-window-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* Mobile: hide minimize + maximize; keep only close visible. */
.os-window-btn--minimize,
.os-window-btn--maximize {
  display: none;
}

@media (min-width: 768px) {
  .os-window-btn--minimize,
  .os-window-btn--maximize {
    display: inline-flex;
  }

  /* Desktop: tighter non-overlapping traffic lights matching macOS spacing. */
  .os-window-btn {
    width: 20px;
    height: 32px;
  }
}

.os-window-title {
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  font-feature-settings: "ss01";
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  /* Reserve buffer on both sides so the centered title does not underlap the controls cluster. */
  max-width: calc(100% - 140px);
}

.os-window-body {
  overflow-y: auto;
  max-height: none;
  flex: 1 1 auto;
}

.os-window.is-minimized .os-window-body {
  display: none;
}

.os-window.is-minimized {
  height: auto;
  max-height: none;
}

.os-window.is-focused {
  box-shadow: var(--window-ring), var(--window-shadow);
}

.os-window-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--backdrop-bg);
  z-index: 999;
  pointer-events: auto;
  animation: window-open 120ms ease-out;
}

@keyframes window-open {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* AI:
   what: Desktop-centered variant of window-open that preserves the translate(-50%,-50%) centering offset in both keyframe stops.
   why:  The base window-open keyframes replace the transform entirely (translateY → none), which strips the centered translate(-50%,-50%) set by the ≥768px .os-window rule. During the 160ms animation the window renders with its top-left corner at top:50%/left:50% (lower-right area), then snaps to center when the animation ends and the CSS rule reasserts. This variant keeps translate(-50%,-50%) in both stops so the window stays centered throughout the entrance.
   ref:  bug-fix review — window flash in lower-right corner */
@keyframes window-open-centered {
  from {
    opacity: 0;
    transform: translate(-50%, calc(-50% + 8px)) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

/* Mobile-first: full-screen below 768px (PRD-8). */
/* ≥768px: centered windows, max-width 95%, max-height 80vh, draggable (PRD-13). */
@media (min-width: 768px) {
  .os-window {
    inset: auto;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 95%;
    max-width: 95%;
    height: auto;
    max-height: 80vh;
    border-radius: var(--radius-window);
    overflow: hidden;
    animation: window-open-centered 160ms ease-out;
  }

  .os-window-titlebar {
    border-radius: 12px 12px 0 0;
  }

  .os-window-body {
    max-height: 75vh;
  }

  /* AI:
      what: Maximized window fills the viewport below the menu bar and above the status bar.
      why:  PRD-13 §Window control behavior — toggle via .is-maximized; filled via calc(menu-bar-h / status-bar-h) so it respects shell heights; transform:none overrides the centered translate(-50%,-50%) so the window pins to top-left.
      ref:  PRD-13 §Window chrome, §Window control behavior */
  .os-window.is-maximized {
    position: fixed;
    inset: calc(var(--menu-bar-h, 52px)) 0 calc(var(--status-bar-h, 40px)) 0;
    width: auto;
    max-width: none;
    height: auto;
    max-height: none;
    transform: none;
    border-radius: 0;
  }
}

/* ≥992px: centered windows, max-width ~720px (PRD-8). */
@media (min-width: 992px) {
  .os-window {
    max-width: 720px;
  }
}

/* Drag helper: user-select:none on body during a titlebar drag (PRD-13). */
body.is-dragging,
body.is-dragging * {
  user-select: none;
}

/* ===== 6. Post-list window ===== */

/* (unchanged from PRD-10 — dark theme via :root vars) */
.post-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 1rem;
}

@media (min-width: 768px) {
  .post-list {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

.post-list-item {
  position: relative;
  padding: 0;
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.post-list-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.post-list-item__trigger {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
}

.post-list-item__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  transition: transform 150ms ease;
}

.post-list-item:hover .post-list-item__image {
  transform: scale(1.04);
}

.post-list-item__title {
  margin: 0;
  padding: 0.65rem 0.75rem;
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
  text-align: left;
}

.post-list-item__logo {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  opacity: 1;
  transition: opacity 120ms ease;
}

.post-list-item__logo:hover {
  opacity: 0.85;
}

.post-list-item__logo img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: rgba(15, 15, 24, 0.8);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
}

.post-list__empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ===== 7. Post-detail window ===== */

.post-detail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
}

.post-detail__hero {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  /* AI:
     what: Inset bottom gradient overlay on the hero image for depth.
     why:  PRD-11 spec value — soft legibility hint on lighter images; no hard border, keeps a clean photo-centric look.
     ref:  PRD-11 */
  box-shadow: inset 0 -40px 30px -20px rgba(0, 0, 0, 0.15);
}

.post-detail__logo {
  display: inline-block;
  margin-top: 0.75rem;
  opacity: 1;
  transition: opacity 120ms ease;
}

.post-detail__logo:hover {
  opacity: 0.85;
}

.post-detail__logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(15, 15, 24, 0.8);
  border: 1px solid var(--border);
  backdrop-filter: var(--glass-blur);
}

/* AI:
   what: Publication/media source label below hero, after .post-detail__logo (or after hero when logo null), before .category-pill.
   why:  PRD-11 §4 — small all-caps source line; CSS text-transform: uppercase converts the original-case textContent for visual display so screen readers still read the verbatim string. Only rendered when post.source is non-null (PRD-11 acceptance).
   ref:  PRD-11 §4
*/
.post-detail__source {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.5rem;
}

.post-detail__title {
  font-size: var(--fs-title3);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.022em;
  line-height: 1.2;
  font-feature-settings: "ss01";
  color: var(--text);
  margin-top: 0.75rem;
}

.post-detail__blurb {
  color: var(--text);
  font-size: var(--fs-headline);
  font-weight: var(--fw-regular);
  line-height: 1.45;
}

/* ===== 8. Menu-section modal ===== */

/* AI:
   what: Modal windows capped at 600px max-width (vs .os-window's 720px at ≥992px / 95% at ≥768px).
   why:  PRD-12 §Layout line 40 specifies "Modal window: max-width 600px, centered"; without this rule the About modal inherited .os-window's 720px. [data-window-type="modal"] (one attribute selector) has equal specificity to .os-window (one class selector), so source order (§8 after §5) makes this rule win.
   ref:  PRD-31, PRD-12
*/
[data-window-type="modal"] {
  max-width: 600px;
}

.menu-section {
  padding: 1.25rem;
}

.menu-section__placeholder {
  color: var(--muted);
  font-size: var(--fs-footnote);
  font-style: italic;
  text-align: center;
}

.menu-section__content {
  font-size: var(--fs-body);
  font-weight: var(--fw-regular);
  line-height: 1.5;
  color: var(--text);
}

/* AI:
   what: About rich-content additions — photo + paragraphs inside .menu-section__content.
   why:  PRD-12 deferred rich-content path now in use (About); image keeps natural aspect ratio (no forced crop) bounded by max-width/max-height so the modal stays scrollable on small viewports; paragraphs spaced via adjacent-sibling selector to avoid per-element classes.
   ref:  PRD-12
*/
.menu-section__image {
  display: block;
  max-width: 100%;
  max-height: 56vh;
  margin: 0 auto 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.menu-section__paragraph + .menu-section__paragraph {
  margin-top: 1rem;
}

/* ===== 9. Shared components ===== */
.category-pill {
  display: inline-block;
  background-color: var(--accent-tint);
  color: var(--accent);
  font-size: var(--fs-caption1);
  font-weight: var(--fw-medium);
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.read-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  align-self: flex-start;
  margin-top: auto;
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
  color: var(--accent);
}
.read-link:hover { color: var(--accent); text-decoration: underline; }

.post-date {
  font-size: var(--fs-footnote);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

/* ===== 10. Status bar / footer ===== */
.os-status-bar {
  position: sticky;
  bottom: 0;
  z-index: 90;
  min-height: var(--status-bar-h);
  padding: 0.5rem 1rem;
  background-color: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: 0 -1px 10px rgba(0, 0, 0, 0.4);
  color: var(--muted);
  font-size: var(--fs-caption1);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.os-status-bar span {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
}

/* ===== 11. Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto;
  }
}

/* ===== 12. Catalog menu box & PDF viewer [PRD-20] ===== */

/* Mobile-first: <768px windows are already full-screen per PRD-13; inherit. */
.catalog-menu-box {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.catalog-menu-item { /* <li> wrapper */
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-button);
}
.catalog-menu-item:last-child { border-bottom: none; }
.catalog-menu-item__btn {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  font-size: var(--fs-subhead);
  font-weight: var(--fw-medium);
  letter-spacing: -0.01em;
}
.catalog-menu-item__btn:hover,
.catalog-menu-item__btn:focus-visible {
  background-color: var(--surface-2);
  color: var(--accent);  /* cyan; color is one of TWO signals (background is the other) */
}
.catalog-menu-item__title {
  flex: 1 1 auto;
  white-space: nowrap;       /* no wrap — PRD-20 overflow rule */
  overflow: hidden;
  text-overflow: ellipsis;   /* finish with "..." when title > line width */
  font-size: 0.95rem;
}
.catalog-menu-item__year {
  flex: 0 0 auto;
  font-size: var(--fs-caption1);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.catalog-menu-box__empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 2rem 1rem;
}

/* AI:
     what: Catalog-menu dropdown chrome at ≥768px — anchored to trigger button,
           not centered. Anchoring (top/left/right) set by JS at open time via
           WindowManager.openWindow's opts.anchoredTo path; CSS only constrains
           dimensions + scroll + box-shadow. Mobile (<768px) inherits PRD-13's
           full-screen modal rule.
     why:  User-reported UX bug fix (PRD-23): Mac-style dropdown expectations.
     ref:  PRD-23 §Spec §5
*/
@media (min-width: 768px) {
  .os-window.is-anchored[data-window-type="catalog-menu"] {
    position: absolute;
    width: 360px;
    max-width: 90vw;
    height: auto;
    max-height: 640px;          /* ≈ 24 patent entries + chrome; otherwise scrolls */
    display: flex;              /* body fills vertical space below titlebar */
    flex-direction: column;
    box-shadow: var(--shadow-lg);   /* lifted above desktop; no backdrop (modal:false) */
    border-radius: var(--radius-dropdown);
  }
  .os-window.is-anchored[data-window-type="catalog-menu"] .os-window-body {
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 640px;          /* titlebar hidden below; body fills the full 640px window (2026-10-15 follow-up) */
    border-radius: var(--radius-dropdown);  /* replaces the now-hidden titlebar's top-corner rounding, keeping clean rounded dropdown corners */
    flex: 1 1 auto;
  }

  /* AI:
       what: Hide the titlebar on the desktop anchored catalog-dropdown (chromeless panel).
       why:  User found the title redundant after PRD-25's traffic-light removal.
       ref:  user request 2026-10-15; PRD-25 §Scope */
  .os-window.is-anchored[data-window-type="catalog-menu"] .os-window-titlebar {
    display: none;
  }

  .os-window.is-anchored[data-window-type="catalog-menu"] .os-window-controls {
    display: none;
  }
}

.screenshot-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 0;
}
.screenshot-viewer__img {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  border: 0;
  background: var(--surface);  /* dark loading surface matching theme */
}
.screenshot-viewer__footer {
  flex: 0 0 auto;
  padding: 0.5rem 0.9rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  font-size: var(--fs-footnote);
}
.screenshot-viewer__link {
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}
.screenshot-viewer__link:hover,
.screenshot-viewer__link:focus-visible { text-decoration: underline; }

@media (min-width: 768px) {
  /* Screenshot windows: smaller-pinned-to-readable size on desktop. */
  .os-window[data-window-type="screenshot"] {
    width: 800px;
    max-width: 95%;
    max-height: 80vh;
  }
  .os-window[data-window-type="screenshot"] .os-window-body {
    max-height: none;
    height: 540px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
  }
  .screenshot-viewer { flex: 1 1 auto; }
}
