/* nhk-spotlight design system — phase 1.
   Palette 4 (plum + apricot on milk), Kufam for headings, Vazirmatn for text.
   Surfaces are raised; icons sit engraved inside them. Light theme is the default; dark mirrors it. */

:root {
  --bg: #F4EDE2;            /* milk */
  --sf: #FBF6EE;            /* raised surface */
  --ink: #221A2E;
  --mu: #6E6478;            /* muted text (contrast 5.1:1 on bg) */
  --pu: #5A2D82;            /* plum */
  --pu-2: #6E3D9E;
  --pu-d: #3F1D60;
  --or: #EE9A4D;            /* apricot — accents only, never body text */
  --or-ink: #C46F22;
  --pl: #EEE5F4;            /* lavender tile */
  --hi: #FFFDF8;            /* relief highlight */
  --sh: #DDD1C1;            /* relief shadow */
  --eg: #A99B89;            /* engraved icon */
  --kb1: #FFFDF9; --kb2: #F1E8DB; --kbl: #E2D6C6;   /* raised keys */
  --hero1: #6A3896; --hero2: #4A2270;
  --dk1: #2D2340; --dk2: #1D1629;
  --veil: rgba(244, 237, 226, .6);

  --f-head: 'Kufam', 'Vazirmatn', system-ui, sans-serif;
  --f-body: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --r-lg: 26px; --r-md: 18px; --r-sm: 14px;
  --gap: 18px;
  --pad: clamp(16px, 4vw, 40px);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #16111D; --sf: #201929; --ink: #F2EDF7; --mu: #A69CB4;
  --pu: #8B5CC4; --pu-2: #7A4AAE; --pu-d: #3A1B5C;
  --pl: #2A2039; --hi: #261E31; --sh: #0B080F; --eg: #7A6F8B;
  --kb1: #2A2234; --kb2: #1F1828; --kbl: #120E18;
  --hero1: #5B2F86; --hero2: #3A1B5C; --dk1: #0F0B15; --dk2: #0A070E;
  --veil: rgba(22, 17, 29, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  min-height: 100dvh; background: var(--bg); color: var(--ink);
  font: 400 16px/1.8 var(--f-body); -webkit-font-smoothing: antialiased;
  transition: background-color .4s ease, color .4s ease;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; display: block; }
:focus-visible { outline: 2.5px solid var(--or); outline-offset: 3px; }
h1, h2, h3, .head { font-family: var(--f-head); font-feature-settings: "liga" 0, "dlig" 0, "calt" 0; font-weight: 600; letter-spacing: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }

.wrap { max-width: 1120px; margin: 0 auto; padding: 22px var(--pad) 120px; }

/* ---------- relief primitives ---------- */
.raised { background: var(--sf); border-radius: var(--r-lg); box-shadow: 6px 6px 16px var(--sh), -6px -6px 16px var(--hi); }
.well {
  display: grid; place-items: center; flex: none;
  width: 46px; height: 46px; border-radius: 15px;
  background: var(--bg); color: var(--eg);
  box-shadow: inset 3px 3px 7px var(--sh), inset -3px -3px 7px var(--hi);
}
.well svg, .key svg { filter: drop-shadow(0 1px 0 var(--hi)) drop-shadow(0 -1px 0 rgba(0, 0, 0, .25)); }
.well.p { color: var(--pu); } .well.o { color: var(--or-ink); }
.key {
  display: grid; place-items: center; flex: none;
  background: linear-gradient(160deg, var(--kb1), var(--kb2));
  border: 1px solid var(--kbl);
  box-shadow: 0 4px 0 var(--kbl), 0 12px 18px -10px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .55);
  color: var(--eg);
  transition: transform .15s ease, box-shadow .15s ease;
}
:root[data-theme="dark"] .key { box-shadow: 0 4px 0 var(--kbl), 0 12px 18px -10px #000, inset 0 1px 0 rgba(255, 255, 255, .06); }
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--kbl), 0 4px 8px -6px rgba(0, 0, 0, .35); }
/* colored tiles: engraved well becomes a darker dent */
.on-color .well { background: rgba(0, 0, 0, .16); color: rgba(255, 255, 255, .9); box-shadow: inset 2px 2px 5px rgba(0, 0, 0, .3), inset -2px -2px 5px rgba(255, 255, 255, .12); }
.on-color .well svg { filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .35)) drop-shadow(0 1px 0 rgba(255, 255, 255, .18)); }

/* ---------- top bar ---------- */
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 22px; }
.me { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 48px; height: 48px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--pu) center / cover no-repeat; color: #fff;
  font: 600 17px/1 var(--f-head); box-shadow: 4px 4px 10px var(--sh), -4px -4px 10px var(--hi);
}
.me b { display: block; font: 600 16px/1.4 var(--f-head); font-feature-settings: "liga" 0, "calt" 0; }
.me small { display: block; color: var(--mu); font-size: 12.5px; line-height: 1.4; }
.tools { display: flex; gap: 10px; }
.tools .key { width: 42px; height: 42px; border-radius: 14px; }
.tools .key svg { width: 19px; height: 19px; }

/* ---------- tiles ---------- */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: minmax(158px, auto); gap: var(--gap); }
.tile { position: relative; padding: 20px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; overflow: hidden; text-align: start; transition: transform .25s var(--ease); }
a.tile:hover, button.tile:hover { transform: translateY(-2px); }
a.tile:active, button.tile:active { transform: translateY(1px) scale(.99); }
.tile b { display: block; font: 600 16px/1.45 var(--f-head); font-feature-settings: "liga" 0, "calt" 0; }
.tile small { display: block; font-size: 12.5px; line-height: 1.6; color: var(--mu); margin-top: 3px; }
.tile.wide { grid-column: span 2; }
.t-lavender { background: var(--pl); }
.t-lavender .well { background: var(--pl); box-shadow: inset 3px 3px 7px rgba(0, 0, 0, .12), inset -3px -3px 7px rgba(255, 255, 255, .35); }
:root[data-theme="dark"] .t-lavender .well { box-shadow: inset 3px 3px 7px #120D1A, inset -3px -3px 7px #36294A; }
.t-dark { background: linear-gradient(155deg, var(--dk1), var(--dk2)); color: #fff; }
.t-dark small { color: #B9B0C6; }
.t-orange { background: linear-gradient(155deg, #F2A862, #E2873A); color: #2E1705; }
.t-orange small { color: #5E3310; }
.ext { position: absolute; top: 20px; inset-inline-end: 20px; opacity: .55; }
.ext svg { width: 16px; height: 16px; }

/* about */
.about { grid-column: span 2; grid-row: span 2; padding: 0; display: grid; grid-template-columns: 1fr; background: linear-gradient(155deg, var(--hero1), var(--hero2)); color: #fff; }
.about.has-photo { grid-template-columns: 1fr 34%; }
.about .txt { padding: 24px; display: flex; flex-direction: column; justify-content: space-between; gap: 20px; }
.kicker { display: flex; align-items: center; gap: 7px; font-size: 12.5px; opacity: .85; }
.kicker i { width: 7px; height: 7px; border-radius: 50%; background: var(--or); }
.about h1 { font-size: clamp(26px, 3.1vw, 34px); line-height: 1.35; margin-top: 6px; font-weight: 700; }
.about:not(.has-photo) h1 { font-size: clamp(28px, 3.6vw, 40px); }
.about p { font-size: 15px; line-height: 1.95; opacity: .88; margin-top: 10px; font-weight: 300; max-width: 60ch; }
.about .photo { margin: 10px; margin-inline-start: 0; border-radius: 18px; background: center 20% / cover no-repeat; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); min-height: 200px; }
.stats { display: flex; flex-wrap: wrap; gap: 10px; }
.stats div { border-radius: 14px; padding: 8px 13px; font-size: 11.5px; line-height: 1.5; background: rgba(0, 0, 0, .16); box-shadow: inset 2px 2px 5px rgba(0, 0, 0, .28), inset -2px -2px 5px rgba(255, 255, 255, .1); }
.stats b { display: block; font: 600 19px/1.3 var(--f-head); }

/* ring */
.ring { position: relative; width: 84px; height: 84px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
[dir="rtl"] .ring svg { transform: rotate(-90deg) scaleY(-1); }
.ring .track { stroke: var(--pl); }
.ring .bar { transition: stroke-dashoffset 1.2s var(--ease); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 600 17px/1 var(--f-head); }

/* course "now playing" */
.now { display: flex; align-items: center; gap: 14px; height: 100%; }
.now .x { flex: 1; min-width: 0; }
.progress { height: 8px; border-radius: 9px; margin-top: 10px; background: var(--bg); box-shadow: inset 2px 2px 4px var(--sh), inset -2px -2px 4px var(--hi); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 9px; background: linear-gradient(90deg, var(--pu), var(--or)); transition: width 1.2s var(--ease); }
[dir="rtl"] .progress i { background: linear-gradient(270deg, var(--pu), var(--or)); }
.play { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--pu); box-shadow: 4px 4px 10px var(--sh), -4px -4px 10px var(--hi); flex: none; }
.play svg { width: 18px; height: 18px; }
.num { font: 700 36px/1 var(--f-head); color: var(--pu); }

/* entrance */
.grid > * { opacity: 0; transform: translateY(14px); animation: rise .6s var(--ease) forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- FAB (bottom-left, round, milk) ---------- */
.veil { position: fixed; inset: 0; z-index: 20; background: var(--veil); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); opacity: 0; pointer-events: none; transition: opacity .35s ease; }
body.menu-open .veil, body.sheet-open .veil { opacity: 1; pointer-events: auto; }
.fab {
  --s: 64px;
  position: fixed; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 40;
  width: var(--s); height: var(--s); border-radius: 50%; color: var(--pu);
  transition: width .45s var(--ease-io), height .45s var(--ease-io), left .45s var(--ease-io), bottom .45s var(--ease-io), color .45s ease;
}
.fab svg { width: 28px; height: 28px; transition: transform .45s var(--ease-io); }
body.menu-open .fab, body.sheet-open .fab { --s: 44px; left: 34px; bottom: calc(34px + env(safe-area-inset-bottom)); color: var(--or-ink); }
body.menu-open .fab svg, body.sheet-open .fab svg { transform: rotate(-135deg); }
.fan { position: fixed; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 30; width: 64px; height: 64px; opacity: 0; pointer-events: none; transform: translate(0, 0) scale(.3); transition: transform .35s cubic-bezier(.34, 1.45, .5, 1), opacity .2s ease; }
.fan .key { width: 64px; height: 64px; border-radius: 50%; color: var(--pu); }
.fan em { position: absolute; top: 50%; left: 100%; transform: translateY(-50%); margin-left: 10px; font-style: normal; font-size: 12.5px; font-weight: 500; white-space: nowrap; padding: 2px 10px; border-radius: 9px; background: var(--sf); box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .3); opacity: 0; transition: opacity .2s ease; }
.fan.top-label em { top: auto; bottom: 100%; left: 50%; transform: translateX(-50%); margin: 0 0 9px; }
body.menu-open .fan { opacity: 1; pointer-events: auto; }
body.menu-open .fan em { opacity: 1; }

/* ---------- sheets ---------- */
.sheet {
  position: fixed; z-index: 35; left: 50%; bottom: 0; width: min(560px, 100%); max-height: 88dvh; overflow: auto;
  transform: translate(-50%, 105%); background: var(--sf); border-radius: 30px 30px 0 0;
  padding: 14px 22px calc(108px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px -20px rgba(0, 0, 0, .35); transition: transform .55s var(--ease); visibility: hidden;
}
.sheet.show { transform: translate(-50%, 0); visibility: visible; }
.grab { width: 44px; height: 5px; border-radius: 9px; background: var(--kbl); margin: 0 auto 16px; }
.sheet h2 { font-size: 20px; line-height: 1.5; }
.sheet .lede { color: var(--mu); font-size: 14px; margin: 4px 0 18px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt { border-radius: 20px; padding: 16px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; text-align: start; box-shadow: 4px 4px 10px var(--sh), -4px -4px 10px var(--hi); }
.opt b { display: block; font: 600 15px/1.5 var(--f-head); font-feature-settings: "liga" 0, "calt" 0; }
.opt small { display: block; font-size: 12px; color: var(--mu); margin-top: 2px; }
.stagger > * { opacity: 0; transform: translateY(16px); }
.sheet.show .stagger > * { animation: rise .45s var(--ease) forwards; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 18px; background: var(--bg); box-shadow: 4px 4px 10px var(--sh), -4px -4px 10px var(--hi); }
.row .x { flex: 1; min-width: 0; } .row b { display: block; font-weight: 500; font-size: 15px; } .row small { display: block; color: var(--mu); font-size: 12.5px; direction: ltr; text-align: start; }
[dir="rtl"] .row small { text-align: right; }
.row .well { width: 42px; height: 42px; border-radius: 13px; }
.chev { color: var(--mu); } [dir="ltr"] .chev svg { transform: scaleX(-1); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 13px; color: var(--mu); }
.input { width: 100%; height: 52px; border-radius: 16px; border: 0; padding: 0 16px; font: 500 16px var(--f-body); color: var(--ink); background: var(--bg); box-shadow: inset 3px 3px 7px var(--sh), inset -3px -3px 7px var(--hi); direction: ltr; text-align: center; letter-spacing: .06em; }
.btn { width: 100%; height: 54px; border-radius: 18px; color: #fff; font: 600 15.5px var(--f-body); background: linear-gradient(160deg, var(--pu-2), var(--pu)); box-shadow: 0 4px 0 var(--pu-d), 0 12px 18px -10px rgba(63, 29, 96, .5); transition: transform .15s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--pu-d); }
.btn:disabled { opacity: .6; }
.msg { color: #C0392B; font-size: 13.5px; margin-top: 10px; }
:root[data-theme="dark"] .msg { color: #FF8F8F; }
.seg3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.seg3 .key { height: 56px; border-radius: 16px; font-weight: 500; color: var(--ink); }
.seg3 .key[aria-pressed="true"] { background: linear-gradient(160deg, var(--pu-2), var(--pu)); border-color: var(--pu-d); box-shadow: 0 4px 0 var(--pu-d); color: #fff; }
.sheet h3 { font-size: 14px; color: var(--mu); font-family: var(--f-body); font-weight: 500; margin: 6px 0 10px; }

.beta { margin-top: 28px; text-align: center; font-size: 12.5px; color: var(--mu); }
.beta a { color: var(--pu); text-decoration: underline; text-underline-offset: 3px; }

/* page exit (flowing navigation) */
body.leaving .wrap { opacity: 0; transform: scale(.98); filter: blur(6px); transition: all .35s var(--ease); }

/* ---------- tablet & phone ---------- */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .about { grid-column: span 2; }
}
@media (max-width: 560px) {
  :root { --gap: 12px; }
  .wrap { padding-top: 14px; }
  .top { margin-bottom: 16px; }
  .avatar { width: 44px; height: 44px; font-size: 15px; }
  .tools { gap: 8px; } .tools .key { width: 38px; height: 38px; border-radius: 12px; }
  .grid { grid-auto-rows: minmax(136px, auto); }
  .raised { border-radius: 22px; box-shadow: 4px 4px 11px var(--sh), -4px -4px 11px var(--hi); }
  .tile { padding: 15px; }
  .tile b { font-size: 14.5px; } .tile small { font-size: 11.5px; }
  .well { width: 40px; height: 40px; border-radius: 13px; } .well svg { width: 19px; height: 19px; }
  .about.has-photo { grid-template-columns: 1fr; grid-template-rows: 160px auto; }
  .about .photo { margin: 10px 10px 0; order: -1; min-height: 0; background-position: center 25%; }
  .about .txt { padding: 16px; gap: 16px; }
  .about h1, .about:not(.has-photo) h1 { font-size: 23px; }
  .about p { font-size: 13.5px; line-height: 1.85; }
  .stats div { padding: 6px 10px; font-size: 10.5px; } .stats b { font-size: 15px; }
  .stats div:nth-child(n+3) { display: none; }
  .ring { width: 64px; height: 64px; } .ring span { font-size: 14px; }
  .num { font-size: 28px; } .play { width: 42px; height: 42px; }
  .fab { --s: 58px; left: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); }
  body.menu-open .fab, body.sheet-open .fab { --s: 40px; left: 27px; bottom: calc(29px + env(safe-area-inset-bottom)); }
  .fan { left: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 58px; height: 58px; }
  .fan .key { width: 58px; height: 58px; }
  .fan em { font-size: 12px; }
  .sheet { padding-left: 18px; padding-right: 18px; }
}
