/* ==========================================================================
   yomiplush.dev/top — the apps briefing.

   Loaded after style.css, and only by top.html: this page is a deck, not a
   document. Every rule here is scoped to the deck, so the rest of the site
   keeps its own look.

   Sections: tokens · stage · chrome · scene panel · rail · cover · drawer ·
             list fallback (no JS) · motion · responsive
   ========================================================================== */

/* --- tokens --------------------------------------------------------------- */
.deck,
.cover,
.drawer {
  --d-bg: #05080d;
  --d-ink: #e6eef3;
  --d-dim: #8ba0ad;
  --d-amber: #ffb45e;
  --d-cyan: #6fd7ec;
  --d-red: #ff5b57;
  --d-green: #6ef2b0;
  --d-line: rgba(140, 170, 190, 0.22);
  --d-mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --d-sans: "Helvetica Neue", Inter, system-ui, "Hiragino Sans", "Noto Sans JP", sans-serif;
  --d-pad: clamp(16px, 3.2vw, 40px);
}

/* The deck owns the whole window on this page. */
html.has-deck,
html.has-deck body {
  height: 100%;
  background: #05080d;
  background-image: none;
}

html.has-deck body {
  color: var(--d-ink, #e6eef3);
  font-family: var(--d-sans);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
}

html.has-deck main { margin: 0; max-width: none; padding: 0; }

/* --- stage ---------------------------------------------------------------- */
#stage {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
}

#stage .vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 40%, transparent 34%, rgba(0, 0, 0, 0.62) 100%);
}

#stage .scan {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  mix-blend-mode: screen;
  background: repeating-linear-gradient(
    to bottom,
    rgba(120, 200, 255, 0.16) 0 1px,
    transparent 1px 3px
  );
}

/* Grain as a pair of hatching gradients: the CSP allows images from 'self'
   only, so a data: URI noise tile would be blocked (and log a violation) for
   the sake of four percent of texture. */
#stage .grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.03;
  background-image:
    repeating-linear-gradient(45deg, #fff 0 1px, transparent 1px 3px),
    repeating-linear-gradient(-45deg, #fff 0 1px, transparent 1px 4px);
}

/* --- chrome --------------------------------------------------------------- */
.deck {
  position: relative;
  z-index: 2;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: calc(var(--d-pad) + env(safe-area-inset-top)) var(--d-pad)
    calc(var(--d-pad) + env(safe-area-inset-bottom));
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 28px;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tag {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--d-amber);
  border: 1px solid rgba(255, 180, 94, 0.45);
  padding: 4px 8px;
  border-radius: 2px;
  background: rgba(255, 180, 94, 0.07);
}

.sep { width: 22px; height: 1px; background: var(--d-line); }

.chapter {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--d-dim);
  white-space: nowrap;
}

.chip {
  font-family: var(--d-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--d-dim);
  border: 1px solid var(--d-line);
  background: rgba(8, 15, 22, 0.55);
  padding: 6px 9px;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.chip:hover,
.chip:focus-visible {
  color: var(--d-ink);
  border-color: rgba(255, 255, 255, 0.42);
  outline: none;
}

.chip[aria-pressed="true"] {
  color: var(--d-amber);
  border-color: rgba(255, 180, 94, 0.5);
}

/* The lofi chip: a small equaliser next to LIST and INDEX. Enter starts the
   loop; the chip itself is the pointer/touch way in and out. */
.lofi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.lofi-chip .lofi-eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 10px;
}

.lofi-chip .lofi-eq i {
  display: block;
  width: 2px;
  height: 4px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.5;
  transform-origin: bottom;
}

.lofi-chip[data-playing="true"] .lofi-eq i {
  opacity: 1;
  animation: lofi-eq 0.9s ease-in-out infinite;
}

.lofi-chip[data-playing="true"] .lofi-eq i:nth-child(2) { animation-delay: -0.35s; }
.lofi-chip[data-playing="true"] .lofi-eq i:nth-child(3) { animation-delay: -0.6s; }
.lofi-chip[data-playing="true"] .lofi-eq i:nth-child(4) { animation-delay: -0.15s; }

@keyframes lofi-eq {
  0%, 100% { transform: scaleY(0.45); }
  50%      { transform: scaleY(1.8); }
}

/* --- scene panel ---------------------------------------------------------- */
.deck-body {
  position: relative;
  min-height: 0;
  display: flex;
  align-items: flex-end;
}

.scene {
  display: none;
  width: min(58ch, 92vw);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-left: 14px;
  border-left: 2px solid var(--d-amber);
  margin-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 170, 190, 0.35) transparent;
}

.scene::-webkit-scrollbar { width: 6px; }
.scene::-webkit-scrollbar-thumb {
  background: rgba(140, 170, 190, 0.32);
  border-radius: 3px;
}

.scene.active { display: block; }

.kicker {
  font-family: var(--d-mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  color: var(--d-amber);
  margin: 0 0 6px;
}

.stamp {
  font-family: var(--d-mono);
  font-size: clamp(30px, 6vw, 54px);
  line-height: 0.95;
  margin: 0;
  color: rgba(230, 238, 243, 0.14);
  letter-spacing: -0.02em;
  font-weight: 700;
  white-space: nowrap;
}

.scene h1 {
  font-size: clamp(24px, 4.6vw, 44px);
  line-height: 1.14;
  margin: 0.1em 0 0.5em;
  letter-spacing: -0.01em;
  font-weight: 800;
  text-wrap: balance;
  color: var(--d-ink);
}

.lede {
  margin: 0 0 0.7em;
  color: #c8d6e2;
  font-size: clamp(13px, 1.6vw, 16px);
  line-height: 1.75;
  max-width: 52ch;
}

.points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.points li {
  position: relative;
  padding-left: 16px;
  font-size: clamp(12px, 1.45vw, 14.5px);
  line-height: 1.6;
  color: #a9bac8;
  font-family: var(--d-mono);
}

.points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 1px;
  background: var(--d-cyan);
  opacity: 0.8;
}

.points b { color: var(--d-ink); font-weight: 600; }
.points em { color: var(--d-amber); font-style: normal; }
.points a { color: var(--d-cyan); text-decoration: none; border-bottom: 1px solid rgba(111, 215, 236, 0.35); }
.points a:hover { border-bottom-color: var(--d-cyan); }

/* the Japanese name sits beside the English one, quietly */
.scene h1 .ja {
  font-size: 0.56em;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--d-cyan);
  white-space: nowrap;
}

.metric {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 14px 0 0;
  font-family: var(--d-mono);
}

.metric-val {
  font-size: clamp(26px, 4.4vw, 40px);
  font-weight: 800;
  color: var(--d-amber);
  line-height: 1;
}

.metric-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--d-dim);
  text-transform: uppercase;
}

/* the last scene carries the actual store links */
.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}

.store {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 2.75rem;
  padding: 10px 16px;
  border-radius: 2px;
  border: 1px solid var(--d-amber);
  background: var(--d-amber);
  color: #0a0d12;
  font-family: var(--d-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s, transform 0.18s;
}

.store:hover { background: #ffc884; transform: translateY(-1px); }
.store .arrow { transition: transform 0.18s; }
.store:hover .arrow { transform: translate(2px, -1px); }

.store.ghost {
  background: transparent;
  border-color: var(--d-line);
  color: var(--d-ink);
  font-weight: 500;
}

.store.ghost:hover { border-color: var(--d-cyan); background: rgba(111, 215, 236, 0.06); }

/* --- footer --------------------------------------------------------------- */
.hud-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.rail { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

.tick {
  width: 16px;
  height: 3px;
  padding: 0;
  border: 0;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.16);
  cursor: pointer;
  transition: width 0.2s, background 0.2s;
}

.tick[aria-current="true"] { background: var(--d-amber); width: 26px; }
.tick:hover { background: rgba(255, 255, 255, 0.45); }

.nav { display: flex; gap: 8px; align-items: center; }

.navbtn {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--d-dim);
  border: 1px solid var(--d-line);
  background: rgba(8, 15, 22, 0.6);
  padding: 9px 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: color 0.18s, border-color 0.18s;
}

.navbtn:hover { color: var(--d-ink); border-color: rgba(255, 255, 255, 0.42); }
.navbtn:disabled { opacity: 0.35; cursor: default; }

.navbtn.primary {
  color: #0a0d12;
  background: var(--d-amber);
  border-color: var(--d-amber);
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.navbtn.primary:hover { background: #ffc884; }

.next-arrow { font-size: 14px; animation: nudge 1.6s ease-in-out infinite; }

@keyframes nudge {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}

.hint {
  font-family: var(--d-mono);
  font-size: 10px;
  color: rgba(139, 160, 173, 0.8);
  margin: 0;
  letter-spacing: 0.1em;
}

/* --- cover ---------------------------------------------------------------- */
.cover {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  background: radial-gradient(80% 60% at 50% 45%, rgba(8, 14, 22, 0.72), rgba(4, 6, 10, 0.96));
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  transition: opacity 0.5s ease, visibility 0.5s;
}

html.has-deck .cover { display: grid; }
html.has-deck .cover.hidden { opacity: 0; visibility: hidden; }

.cover-inner {
  position: relative;
  max-width: min(680px, 90vw);
  padding: 26px;
  text-align: center;
  border: 1px solid rgba(255, 180, 94, 0.22);
  background: linear-gradient(180deg, rgba(255, 180, 94, 0.05), transparent 60%);
}

.cover-inner::before,
.cover-inner::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 1px solid var(--d-amber);
}

.cover-inner::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.cover-inner::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.cover-kicker {
  font-family: var(--d-mono);
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--d-amber);
  margin: 0 0 14px;
}

.cover-title {
  font-size: clamp(30px, 7vw, 60px);
  line-height: 0.98;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  font-weight: 900;
  color: var(--d-ink);
}

.cover-title em {
  font-style: normal;
  color: transparent;
  -webkit-text-stroke: 1px rgba(230, 238, 243, 0.55);
}

.cover-sub {
  color: #b6c6d4;
  font-size: clamp(13px, 1.6vw, 15px);
  line-height: 1.85;
  margin: 0 0 22px;
}

.start {
  font-family: var(--d-mono);
  font-size: 13px;
  letter-spacing: 0.2em;
  font-weight: 700;
  color: #0a0d12;
  background: var(--d-amber);
  padding: 14px 26px;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.18s, transform 0.18s;
}

.start:hover { background: #ffc884; transform: translateY(-1px); }
.start:focus-visible { outline: 2px solid var(--d-cyan); outline-offset: 3px; }

.cover-foot {
  font-family: var(--d-mono);
  font-size: 10px;
  color: var(--d-dim);
  margin: 18px 0 0;
  letter-spacing: 0.06em;
}

/* --- drawer --------------------------------------------------------------- */
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(440px, 92vw);
  padding: 22px;
  background: #080d14;
  border-left: 1px solid var(--d-line);
  overflow: auto;
  transform: translateX(102%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.open { transform: none; }

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.drawer-head h2 {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--d-amber);
  margin: 0;
}

.drawer ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.drawer ol a {
  display: block;
  padding: 9px 10px;
  border-bottom: 1px dotted rgba(140, 170, 190, 0.16);
  color: #9fb2c1;
  font-family: var(--d-mono);
  font-size: 12px;
  text-decoration: none;
}
.drawer ol a:hover { color: var(--d-ink); background: rgba(255, 255, 255, 0.03); }
.drawer ol a b { color: var(--d-amber); font-weight: 500; margin-right: 10px; }

.drawer-foot {
  margin-top: 20px;
  font-family: var(--d-mono);
  font-size: 10.5px;
  line-height: 1.9;
  color: var(--d-dim);
}

.drawer-foot a { color: var(--d-cyan); }

/* --- scene text animation ------------------------------------------------- */
.scene.swap .kicker,
.scene.swap .stamp,
.scene.swap h1,
.scene.swap .lede,
.scene.swap .points,
.scene.swap .metric,
.scene.swap .links-row {
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.scene.swap .stamp { animation-delay: 0.02s; }
.scene.swap h1 { animation-delay: 0.06s; }
.scene.swap .lede { animation-delay: 0.12s; }
.scene.swap .points { animation-delay: 0.18s; }
.scene.swap .metric { animation-delay: 0.24s; }
.scene.swap .links-row { animation-delay: 0.28s; }

.scene.swap .points li {
  animation: rise 0.45s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.scene.swap .points li:nth-child(1) { animation-delay: 0.18s; }
.scene.swap .points li:nth-child(2) { animation-delay: 0.24s; }
.scene.swap .points li:nth-child(3) { animation-delay: 0.3s; }
.scene.swap .points li:nth-child(4) { animation-delay: 0.36s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* --- list fallback -------------------------------------------------------- */
/* No deck class (no JS), or the reader pressed LIST: the same copy as a plain
   document, in reading order, with the cover and the chrome out of the way. */
html:not(.has-deck) body { overflow: auto; }

html:not(.has-deck) #stage,
html:not(.has-deck) .cover,
html:not(.has-deck) .hud-bottom,
html:not(.has-deck) .hud-top .chip,
html:not(.has-deck) .drawer { display: none; }

html:not(.has-deck) .deck { height: auto; display: block; padding: 8vh 20px 64px; }
html:not(.has-deck) .deck-body { display: block; }
html:not(.has-deck) .hud-top { margin-bottom: 32px; }

html:not(.has-deck) .scene {
  display: block;
  width: min(680px, 100%);
  max-height: none;
  overflow: visible;
  margin: 0 auto 48px;
}

html:not(.has-deck) .scene h1 { font-size: clamp(22px, 5vw, 32px); }
html:not(.has-deck) .stamp { font-size: clamp(24px, 6vw, 40px); }

html.has-deck.list body { overflow: auto; }
html.has-deck.list #stage,
html.has-deck.list .cover,
html.has-deck.list .hud-bottom { display: none; }
html.has-deck.list .deck { height: auto; display: block; padding: 8vh 20px 64px; }
html.has-deck.list .deck-body { display: block; }
html.has-deck.list .scene {
  display: block;
  width: min(680px, 100%);
  max-height: none;
  overflow: visible;
  margin: 0 auto 48px;
}

/* --- static / reduced motion --------------------------------------------- */
body.still *,
body.still *::before,
body.still *::after {
  animation: none !important;
  transition: none !important;
}

body.still .cover { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .next-arrow { animation: none; }
  #stage .scan,
  #stage .grain { display: none; }
  .scene.swap *,
  .scene.swap .points li { animation-duration: 0.01ms !important; }
}

/* --- responsive ----------------------------------------------------------- */
@media (max-width: 720px) {
  .scene {
    width: 100%;
    margin-bottom: 4px;
    padding-left: 10px;
    padding-right: 2px;
  }

  .hint { display: none; }
  .rail { gap: 4px; }
  .tick { width: 11px; }
  .tick[aria-current="true"] { width: 20px; }
  .hud-bottom { gap: 10px; }
  .navbtn { padding: 11px 14px; }
  .stamp { font-size: clamp(22px, 7.5vw, 32px); }
  .scene h1 { font-size: clamp(21px, 6vw, 32px); margin: 0.05em 0 0.4em; line-height: 1.16; }
  .lede { font-size: 13px; line-height: 1.7; margin-bottom: 0.55em; }
  .points li { font-size: 12px; line-height: 1.55; padding-left: 14px; }
  .kicker { font-size: 9px; letter-spacing: 0.2em; }
  .metric { margin-top: 10px; }
  .metric-val { font-size: clamp(22px, 7vw, 32px); }
  .metric-label { font-size: 10px; }
  .separator-optional { display: none; }
}

@media (max-width: 480px) {
  .lofi-chip .lofi-label { display: none; }
}

/* landscape phones: keep the copy, shrink the type */
@media (max-height: 560px) {
  .scene h1 { font-size: clamp(18px, 4.2vw, 26px); margin-bottom: 0.3em; }
  .lede { font-size: 11.5px; line-height: 1.55; }
  .points { gap: 3px; }
  .points li { font-size: 10.5px; line-height: 1.45; }
  .stamp { font-size: clamp(16px, 4vw, 24px); }
  .metric { margin-top: 6px; }
  .metric-val { font-size: clamp(18px, 4vw, 26px); }
  .scene { margin-bottom: 2px; }
  .hud-bottom { margin-top: 8px; }
}
