/* =========================================================
   Manav Jain — Mono
   Quiet sidebar, loud stage. One dither engine, three themes.
   ========================================================= */

:root {
  --side-w: clamp(320px, 27vw, 400px);
  --pad: clamp(16px, 1.6vw, 24px);

  --sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
  --mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);
  --d-micro: 150ms;
  --d-small: 250ms;
  --d-med: 400ms;
}

/* ---------- themes ---------- */
:root,
[data-theme="dark"] {
  --bg:      oklch(0.155 0.003 270);
  --bg-2:    oklch(0.195 0.004 270);
  --bg-3:    oklch(0.235 0.005 270);
  --tx:      oklch(0.955 0.003 270);
  --tx-2:    oklch(0.72 0.006 270);
  --tx-3:    oklch(0.56 0.006 270);
  --line:    oklch(0.955 0 0 / 0.08);
  --line-2:  oklch(0.955 0 0 / 0.14);
  --accent:  oklch(0.70 0.17 35);
  /* canvas reads these as plain colours */
  --fx:       #ececf0;
  --thumb-bg: #1d1d21;
  --thumb-fg: #d8d8de;
  --thumb-ac: #e2694a;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg:      oklch(0.975 0.004 85);
  --bg-2:    oklch(0.945 0.005 85);
  --bg-3:    oklch(0.91 0.006 85);
  --tx:      oklch(0.2 0.006 270);
  --tx-2:    oklch(0.42 0.008 270);
  --tx-3:    oklch(0.55 0.008 270);
  --line:    oklch(0.2 0 0 / 0.09);
  --line-2:  oklch(0.2 0 0 / 0.16);
  --accent:  oklch(0.58 0.18 35);
  --fx:       #1b1b1f;
  --thumb-bg: #ebe8e2;
  --thumb-fg: #26262b;
  --thumb-ac: #c9472a;
  color-scheme: light;
}
[data-theme="phosphor"] {
  --bg:      oklch(0.14 0.02 150);
  --bg-2:    oklch(0.18 0.03 150);
  --bg-3:    oklch(0.22 0.04 150);
  --tx:      oklch(0.88 0.19 145);
  --tx-2:    oklch(0.72 0.15 145);
  --tx-3:    oklch(0.56 0.11 145);
  --line:    oklch(0.88 0.19 145 / 0.12);
  --line-2:  oklch(0.88 0.19 145 / 0.22);
  --accent:  oklch(0.86 0.17 95);
  --fx:       #6dfb8a;
  --thumb-bg: #0c1f12;
  --thumb-fg: #5ee87c;
  --thumb-ac: #e8e26a;
  color-scheme: dark;
}
[data-theme="phosphor"] body { text-shadow: 0 0 6px oklch(0.88 0.19 145 / 0.35); }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--tx);
  font-family: var(--sans); font-size: 15px; line-height: 1.5; letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--d-med) var(--ease), color var(--d-med) var(--ease);
}
ul, ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
kbd { font-family: var(--mono); font-size: 11px; }
::selection { background: var(--tx); color: var(--bg); }
:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip {
  position: fixed; top: 8px; left: 8px; z-index: 100; padding: 8px 12px; border-radius: 6px;
  background: var(--tx); color: var(--bg); font-family: var(--mono); font-size: 12px;
  transform: translateY(-200%); transition: transform var(--d-small) var(--ease);
}
.skip:focus { transform: none; }

.eyebrow {
  font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--tx-3); margin-bottom: 14px;
}

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100svh; }

/* ---------- sidebar ---------- */
.side {
  position: sticky; top: 0; height: 100svh; overflow-y: auto; overscroll-behavior: contain;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
.side__top {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px var(--pad) 18px; background: var(--bg);
  transition: background-color var(--d-med) var(--ease);
}
.side__name { font-family: var(--mono); font-size: 15px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.01em; }
.theme { font-family: var(--mono); font-size: 12px; text-transform: uppercase; color: var(--tx-3); padding: 4px 0; }
.theme__v { color: var(--tx); margin-left: 6px; }
@media (hover: hover) { .theme:hover .theme__v { color: var(--accent); } }

.side__block { padding: 0 var(--pad); margin-top: 44px; }
.side__about { margin-top: 56px; }
.about { color: var(--tx-2); text-wrap: pretty; }
.links { margin-top: 10px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.01em; color: var(--tx-3); }
.links a { color: var(--tx); transition: color var(--d-micro); }
@media (hover: hover) { .links a:hover { color: var(--accent); } }

/* system items */
.items { display: flex; flex-direction: column; gap: 4px; margin: 0 calc(var(--pad) * -0.5); }
.item {
  display: grid; grid-template-columns: 56px 1fr; gap: 14px; align-items: start;
  padding: 10px calc(var(--pad) * 0.5); border-radius: 10px; position: relative;
  transition: background-color var(--d-small) var(--ease);
}
.item__thumb {
  width: 56px; height: 56px; border-radius: 9px; display: block;
  image-rendering: pixelated; box-shadow: inset 0 0 0 1px var(--line);
  transition: transform var(--d-med) var(--ease);
}
.item__head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.item__t { font-family: var(--mono); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.01em; }
.pill {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 99px; background: var(--bg-3); color: var(--tx-2);
}
.item__d {
  margin-top: 4px; color: var(--tx-3); font-size: 13.5px; line-height: 1.38;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color var(--d-small) var(--ease);
}
.item[aria-current="true"] { background: var(--bg-2); }
.item[aria-current="true"]::before {
  content: ""; position: absolute; left: -1px; top: 18px; width: 2px; height: 22px; border-radius: 2px; background: var(--accent);
}
.item[aria-current="true"] .item__d { color: var(--tx-2); }
@media (hover: hover) {
  .item:hover { background: var(--bg-2); }
  .item:hover .item__d { color: var(--tx-2); }
  .item:hover .item__thumb { transform: scale(1.04); }
}

/* log */
.log li {
  display: grid; grid-template-columns: 84px 1fr; gap: 2px 12px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 13.5px;
}
.log li:last-child { border-bottom: 1px solid var(--line); }
.log__y { grid-row: span 2; font-family: var(--mono); font-size: 11.5px; color: var(--tx-3); padding-top: 2px; font-variant-numeric: tabular-nums; }
.log__w { color: var(--tx); }
.log__r { color: var(--tx-3); }

.pub { display: block; padding: 12px 14px; border-radius: 10px; background: var(--bg-2); transition: background-color var(--d-small) var(--ease); }
.pub__t { display: block; font-size: 13.5px; text-wrap: balance; }
.pub__m { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11.5px; color: var(--tx-3); text-transform: uppercase; }
@media (hover: hover) { .pub:hover { background: var(--bg-3); } }

.side__foot {
  position: sticky; bottom: 0; margin-top: auto; padding: 32px 8px 8px;
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}
.kbar {
  width: 100%; display: flex; justify-content: center; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px; background: var(--bg-2);
  font-family: var(--mono); font-size: 13px; color: var(--tx);
  transition: background-color var(--d-small) var(--ease);
}
.kbar kbd { color: var(--tx-3); padding: 1px 6px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-2); }
@media (hover: hover) { .kbar:hover { background: var(--bg-3); } }

/* ---------- stage ---------- */
.stage { position: relative; min-height: 100svh; overflow: hidden; isolation: isolate; }
.fx { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
.view { position: relative; z-index: 1; min-height: 100svh; }
.view[hidden] { display: none; }

.home {
  min-height: 100svh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px clamp(24px, 6vw, 96px) 120px; text-align: center;
}
.home__statement {
  width: min(100%, 15.5em);
  font-size: clamp(30px, 3.9vw, 60px); font-weight: 500; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance;
}
.caption { margin-top: 28px; font-family: var(--mono); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--tx-3); }
.hint {
  position: absolute; left: 0; right: 0; bottom: 22px; text-align: center;
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; color: var(--tx-3);
}
.hint__touch { display: none; }
@media (hover: none) { .hint__desk { display: none; } .hint__touch { display: inline; } }

/* fx on: the canvas draws the words, the DOM keeps them for readers */
.fx-on .home__statement { color: transparent; }
.fx-on .home__statement::selection { color: var(--bg); }

.detail {
  width: min(100% - 48px, 620px); margin: 0 auto;
  padding: clamp(72px, 12vh, 140px) 0 120px;
}
.detail__slot { display: none; }
.fx-on .detail__slot { display: block; height: clamp(150px, 26vh, 250px); }
.detail__metric {
  font-size: clamp(88px, 12vw, 190px); font-weight: 600; line-height: 0.9; letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}
.fx-on .detail__metric {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.detail__meta { margin-top: 28px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--tx-3); }
.detail__title { margin-top: 10px; font-size: clamp(26px, 2.6vw, 38px); font-weight: 500; letter-spacing: -0.03em; line-height: 1.1; }
.detail__unit { margin-top: 6px; color: var(--accent); font-family: var(--mono); font-size: 13px; text-transform: uppercase; letter-spacing: 0.02em; }
.detail__facts { margin-top: 26px; border-top: 1px solid var(--line); }
.detail__facts li {
  position: relative; padding: 12px 0 12px 22px; border-bottom: 1px solid var(--line);
  color: var(--tx-2); text-wrap: pretty;
}
.detail__facts li::before { content: "—"; position: absolute; left: 0; color: var(--tx-3); }
.detail__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 20px; }
.detail__tags li { font-family: var(--mono); font-size: 11px; text-transform: uppercase; padding: 4px 9px; border-radius: 99px; box-shadow: inset 0 0 0 1px var(--line-2); color: var(--tx-2); }
.detail__link:empty { display: none; }
.detail__link { margin-top: 18px; font-family: var(--mono); font-size: 12px; text-transform: uppercase; }
.detail__link a { border-bottom: 1px solid var(--line-2); padding-bottom: 2px; transition: color var(--d-micro), border-color var(--d-micro); }
@media (hover: hover) { .detail__link a:hover { color: var(--accent); border-color: var(--accent); } }

.pager {
  display: flex; justify-content: space-between; align-items: center; margin-top: 44px;
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; color: var(--tx-3);
}
.pager a { color: var(--tx); padding: 6px 0; transition: color var(--d-micro); }
.pager a[aria-disabled="true"] { opacity: 0.3; pointer-events: none; }
.pager__n { font-variant-numeric: tabular-nums; }
@media (hover: hover) { .pager a:hover { color: var(--accent); } }

/* view transitions: only the stage panel moves; the canvas morphs itself */
.view { view-transition-name: panel; }
::view-transition-group(root) { animation: none; }
::view-transition-old(panel) { animation: vt-out 220ms var(--ease-io) both; }
::view-transition-new(panel) { animation: vt-in 420ms var(--ease) both; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-8px); filter: blur(3px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(14px); filter: blur(3px); } }
/* fallback crossfade */
.view.is-entering { animation: vt-in 420ms var(--ease) both; }


/* ---------- palette ---------- */
.palette {
  margin: 14vh auto auto; width: min(600px, calc(100% - 32px)); max-height: 70vh;
  border: 0; border-radius: 14px; padding: 0; overflow: hidden;
  background: var(--bg-2); color: var(--tx);
  box-shadow: 0 0 0 1px var(--line-2), 0 30px 80px -20px oklch(0 0 0 / 0.6);
}
.palette[open] { animation: pal-in 260ms var(--ease) both; display: flex; flex-direction: column; }
.palette::backdrop { background: oklch(0 0 0 / 0.45); backdrop-filter: blur(2px); }
@keyframes pal-in { from { opacity: 0; transform: translateY(-6px) scale(0.985); } }
.palette__form { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.palette__label { font-family: var(--mono); color: var(--accent); }
.palette__in { flex: 1; background: none; border: 0; outline: 0; color: var(--tx); font: 15px var(--sans); letter-spacing: -0.01em; }
.palette__in::placeholder { color: var(--tx-3); }
.palette__esc { color: var(--tx-3); padding: 1px 6px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--line-2); }
.palette__list { overflow-y: auto; padding: 6px; }
.palette__list li {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--tx-2); font-size: 14px;
}
.palette__list li small { font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--tx-3); }
.palette__list li[aria-selected="true"] { background: var(--bg-3); color: var(--tx); }
.palette__list .empty { color: var(--tx-3); cursor: default; font-family: var(--mono); font-size: 12px; }
.palette__out:empty { display: none; }
.palette__out { padding: 10px 18px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 12px; color: var(--accent); white-space: pre-wrap; }
.palette__foot { display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line); font-family: var(--mono); font-size: 11px; text-transform: uppercase; color: var(--tx-3); }

/* ---------- toast ---------- */
.toast {
  position: fixed; z-index: 60; top: 18px; left: 50%; transform: translateX(-50%);
  padding: 10px 14px; border-radius: 10px; background: var(--bg-2); color: var(--tx);
  box-shadow: inset 0 0 0 1px var(--line-2), 0 16px 40px -16px oklch(0 0 0 / 0.5);
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em;
  animation: toast-in 320ms var(--ease) both; transition: opacity var(--d-med) var(--ease), transform var(--d-med) var(--ease);
}
.toast.out { opacity: 0; transform: translate(-50%, -6px); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* ---------- mobile: stage first, sidebar becomes the page ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .stage { order: -1; min-height: 0; }
  .view, .home { min-height: 82svh; }
  .home { padding: 72px 24px 96px; }
  .detail { padding-top: 64px; padding-bottom: 72px; }
  .side { position: static; height: auto; overflow: visible; border-right: 0; border-top: 1px solid var(--line); }
  .side__top { position: fixed; left: 0; right: 0; top: 0; z-index: 30; padding: 14px 16px;
    background: color-mix(in oklch, var(--bg) 86%, transparent); backdrop-filter: blur(10px); }
  .side__about { margin-top: 36px; }
  .side__block { padding: 0 16px; }
  .side__foot { position: static; padding: 36px 16px 8px; background: none; }
  body { padding-bottom: 60px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
  ::view-transition-old(panel), ::view-transition-new(panel) { animation: none; }
}

/* ---------- "getting bored?" — the door to the CRT game ---------- */
.bored {
  position: absolute; top: 16px; right: var(--pad, 20px); z-index: 3;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px; border-radius: 99px;
  background: var(--bg-2); box-shadow: inset 0 0 0 1px var(--line-2, var(--line));
  font-family: var(--mono); font-size: 12px; text-transform: uppercase; letter-spacing: 0.02em; color: var(--tx-3);
  transition: background-color var(--d-small) var(--ease), color var(--d-small) var(--ease), box-shadow var(--d-small) var(--ease);
}
.bored__go {
  padding: 4px 10px; border-radius: 99px; background: var(--tx); color: var(--bg);
  transition: background-color var(--d-small) var(--ease);
}
/* an 8-bit coin, drawn with box-shadows on a 1px grid scaled up */
.bored__coin {
  width: 2px; height: 2px; margin: 0 7px 0 1px; flex: none; color: oklch(0.84 0.16 85);
  box-shadow:
    2px 0, 4px 0,
    0 2px, 2px 2px, 4px 2px, 6px 2px,
    0 4px, 2px 4px, 4px 4px, 6px 4px,
    0 6px, 2px 6px, 4px 6px, 6px 6px,
    2px 8px, 4px 8px;
  transform: translateY(-5px);
  animation: coin-spin 1.2s steps(4) infinite;
}
@keyframes coin-spin {
  0%, 100% { transform: translateY(-5px) scaleX(1); }
  25%      { transform: translateY(-5px) scaleX(0.55); }
  50%      { transform: translateY(-5px) scaleX(0.15); }
  75%      { transform: translateY(-5px) scaleX(0.55); }
}
@media (hover: hover) {
  .bored:hover { color: var(--tx); box-shadow: inset 0 0 0 1px var(--accent); }
  .bored:hover .bored__go { background: var(--accent); }
}
@media (max-width: 860px) {
  .bored { top: 64px; right: 12px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) { .bored__coin { animation: none; } }
