/**
 * RoccOS Launcher — Accordion Layout
 * Flat list left with orb backdrop + detail view right.
 * Click a row to expand its app content inline (accordion).
 */

/* ── Hide chrome when launcher is active ── */
.desktop--launcher-active #taskbar,
.desktop--launcher-active #start-menu,
.desktop--launcher-active .start-btn,
.desktop--launcher-active .launcher-trigger,
.desktop--launcher-active #desktop-icons,
.desktop--launcher-active .greta {
  display: none !important;
}

.desktop--launcher-active .window-container {
  bottom: 0 !important;
}

/* Break out of the 16/10 diorama and fill viewport */
.desktop--launcher-active {
  aspect-ratio: unset !important;
  width: 100vw !important;
  height: 100vh !important;
  height: 100dvh !important;
  max-height: none !important;
  border-radius: 0 !important;
}

/* ═══════════════════════════════════════════
   COLOR WIPE — elastic SVG curtain
   ═══════════════════════════════════════════ */

.launcher-color-wipe {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ═══════════════════════════════════════════
   PROOF TICKER — real metrics flashed over the wipe
   Pinned low-center where the rising ink is fullest. Sits just above the
   wipe SVG (z 0) but below interactive content. Hidden by default; .is-visible
   is toggled by launcher.js while a row opens. Text colour follows the
   wipe-tone contrast handling so it reads on both dark and light wipes.
   ═══════════════════════════════════════════ */

.launcher-proof-ticker {
  position: fixed;
  left: 50%;
  bottom: clamp(var(--sp-5), 7vh, var(--sp-8));
  transform: translateX(-50%);
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  max-width: min(92vw, 760px);
  padding: var(--sp-2) var(--sp-4);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Hidden from layout until shown — keeps it out of the way pre-wipe. */
  visibility: hidden;
}

.launcher-proof-ticker.is-visible {
  visibility: visible;
}

.launcher-proof-ticker-line {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  /* Light-wipe default: muted ink. */
  color: var(--os-text-muted);
}

.launcher-proof-seg {
  white-space: nowrap;
}

.launcher-proof-sep {
  margin: 0 0.6em;
  opacity: 0.55;
}

/* Adaptive contrast over a dark wipe. */
.launcher[data-wipe-tone="dark"] .launcher-proof-ticker-line {
  color: rgba(240, 238, 237, 0.78);
}

@media (max-width: 768px) {
  .launcher-proof-ticker {
    max-width: 94vw;
  }
  .launcher-proof-ticker-line {
    /* Slightly smaller separators keep the single line from wrapping on phones. */
    letter-spacing: 0.05em;
  }
}

/* Reduced motion: no slide — visibility/opacity flip only (JS sets opacity:1
   inline via the class path; ensure a non-animated baseline here too). */
@media (prefers-reduced-motion: reduce) {
  .launcher-proof-ticker.is-visible {
    opacity: 1;
    transform: translateX(-50%);
  }
}

/* ── Launcher Shell ── */
.launcher {
  position: absolute;
  inset: 0;
  z-index: var(--z-desktop-icons);
  pointer-events: auto;
  overflow-y: auto;
  overflow-x: hidden;
}

.launcher-home {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: var(--sp-8) clamp(var(--sp-6), 12vw, 20vw);
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════
   POLKADOTS — retro 70s color pops
   ═══════════════════════════════════════════ */

.polkadot-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.polkadot {
  position: absolute;
  transform: translate(-50%, -50%) rotate(var(--dot-rotation, 0deg));
  pointer-events: none;
  z-index: 0;
  opacity: 1;
}

.polkadot--circle {
  border-radius: 50%;
}

.polkadot--sticker {
  border-radius: 6px;
}

.polkadot--sticker img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Pop-in animation for click-spawned dots */
.polkadot--pop {
  animation: polkadot-pop 300ms ease-out both;
}

@keyframes polkadot-pop {
  0% {
    transform: translate(-50%, -50%) rotate(var(--dot-rotation, 0deg)) scale(0);
    opacity: 0;
  }
  60% {
    transform: translate(-50%, -50%) rotate(var(--dot-rotation, 0deg)) scale(1.15);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) rotate(var(--dot-rotation, 0deg)) scale(1);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════
   APP LIST
   ═══════════════════════════════════════════ */

.launcher-app-list {
  display: flex;
  flex-direction: column;
  z-index: 1;
}

/* Infinite scroll: canonical + 2 clones */
.launcher-canonical,
.launcher-clone {
  display: flex;
  flex-direction: column;
}

/* ── Rows ── */
.launcher-row {
  display: grid;
  grid-template-columns: minmax(200px, 35%) 1fr;
  background: none;
  border: none;
  border-bottom: 1px solid var(--os-border-subtle);
  transition: border-bottom-color 1s ease-out;
  text-align: left;
  width: 100%;
  font-family: inherit;
  position: relative;
}

/* Collapsed: header spans full width, panel hidden */
.launcher-row:not(.launcher-row--expanded) {
  grid-template-columns: 1fr;
}

.launcher-canonical > .launcher-row:first-child,
.launcher-clone > .launcher-row:first-child {
  border-top: none;
}

/* The clickable header strip */
.launcher-row-header {
  display: grid;
  grid-template-columns: 40px 1fr 24px;
  align-items: center;
  padding: var(--sp-4) var(--sp-2);
  cursor: var(--cur-hand); --crt-cursor: hand;
  opacity: 0.4;
  transition: opacity 0.15s ease-out;
}

/* ── Two-tier reading-path emphasis ──
   Substance (Selected Work) rests slightly brighter than Play (Playground)
   so the eye lands on real work first. Declared BEFORE :hover / --expanded so
   those win at equal specificity.

   Raised idle floor: the fisheye magnification only fires on mousemove, so
   keyboard, screen-reader, and ALL touch users would otherwise read a flat,
   dim list. The baseline is lifted (was 0.62 / 0.40) while the two-tier gap is
   preserved. These values MUST stay in sync with BAND_FLOOR in launcher.js —
   the JS lerps opacity UP from this same floor. */
.launcher-row[data-band="substance"] .launcher-row-header {
  opacity: 0.72; /* TIER 1 — substance (work/info) */
}
.launcher-row[data-band="play"] .launcher-row-header {
  opacity: 0.62; /* TIER 2 — play (creative/games/extras/companion) */
}

.launcher-row:hover .launcher-row-header,
/* Keyboard focus brightens the row to full opacity BEFORE the JS scale lands,
   so the focused row is unambiguous even if GSAP/JS hasn't run yet. Mirrors
   :hover. :focus-within catches focus on the header (role=button) or anything
   inside an expanded panel. */
.launcher-row:focus-within .launcher-row-header {
  opacity: 1;
}

.launcher-row--expanded .launcher-row-header {
  opacity: 1;
  align-self: start;
  padding-top: var(--sp-6);
}

.launcher-row-header:focus-visible {
  outline: 1px solid var(--os-text-muted);
  outline-offset: -1px;
}

.launcher-cell--index {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--os-text-muted);
  transition: color 1s ease-out;
}

.launcher-cell--name {
  font-family: var(--font-serif);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  color: var(--os-text);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  transition: transform 0.08s ease-out, color 1s ease-out;
  display: inline-block;
  transform-origin: left 45%;
  will-change: transform;
}

/* ── Adaptive text for dark wipe backgrounds ── */
.launcher[data-wipe-tone="dark"] .launcher-cell--name {
  color: #F0EEED;
}

.launcher[data-wipe-tone="dark"] .launcher-cell--index {
  color: rgba(240, 238, 237, 0.6);
}

.launcher[data-wipe-tone="dark"] .launcher-row {
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.launcher-hint {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 0.55em;
  opacity: 0.7;
  white-space: nowrap;
  margin-left: 1rem;
  letter-spacing: 0.02em;
  text-transform: none;
}

/* ── Reading-path section labels ── */
/* Presentational only — aria-hidden, not in tab order. Mono small-caps
   divider printed once at each band boundary (Selected Work → Playground). */
.launcher-section-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--os-text-muted);
  padding: var(--sp-6) var(--sp-2) var(--sp-2);
  user-select: none;
  pointer-events: none;
}

/* Dark-wipe override — keep the label legible over a flooded wipe */
.launcher[data-wipe-tone="dark"] .launcher-section-label {
  color: rgba(240, 238, 237, 0.7);
}

.launcher-cell--status {
  display: flex;
  justify-content: center;
  align-items: center;
}

.launcher-dot {
  display: none; /* dots hidden in editorial layout — kept for future use */
}

/* ── Expand affordance chevron ──
   Fills the formerly-empty status gutter. Reflects aria-expanded: rests
   pointing down (collapse target), rotates to point up when the row is
   expanded. Decorative (the role=button + aria-expanded already announce
   state), so it carries aria-hidden. */
.launcher-chevron {
  color: var(--os-text-muted);
  opacity: 0.5;
  transition: transform 0.2s ease-out, opacity 0.15s ease-out, color 1s ease-out;
  transform-origin: center;
}

.launcher-row-header:hover .launcher-chevron,
.launcher-row-header:focus-visible .launcher-chevron,
.launcher-row:hover .launcher-chevron,
.launcher-row:focus-within .launcher-chevron {
  opacity: 0.85;
}

.launcher-row-header[aria-expanded="true"] .launcher-chevron {
  transform: rotate(180deg);
  opacity: 0.85;
}

.launcher[data-wipe-tone="dark"] .launcher-chevron {
  color: rgba(240, 238, 237, 0.6);
}

@media (prefers-reduced-motion: reduce) {
  .launcher-chevron {
    transition: opacity 0.15s ease-out, color 1s ease-out;
  }
}

/* ═══════════════════════════════════════════
   ACCORDION PANEL — expands below the header
   Two-column: title left, app content right
   ═══════════════════════════════════════════ */

.launcher-panel {
  overflow: hidden;
  height: 0;
  opacity: 0;
  /* Collapsed: remove from flow */
  grid-column: 1 / -1;
}

.launcher-row--expanded .launcher-panel {
  /* Expanded: sit in the right column */
  grid-column: 2;
  grid-row: 1;
}

.launcher-panel-content {
  padding: var(--sp-4) 0;
}

/* ═══════════════════════════════════════════
   MOBILE — single responsive accordion
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Touch UX (migrated from mobile.css) */
  *, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
  }

  /* Hide characters on phones (migrated from mobile.css) */
  .greta, .greta-menu {
    display: none !important;
  }

  .launcher-home {
    padding: var(--sp-3);
  }

  /* Finite list — hide infinite scroll clones */
  .launcher-clone {
    display: none;
  }

  /* Block layout — override grid so header + panel stack vertically */
  .launcher-row--expanded {
    display: block;
  }

  .launcher-row--expanded .launcher-row-header {
    position: static;
  }

  /* Panel fills below header, no max-height to avoid nested scrolling */
  .launcher-row--expanded .launcher-panel {
    grid-column: unset;
    grid-row: unset;
  }

  .launcher-panel-content {
    padding: var(--sp-4) var(--sp-3);
    max-height: none;
  }

  /* Touch-friendly hit targets (WCAG 2.5.5: 44px minimum). Rows rest at the
     raised idle floor so the IntersectionObserver-driven focal row (lifted to
     opacity 1 + scale) stands out against legible — not dim — neighbours. */
  .launcher-row-header {
    min-height: 48px;
    padding-block: var(--sp-3);
    opacity: 0.62;
    /* Ease the focal emphasis (opacity lift driven by the JS observer) */
    transition: opacity 0.25s ease-out;
  }

  /* Two-tier reading-path floor still applies on mobile — substance rests
     brighter than play, matching desktop. The JS observer lifts the centered
     row to full opacity on top of these. */
  .launcher-row[data-band="substance"] .launcher-row-header {
    opacity: 0.72;
  }
  .launcher-row[data-band="play"] .launcher-row-header {
    opacity: 0.62;
  }

  /* Section dividers — tighter rhythm on phones */
  .launcher-section-label {
    padding: var(--sp-4) var(--sp-3) var(--sp-2);
  }

  /* Mobile focal scale is driven by the IntersectionObserver (centered row).
     The JS skips scale under reduced motion; the rule below removes scale
     unconditionally for the reduced-motion path as a CSS-level guarantee. */
  .launcher-cell--name {
    will-change: auto;
    transition: transform 0.25s ease-out, color 1s ease-out;
  }

  .launcher-hint {
    display: none;
  }
}

/* Reduced motion + mobile: focal emphasis is opacity-only. The JS observer
   already withholds scale, but this guarantees no transform sneaks in and
   kills the per-row transition so the opacity lift is instant. Scoped to the
   mobile breakpoint so desktop magnification is untouched. */
@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
  .launcher-cell--name {
    transform: none !important;
    transition: color 1s ease-out;
  }
}
