/* dhruvindave.live: case pages (/work/*.html). Shares tokens and type with site.css. */

/* ------------------------------------------------------------ tokens */
:root {
  --bg: #FBFAF7; --surface: #FFFFFF; --text: #1A1916; --text-2: #5F5C56;
  --hairline: #E6E2DA; --frame: #D9D4CA; --accent: #E4572E; --focus: #E4572E;
  --shadow: 0 12px 32px rgba(26, 25, 22, .14);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --col: 680px; --gutter: 24px;
  --ok: #3F7D46; --caution: #A7841C; --warn: #C2621F; --bad: #B23A2E;
  color-scheme: light;

  /* type scale (D) */
  --fs-h1: clamp(36px, 5vw, 56px);
  --fs-name: 28px;
  --fs-mail: 28px;
  --fs-h2: 24px;
  --fs-sub: 20px;
  --fs-row: 20px;
  --fs-num: 48px;
  --fs-body: 17px;
  --fs-small: 16px;

  --sec: 96px;
  --top-pad: 40px;

  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-num: Newsreader, Georgia, "Times New Roman", serif;
  --font-code: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;

  /* old names used by existing markup and scripts */
  --ink: var(--text);
  --ink-2: var(--text-2);
  --ground: var(--surface);
  --sans: var(--font);
  --serif: var(--font);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1B1A19; --surface: #232220; --text: #EDEAE4; --text-2: #A29E97;
    --hairline: #2F2D2A; --frame: #3A3835; --accent: #FF7A4D; --focus: #FF7A4D;
    --shadow: 0 12px 32px rgba(0, 0, 0, .45);
    --ok: #74B87B; --caution: #D9B54A; --warn: #E98A4A; --bad: #EA6A5E;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1B1A19; --surface: #232220; --text: #EDEAE4; --text-2: #A29E97;
  --hairline: #2F2D2A; --frame: #3A3835; --accent: #FF7A4D; --focus: #FF7A4D;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --ok: #74B87B; --caution: #D9B54A; --warn: #E98A4A; --bad: #EA6A5E;
  color-scheme: dark;
}

/* T: 640-899 */
@media (max-width: 899px) {
  :root { --fs-name: 26px; --fs-mail: 26px; --sec: 88px; --fs-num: 44px; }
}
/* M: 375-639 */
@media (max-width: 639px) {
  :root {
    --gutter: 20px; --fs-name: 24px; --fs-mail: 24px; --fs-h2: 22px;
    --fs-sub: 19px; --fs-row: 19px; --fs-num: 40px; --sec: 72px; --top-pad: 24px;
  }
}
/* S: below 375 */
@media (max-width: 374px) {
  :root { --gutter: 18px; --fs-mail: 22px; --fs-sub: 18px; --fs-row: 18px; }
}

/* ------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 24px;
  background: var(--bg);
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-body)/1.65 var(--font);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
  overflow-x: clip;
}
h1, h2, h3, p, ul, ol, figure, pre, dl { margin: 0; }
ul, ol { padding: 0; }
img, svg, video { display: block; max-width: 100%; height: auto; }
p { text-wrap: pretty; }
b, strong { font-weight: 500; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

.plain { list-style: none; }
.vh {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.js-only { display: none; }
.js .js-only { display: flex; }

/* ------------------------------------------------------------ links, focus, buttons */
a {
  color: inherit;
  text-decoration: underline 1px;
  text-decoration-color: var(--frame);
  text-underline-offset: .22em;
  transition: text-decoration-color 150ms var(--ease);
}
a:hover, a:focus-visible { text-decoration-color: var(--accent); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 2px; }

.skip {
  position: absolute;
  left: var(--gutter);
  top: 8px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-small);
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transform: translateY(-160%);
}
.skip:focus { transform: none; }

button {
  font: inherit;
  color: inherit;
  appearance: none;
  background: none;
  border: 0;
  margin: 0;
  padding: 0;
  cursor: pointer;
}
/* text buttons: metric toggles, demo toggles, theme */
.seg, .tbtn, .tog {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0;
  font-size: var(--fs-small);
  font-weight: 500;
  color: var(--text-2);
  text-decoration: underline 1px;
  text-decoration-color: transparent;
  text-underline-offset: .3em;
  transition: color 150ms var(--ease), text-decoration-color 150ms var(--ease);
}
.seg:hover, .tbtn:hover, .tog:hover { color: var(--text); text-decoration-color: var(--frame); }
.seg[aria-pressed="true"], .tbtn[aria-pressed="true"], .tog[aria-pressed="true"] {
  color: var(--text);
  text-decoration-color: var(--text);
}

/* ------------------------------------------------------------ layout */
.wrap {
  width: 100%;
  max-width: calc(var(--col) + 2 * var(--gutter));
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* header: same as the home page */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 24px;
  row-gap: 8px;
  padding-top: var(--top-pad);
}
.top .name {
  font-size: var(--fs-name);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
.top .name:hover { text-decoration: underline 1px; text-decoration-color: var(--accent); }
.top nav { display: flex; flex-wrap: wrap; column-gap: 24px; }
.top nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: var(--fs-small);
  font-weight: 500;
  line-height: 1.5;
  text-decoration-color: transparent;
}
.top nav a:hover, .top nav a:focus-visible { text-decoration-color: var(--accent); }
@media (max-width: 639px) {
  .top nav { column-gap: 20px; }
}

/* ------------------------------------------------------------ case head */
.case__top { padding-top: 72px; }
.case__h1 {
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.02em;
  max-width: 16ch;
  text-wrap: balance;
}
.lead, .case__sub {
  font-size: var(--fs-sub);
  line-height: 1.5;
  color: var(--text-2);
}
.case__sub { margin-top: 24px; max-width: 34em; }
@media (max-width: 639px) {
  .case__top { padding-top: 40px; }
  .case__sub { margin-top: 18px; }
}

/* breakout: video and the results grid use up to 960px on desktop */
@media (min-width: 900px) {
  .case__video,
  .case__evid .evgrid {
    width: min(960px, calc(100vw - 48px));
    margin-left: calc(50% - min(480px, 50vw - 24px));
  }
}

.case__video {
  margin-top: 48px;
  border: 1px solid var(--frame);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.case__video video { width: 100%; height: auto; aspect-ratio: 16 / 10; background: var(--surface); }

/* ------------------------------------------------------------ running text */
.case__txt section, .case__evid { margin-top: var(--sec); }
.case__txt h2, .case__evid h2 {
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
  margin-bottom: 20px;
}
.case__txt p + p { margin-top: 1.1em; }
.case__intro { color: var(--text-2); margin-bottom: 28px; }
@media (max-width: 639px) {
  .case__txt h2, .case__evid h2 { margin-bottom: 16px; }
  .case__intro { margin-bottom: 20px; }
}

/* in-text links to a panel */
a.cite { text-decoration: none; }
.cite__t {
  text-decoration: underline 1px;
  text-decoration-color: var(--frame);
  text-underline-offset: .22em;
  transition: text-decoration-color 150ms var(--ease);
}
.cite:hover .cite__t, .cite:focus-visible .cite__t { text-decoration-color: var(--accent); }

/* ------------------------------------------------------------ results grid and panels */
.evgrid { display: grid; grid-template-columns: minmax(0, 1fr); row-gap: 0; }
.evgrid > .evcell:last-child .panel { border-bottom: 1px solid var(--hairline); }
@media (min-width: 900px) {
  .evgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
  .evcell--wide { grid-column: 1 / -1; }
  .evgrid > .evcell:last-child .panel { border-bottom: 0; }
  .evgrid { border-bottom: 1px solid var(--hairline); }
}
.evcell { min-width: 0; }

.panel {
  height: 100%;
  border-top: 1px solid var(--hairline);
  padding: 24px 0 28px;
  outline: none;
}
.panel:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.panel__title {
  font-size: var(--fs-row);
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: -0.005em;
}
.panel__cap { color: var(--text-2); margin-top: 6px; max-width: 46ch; }
.panel__art { margin-top: 20px; }
.panel__src { margin-top: 20px; color: var(--text-2); }
.panel__note { color: var(--text-2); margin-top: 16px; max-width: 60ch; }
.panel__art > .small { color: var(--text-2); margin-top: 16px; }
.small { font-size: var(--fs-small); line-height: 1.55; }

/* big figure inside a test panel */
.fig {
  font-family: var(--font-num);
  font-weight: 400;
  font-size: var(--fs-num);
  line-height: 1;
  letter-spacing: -0.01em;
  font-variant-numeric: lining-nums tabular-nums;
  margin-bottom: 16px;
}
.panel ul.plain {
  display: grid;
  gap: 2px 24px;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  color: var(--text-2);
}

/* metric toggles */
.segs { flex-wrap: wrap; column-gap: 20px; margin: -10px 0 8px; }
.metric__sub { color: var(--text-2); margin-bottom: 16px; max-width: 46ch; }
.metric:not(.is-on) { display: none; }
html:not(.js) .metric { display: block; margin-bottom: 32px; }
html:not(.js) .metric:last-of-type { margin-bottom: 0; }

/* code: real code only, scrolls inside its own box */
pre {
  margin-top: 20px;
  font-family: var(--font-code);
  font-size: 15px;
  line-height: 1.6;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  tab-size: 2;
}
pre code { font: inherit; }

/* ------------------------------------------------------------ charts and diagrams */
svg { overflow: visible; }
svg text { font: 500 16px/1 var(--font); fill: var(--text); }
svg .val, .fig, .sim, .demo__live b, .log .id { font-variant-numeric: tabular-nums; }
.chart, .diagram { width: 100%; max-width: 360px; }
.diagram--flat { max-width: 420px; }
.chart .nm { fill: var(--text-2); font-weight: 400; }
.chart .bar { transform-box: fill-box; transform-origin: left center; }
.bar--accent { fill: var(--text); }
.bar--base { fill: color-mix(in srgb, var(--text-2) 45%, var(--bg)); }

.diagram .node rect { fill: var(--surface); stroke: var(--frame); stroke-width: 1; }
.diagram .node rect.lvl-bar { stroke: none; }
.diagram .edge { fill: none; stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 1; stroke-dashoffset: 0; stroke-linejoin: round; stroke-linecap: round; }
.diagram .rail { stroke: var(--frame); stroke-width: 2; }
.diagram .tick { fill: var(--text-2); }
.diagram .dot { fill: var(--accent); }
.diagram .note { fill: var(--text-2); font-weight: 400; }
.diagram .lvl-ok { fill: var(--ok); }
.diagram .lvl-caution { fill: var(--caution); }
.diagram .lvl-warn { fill: var(--warn); }
.diagram .lvl-bad { fill: var(--bad); }
.diagram .seg--train { fill: var(--text-2); }
.diagram .seg--val { fill: color-mix(in srgb, var(--text-2) 45%, var(--bg)); }
.diagram .seg--test { fill: var(--text); }
.diagram .ongr { fill: var(--bg); }

/* states main.js sets before a panel animates in */
.pre .chart .bar { transform: scaleX(0); }
.pre .diagram .node, .pre .diagram .edge { opacity: 0; }
.pre .diagram .edge { stroke-dashoffset: 1; opacity: 1; }
.pre .diagram .dot, .pre .diagram .note { opacity: 0; }

/* screenshots */
.shot {
  overflow: hidden;
  border: 1px solid var(--frame);
  border-radius: 10px;
  background: var(--surface);
}
.shot img { width: 100%; height: auto; transform-origin: 50% 50%; }
.shot--narrow { max-width: 480px; }

/* ------------------------------------------------------------ groundcheck event log */
.log {
  list-style: none;
  margin: 0;
  padding: 10px 0;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  font-family: var(--font-code);
  font-size: 15px;
  line-height: 1.55;
  overflow-x: auto;
}
.log li {
  display: grid;
  grid-template-columns: 4.6em minmax(0, 1fr) auto;
  gap: 0 14px;
  padding: 3px 14px 3px 11px;
  border-left: 3px solid transparent;
}
.log .id { color: var(--text-2); white-space: nowrap; }
.log .tx { color: var(--text-2); overflow-wrap: anywhere; }
.log .tg { font-family: var(--font); font-size: 16px; color: var(--text-2); white-space: nowrap; }
.log .is-gold { border-left-color: var(--text); }
.log .is-gold .id, .log .is-gold .tx { color: var(--text); }
.log .is-gold .tg { color: var(--text); font-weight: 500; }
.log .is-dis .tg { color: var(--warn); }
.log .is-cited { background: color-mix(in srgb, var(--text) 6%, transparent); }
.log .is-cited .tg { font-weight: 500; }
.log .is-dis.is-cited .tx { text-decoration: underline wavy var(--warn); text-underline-offset: 3px; }
@media (max-width: 639px) {
  .log li { grid-template-columns: 4.6em minmax(0, 1fr); }
  .log .tg { grid-column: 2; }
  .log .tg:empty { display: none; }
}

/* ------------------------------------------------------------ MusicAI demo */
.demo { display: block; max-width: 680px; }
.demo label.lbl { display: block; font-weight: 500; margin-bottom: 8px; }
.demo__q { margin-top: 12px; color: var(--text-2); }
.demo__q b { color: var(--text); }
.combo { position: relative; }
.combo input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font: inherit;
  font-size: var(--fs-body);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--frame);
  border-radius: 8px;
  outline-offset: 2px;
}
.combo input::placeholder { color: var(--text-2); opacity: 1; }
.combo input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.combo ul {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 3;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--frame);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 22rem;
  overflow: auto;
}
.combo li { padding: 10px 14px; min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.combo li[aria-selected="true"], .combo li:hover { background: color-mix(in srgb, var(--text) 7%, transparent); }
.demo__bar { display: flex; flex-wrap: wrap; gap: 4px 24px; align-items: center; margin: 12px 0 4px; }
.demo__tog { display: flex; gap: 0 20px; }
.results { list-style: none; margin: 4px 0 0; padding: 0; border-top: 1px solid var(--hairline); }
.results li {
  padding: 12px 0 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 16px;
  align-items: baseline;
  border-bottom: 1px solid var(--hairline);
}
.results .nm { font-weight: 500; overflow-wrap: anywhere; }
.results .ar { color: var(--text-2); font-size: var(--fs-small); grid-column: 1; }
.results .sim { grid-column: 2; grid-row: 1; color: var(--text-2); }
.results .tag { color: var(--text); font-weight: 500; font-size: var(--fs-small); margin-left: 10px; }
.results .meter { grid-column: 1 / -1; height: 2px; margin-top: 8px; background: var(--hairline); }
.results .meter i { display: block; height: 2px; background: var(--text-2); transform-origin: left; }
.demo__live { margin-top: 16px; color: var(--text-2); }
.demo__live b { color: var(--text); }
.demo__err { color: var(--bad); }
.demo__load { color: var(--text-2); }

/* ------------------------------------------------------------ footer */
.foot {
  margin-top: 120px;
  border-top: 1px solid var(--hairline);
  padding-top: 32px;
  padding-bottom: 48px;
}
.foot__back { font-size: var(--fs-body); font-weight: 500; }
.foot__back a { display: inline-flex; align-items: center; min-height: 44px; }
.foot__mail {
  margin-top: 32px;
  font-size: var(--fs-mail);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}
.foot__mail a { text-decoration-color: var(--frame); }
.foot__mail a:hover, .foot__mail a:focus-visible { text-decoration-color: var(--accent); }
.foot__row {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 40px;
  justify-content: space-between;
  align-items: center;
}
.foot__links { list-style: none; display: flex; flex-wrap: wrap; column-gap: 24px; font-size: var(--fs-body); font-weight: 500; }
.foot__links a { display: inline-flex; align-items: center; min-height: 44px; }
.theme { display: flex; flex-wrap: wrap; column-gap: 20px; }
.foot__fine { margin-top: 24px; font-size: var(--fs-small); color: var(--text-2); }
@media (max-width: 639px) {
  .foot { margin-top: 88px; padding-top: 24px; }
  .foot__mail { margin-top: 24px; }
  .foot__row { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------------------ reveal (main.js) */
.js [data-rv]:not(.in) { opacity: 0; transform: translateY(8px); }
@media (prefers-reduced-motion: reduce) {
  .js [data-rv]:not(.in) { opacity: 1; transform: none; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print {
  .js [data-rv]:not(.in) { opacity: 1 !important; transform: none !important; }
}
