/* Self-hosted fonts (latin subsets) — same-origin saves two cross-origin
   TLS handshakes plus the fonts CSS round-trip on the glasses' 150ms-RTT
   link. The upright Cormorant file is a variable font covering 500-700. */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url('fonts/cormorant-garamond.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/cormorant-garamond-italic.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/space-mono.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

html, body {
  margin: 0; padding: 0; background: #000;
}
body {
  width: 600px; height: 600px; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
/* No touch-action opt-in: `body { touch-action: none }` would switch the
   glasses into the continuous-drag input model, where a pinch becomes a
   pointer stream instead of Enter/click on the focused element — and
   activation dies. This app is D-pad + pinch-activate only. */
* { box-sizing: border-box; }

@keyframes balPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%       { transform: scale(1.6); opacity: .3; }
}
.balScroll::-webkit-scrollbar { width: 0; height: 0; }

/* ── Base ─────────────────────────────────────────────── */
#root {
  width: 600px; height: 600px; position: relative; overflow: hidden;
  background: #000; color: #fff;
  font-family: 'Cormorant Garamond', Georgia, serif;
  outline: none;
}

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: #000;
}
.screen.hidden { display: none; }

/* ── Loading ──────────────────────────────────────────── */
#screen-loading {
  align-items: center; justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 3px; color: #ffc463;
}

/* ── Hero ─────────────────────────────────────────────── */
#screen-hero { background: transparent; }

.hero-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  transform-origin: center;
  transition: transform .7s cubic-bezier(.22,.61,.36,1);
}

.hero-grad {
  position: absolute; inset: 0;
  background: linear-gradient(180deg,
    rgba(0,0,0,.72) 0%,
    rgba(0,0,0,.08) 26%,
    rgba(0,0,0,.2)  52%,
    rgba(0,0,0,.9)  100%);
}

.hero-layout {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
}

.hero-top-bar {
  padding: 22px 28px;
}

.hero-stage {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 3px;
  text-shadow: 0 1px 6px rgba(0,0,0,.7);
}

.hero-gps-row {
  display: flex; align-items: center; gap: 9px;
  margin-top: 9px;
  font-family: 'Space Mono', monospace;
  font-size: 18px; color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.7);
}

.hero-gps-row.hidden { display: none; }

.gps-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  animation: balPulse 1.7s ease-in-out infinite;
}

.btn-debug {
  align-self: flex-start;
  margin: 0 28px;
  padding: 8px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px;
  color: #ffc463; background: rgba(0,0,0,.45);
  border: 1px solid #ffc463; border-radius: 4px;
  cursor: pointer;
}
.btn-debug:focus {
  outline: none;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 24px rgba(255,196,99,.9);
  background: rgba(0,0,0,.7);
}
.btn-debug.hidden { display: none; }

#btn-enable-loc { margin-top: 8px; }

.hero-spacer { flex: 1; }

.hero-info { padding: 0 30px 6px; }

.hero-location {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px; color: #ffc463;
  margin-bottom: 10px;
  text-shadow: 0 1px 8px rgba(0,0,0,.7);
}
.hero-location.hidden { display: none; }

.hero-name {
  font-size: 54px; font-weight: 700;
  line-height: 0.94; letter-spacing: -0.7px;
  text-shadow: 0 2px 22px rgba(0,0,0,.6);
}

.hero-artist {
  font-style: italic; font-size: 25px; color: #ece3d3;
  margin-top: 6px;
  text-shadow: 0 1px 12px rgba(0,0,0,.6);
}

.hero-btns {
  display: flex; gap: 12px;
  padding: 16px 24px 22px;
}

/* ── Buttons ──────────────────────────────────────────── */
button {
  cursor: pointer;
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 1.5px;
  border-radius: 3px;
  /* Only compositor-friendly properties — `all` would animate layout/paint too */
  transition: background-color .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
  text-align: center;
}

.btn-ghost {
  flex: 1; min-height: 80px;
  color: #fff; background: rgba(0,0,0,.4);
  border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(3px);
}
.btn-ghost:focus {
  outline: none;
  border-color: #ffd98a;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 26px rgba(255,196,99,.7);
  background: rgba(255,196,99,.25);
}
.btn-listen {
  position: absolute;
  top: 22px; right: 24px;
  z-index: 10;
  min-height: 44px; min-width: 52px; padding: 0 14px;
  display: flex; align-items: center; justify-content: center;
  color: #ffc463;
  background: rgba(0,0,0,.55);
  border: 1px solid rgba(255,196,99,.5);
  backdrop-filter: blur(4px);
  font-size: 18px; letter-spacing: 1.5px;
}
.btn-listen svg { display: block; }

/* Top-right of the hero is reserved for the narration toggle */
#btn-speak-hero.hidden { display: none; }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  min-width: 56px; padding: 0 16px;
}
.btn-icon svg { display: block; }

.btn-glyph {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
}
.btn-listen:focus {
  outline: none;
  border-color: #ffc463;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 22px rgba(255,196,99,.8);
  background: rgba(0,0,0,.8);
}
.btn-listen.speaking {
  background: rgba(255,196,99,.15);
}

.btn-gold {
  flex: 2; min-height: 80px;
  color: #000; background: #ffc463;
  border: 1px solid #ffc463;
}
.btn-gold:focus {
  outline: none;
  /* Gold-on-gold ring would vanish — the focus ring here is white */
  box-shadow: 0 0 0 3px #fff, 0 0 30px rgba(255,196,99,.95);
  background: #ffd98a;
}

.btn-outline {
  min-height: 56px; padding: 0 18px;
  color: #fff; background: transparent;
  border: 1px solid rgba(255,255,255,.3);
}
.btn-outline:focus {
  outline: none;
  border-color: #ffd98a;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 26px rgba(255,196,99,.7);
  background: rgba(255,196,99,.18);
}

.btn-back {
  flex: 1; min-height: 80px;
  color: #fff; background: transparent;
  border: 1px solid rgba(255,255,255,.3);
}
.btn-back:focus {
  outline: none;
  border-color: #ffd98a;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 26px rgba(255,196,99,.7);
  background: rgba(255,196,99,.18);
}

/* ── Index ────────────────────────────────────────────── */
.idx-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 26px 16px;
  flex-shrink: 0;
}

.idx-title { font-size: 30px; font-weight: 600; line-height: 1; }

.idx-sub {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px; color: #9a9286;
  margin-top: 4px;
}

.idx-stack {
  flex: 1; overflow-y: auto;
  position: relative;
  padding-bottom: 24px;
}

/* Nearest work leads big; header + featured + carousel fill the 600px screen */
.idx-featured {
  display: block;
  width: 100%; height: 316px;
}

/* The main tile is always labeled (two classes to outrank the base
   .idx-tile-overlay opacity:0, which is declared later) */
.idx-featured .idx-tile-overlay { opacity: 1; }

.idx-featured-kicker {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px; color: #ffc463;
  margin-bottom: 4px;
}

.idx-featured-name {
  font-size: 30px;
  -webkit-line-clamp: 1;
  line-clamp: 1;
}

.idx-carousel {
  display: flex; gap: 3px;
  margin-top: 3px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.idx-carousel::-webkit-scrollbar { display: none; }

.idx-car-item {
  flex: 0 0 176px; height: 176px;
  scroll-snap-align: start;
}

/* Carousel tiles stay labeled too, sized down for the small tile */
.idx-car-item .idx-tile-overlay { opacity: 1; }
.idx-car-item .idx-tile-name { font-size: 18px; }

.idx-item {
  position: relative;
  padding: 0; border: none; border-radius: 0;
  background: #0a0a0a;
  overflow: hidden;
  cursor: pointer;
}
.idx-item:focus { outline: none; }
/* Ring drawn on ::after so it paints above the edge-to-edge photo */
.idx-item:focus::after {
  content: '';
  position: absolute; inset: 0;
  /* Bright ring with a dark separator so it reads on any photo */
  box-shadow: inset 0 0 0 5px #ffc463, inset 0 0 0 8px rgba(0,0,0,.75);
  pointer-events: none;
}

.idx-tile-img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
}

.idx-tile-overlay {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 30px 10px 9px;
  background: linear-gradient(transparent, rgba(0,0,0,.88));
  text-align: left;
  opacity: 0;
  transition: opacity .15s;
  pointer-events: none;
}
.idx-item:focus .idx-tile-overlay { opacity: 1; }

.idx-tile-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px; font-weight: 600; line-height: 1.1; color: #fff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.idx-tile-badge {
  position: absolute; top: 6px; right: 6px;
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: .5px; color: #ffc463;
  background: rgba(0,0,0,.62);
  padding: 3px 7px; border-radius: 2px;
  backdrop-filter: blur(2px);
  pointer-events: none;
}

/* ── Detail ───────────────────────────────────────────── */
.det-header { padding: 30px 30px 0; flex-shrink: 0; }

.det-meta {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2.5px; color: #ffc463;
}

.det-name {
  font-size: 46px; font-weight: 700;
  line-height: 0.98; letter-spacing: -0.4px;
  margin-top: 10px;
}

.det-artist {
  font-style: italic; font-size: 26px; color: #d9cdb8;
  margin-top: 5px;
}

.det-location {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 1px; color: #9a9286;
  margin-top: 13px;
}

.det-body {
  flex: 1; padding: 16px 30px 22px;
  min-height: 0; overflow-y: auto;
  font-size: 19px; line-height: 1.55; color: #cdbfa9;
  white-space: pre-line;
  scroll-behavior: smooth;
}
.det-body:focus {
  outline: none;
  box-shadow: inset 0 0 0 3px rgba(255,196,99,.9);
  border-radius: 3px;
}

.det-btns {
  display: flex; gap: 12px;
  padding: 14px 24px 22px; flex-shrink: 0;
}

/* ── Story (artwork + artist in one) ─────────────────── */
.story-btns {
  padding-top: 10px;
}

/* ── Language ─────────────────────────────────────────── */
.lang-list {
  flex: 1; overflow-y: auto;
  position: relative;
  padding: 4px 26px 22px;
}

.lang-item {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 62px; padding: 0 20px;
  margin-bottom: 10px;
  color: #fff; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.18);
  font-family: 'Cormorant Garamond', serif;
  font-size: 24px; letter-spacing: .5px;
  text-align: left;
}
.lang-item:focus {
  outline: none;
  border-color: #ffd98a;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 26px rgba(255,196,99,.7);
  background: rgba(255,196,99,.22);
}
.lang-item.active { border-color: rgba(255,196,99,.7); color: #ffc463; }

.lang-check {
  font-family: 'Space Mono', monospace;
  font-size: 18px; color: #ffc463;
}

.set-section {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px; color: #9a9286;
  text-transform: uppercase;
  margin: 14px 2px 10px;
}

.set-value {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 1px; color: #ffc463;
}

/* ── Welcome ──────────────────────────────────────────── */
.wel-card {
  flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 24px 28px 22px;
  position: relative;
}
/* Centered column of controls: the grids and buttons keep the card's
   full width so their own content centering reads as one aligned stack */
.wel-card .wel-langs,
.wel-card .wel-toggles,
.wel-card #btn-welcome-start { width: 100%; }

.wel-title { font-size: 42px; font-weight: 700; line-height: 1; }

.wel-sub {
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px; color: #ffc463;
  margin-top: 7px;
}

.wel-intro { font-size: 20px; color: #cdbfa9; margin-top: 8px; }

/* Flex, not grid: a partial last row (2 chips under a row of 4) centers
   under the rows above instead of hugging the left edge */
.wel-langs {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 8px;
}
.wel-chip { flex: 0 0 calc(25% - 6px); }

.wel-chip {
  min-height: 48px;
  color: #fff; background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.18);
  font-family: 'Cormorant Garamond', serif;
  font-size: 19px; letter-spacing: .3px;
}
.wel-chip:focus {
  outline: none;
  border-color: #ffd98a;
  box-shadow: 0 0 0 3px #ffd98a, 0 0 22px rgba(255,196,99,.7);
  background: rgba(255,196,99,.22);
}
.wel-chip.active { border-color: rgba(255,196,99,.7); color: #ffc463; }

.wel-toggles { margin-top: 16px; }
.wel-toggles .lang-item { min-height: 54px; margin-bottom: 8px; }

#btn-welcome-start { min-height: 64px; margin-top: 6px; flex: 0 0 auto; }

/* ── Back buttons (v127 input model) ──────────────────── */
/* On-screen back buttons exist for phones only: glasses use the thumb+
   middle-finger back gesture (Escape), and desktop-sized windows have
   the browser's own back. Hidden by default (which also drops them from
   the D-pad focus order), shown at phone widths. */
.det-btns .btn-back,
.story-btns,
[data-action="close-settings"] { display: none; }
@media (max-width: 520px) {
  html.mobile .det-btns .btn-back { display: block; }
  html.mobile .story-btns { display: flex; }
  html.mobile [data-action="close-settings"] { display: block; }
  html.mobile #story-body { padding-bottom: 14px; }
}

/* ── Offline pill ─────────────────────────────────────── */
.net-pill {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-family: 'Space Mono', monospace;
  font-size: 18px; letter-spacing: 2px;
  color: #ffc463;
  background: rgba(0,0,0,.6);
  border: 1px solid rgba(255,196,99,.5);
  border-radius: 999px;
  padding: 4px 12px;
  pointer-events: none;
}
.net-pill.hidden { display: none; }

/* ── Responsive (phones / desktop — html.mobile) ──────── */
/* Glasses keep the fixed 600x600 layout; other devices fill the viewport,
   capped at the design width and centered. */
html.mobile, html.mobile body {
  width: 100%; height: 100%;
}
html.mobile body {
  display: flex; justify-content: center;
}
html.mobile #root {
  width: 100%; max-width: 600px;
  height: 100dvh;
}
/* Root is capped at 600px on wide screens; scale the Loop tiles to narrow phones */
/* Keep the meta line clear of the narration button; at phone widths the
   distance stacks below the section instead of wrapping under the mic */
html.mobile .det-meta { padding-right: 64px; }
@media (max-width: 520px) {
  html.mobile .det-meta-sep { display: none; }
  html.mobile .det-meta-dist { display: block; margin-top: 3px; }
}
html.mobile .idx-featured { height: min(316px, 53vw); }
/* The Loop on phones: the nearest work leads near-square and the rest
   wrap into a 3-up grid instead of the glasses' horizontal carousel
   (which suits D-pad + pinch-drag, not thumbs). Width-gated so a
   desktop-sized window in mobile mode (e.g. 600x600 testing) keeps the
   carousel — only true phone widths get the grid. */
@media (max-width: 520px) {
  html.mobile .idx-featured { height: min(400px, 100vw); }
  html.mobile .idx-carousel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    overflow-x: visible;
  }
  html.mobile .idx-car-item {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
  }
}
html.mobile .hero-name { font-size: clamp(34px, 9vw, 54px); }
html.mobile .det-name  { font-size: clamp(32px, 8vw, 46px); }
html.mobile .wel-chip { flex: 1 1 120px; }
