/* ============================================================
   ARMIN SABER — arminsaber.com
   One page, one axis: logic at the top, feeling at the bottom.
   The accent colour and the typographic register are the only
   things that change as you descend. The background never does.
   ============================================================ */

/* --t: global spectrum position, 0 = logic, 1 = feeling.
   Driven from scroll by script.js. Everything accent-coloured
   derives from it; nothing else moves with it. */
@property --t {
  syntax: '<number>';
  initial-value: 0;
  inherits: true;
}

:root {
  --bg:    #0A0A0C;
  --ink:   #EDEBE6;
  --muted: #75757F;
  --hair:  #1E1E23;
  --logic: #7E8CF0;
  --feel:  #B8F06E;

  --accent: color-mix(in oklch, var(--logic) calc((1 - var(--t)) * 100%), var(--feel));

  /* spacing rhythm — hold to this scale, nothing arbitrary */
  --s1: 8px;
  --s2: 16px;
  --s3: 24px;
  --s4: 40px;
  --s5: 64px;
  --s6: 104px;
  --s7: 168px;

  --ribbon-h: 44px;
  --edge-h: 2px;
  --measure: 62ch;
  --page-max: 1060px;
  --pad-x: clamp(20px, 5vw, 48px);

  --font-display: "Fraunces", "Georgia", serif;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-mono: "Fragment Mono", "SF Mono", monospace;

  /* motion — quick, confident, ease-out; nothing bouncy */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-fast: 180ms;
  --dur-med: 420ms;
}

/* ------------------------------------------------------------
   Reset + base
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--ribbon-h) + var(--edge-h) + var(--s3));
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

@media (min-width: 720px) {
  body { font-size: 17px; }
}

::selection { background: var(--accent); color: var(--bg); }

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
  border-radius: 1px;
}

/* Sections carry their own fixed register via --st (0..1):
   type is set by where a thing SITS on the spectrum, while
   accents follow where the READER is. Display type tightens
   at the logic end; softens, loosens and goes slightly wonky
   at the feeling end. Felt, not announced. */
.display {
  font-family: var(--font-display);
  font-variation-settings:
    "SOFT" calc(var(--st, 0) * 100),
    "WONK" var(--st, 0);
  font-weight: calc(580 - var(--st, 0) * 120);
  letter-spacing: calc(-0.034em + var(--st, 0) * 0.042em);
  line-height: calc(1.02 + var(--st, 0) * 0.14);
}

.mono {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: calc(0.14em + var(--st, 0) * 0.08em);
  text-transform: uppercase;
}

/* ------------------------------------------------------------
   Top edge + spectrum ribbon (the signature element)
   ------------------------------------------------------------ */
.edge {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--edge-h);
  background: var(--accent);
  z-index: 30;
}

.ribbon {
  position: fixed;
  top: var(--edge-h);
  left: 0;
  right: 0;
  height: var(--ribbon-h);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s2);
  padding: 0 var(--pad-x);
  background: var(--bg);
  border-bottom: 1px solid var(--hair);
}

.ribbon-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  flex: none;
  user-select: none;
}
.ribbon-label--logic { color: var(--logic); }
.ribbon-label--feel  { color: var(--feel); }

.ribbon-track {
  position: relative;
  flex: 1;
  height: 100%;
}

.ribbon-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--hair);
}

/* Ticks: one per project, placed at its spectrum position.
   They light in --accent as the thumb passes. */
.ribbon-tick {
  position: absolute;
  top: 0;
  height: 100%;
  width: 20px;
  transform: translateX(-50%);
  display: block;
}
.ribbon-tick::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: 10px;
  background: var(--muted);
  transition: background var(--dur-fast) linear, height var(--dur-fast) var(--ease-out);
}
.ribbon-tick.is-lit::before {
  background: var(--accent);
  height: 14px;
}

/* Tick tooltip — desktop hover/focus only */
.ribbon-tick::after {
  content: attr(data-name);
  position: absolute;
  top: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--hair);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-fast) linear;
}
.ribbon-tick:hover::after,
.ribbon-tick:focus-visible::after { opacity: 1; }

.ribbon-thumb {
  position: absolute;
  top: 50%;
  left: 0;
  width: 8px;
  height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  will-change: transform;
}

/* ------------------------------------------------------------
   Page scaffold
   ------------------------------------------------------------ */
main {
  padding-top: calc(var(--ribbon-h) + var(--edge-h));
}

.hero,
.entries {
  max-width: var(--page-max);
  margin: 0 auto;
  padding-left: var(--pad-x);
  padding-right: var(--pad-x);
}

/* ------------------------------------------------------------
   Mobile ribbon: track + thumb only, labels shrink,
   no per-tick hover states
   ------------------------------------------------------------ */
@media (max-width: 640px) {
  :root { --ribbon-h: 40px; }
  .ribbon { gap: var(--s1); }
  .ribbon-label { font-size: 9px; letter-spacing: 0.14em; }
  .ribbon-tick::after { display: none; }
}

/* ------------------------------------------------------------
   Reduced motion: no smooth scroll; script.js also snaps the
   spectrum engine and disables reveals.
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------
   Motion system (Group 2)
   Scroll-linked reveals are driven inline by script.js; here we
   only stage the page-load sequence: quick, staggered, ease-out.
   ------------------------------------------------------------ */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

.stagger > * {
  opacity: 0;
}
.is-ready .stagger > * {
  animation: rise 560ms var(--ease-out) both;
}
.is-ready .stagger > :nth-child(1) { animation-delay: 40ms; }
.is-ready .stagger > :nth-child(2) { animation-delay: 110ms; }
.is-ready .stagger > :nth-child(3) { animation-delay: 180ms; }
.is-ready .stagger > :nth-child(4) { animation-delay: 250ms; }
.is-ready .stagger > :nth-child(5) { animation-delay: 320ms; }

/* no-JS fallback: never leave content hidden */
@media (scripting: none) {
  .stagger > * { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .stagger > * { opacity: 1; animation: none !important; }
}

/* hairline rule that draws itself in as it enters */
.rule {
  border: 0;
  height: 1px;
  background: var(--hair);
  transform-origin: left center;
}

.rule--accent {
  background: var(--accent);
  opacity: 0.55;
}

/* ------------------------------------------------------------
   Hero (Group 3) — dense, not airy. The whole thesis lands
   before any scrolling: headline states it, the plot shows it.
   ------------------------------------------------------------ */
.hero {
  padding-top: var(--s6);
  padding-bottom: var(--s5);
}

.hero-eyebrow {
  color: var(--accent);
  line-height: 2;
}
.hero-eyebrow-sub {
  color: var(--muted);
}

.hero-headline {
  margin-top: var(--s3);
  font-size: clamp(38px, 6.6vw, 80px);
  max-width: 13.5em;
}
.w-logic, .w-feel { font-style: normal; }
.w-logic { color: var(--logic); }
.w-feel  { color: var(--feel); }

.hero-lede {
  margin-top: var(--s4);
  max-width: 54ch;
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.65;
  color: color-mix(in oklab, var(--ink) 72%, var(--muted));
}

/* The plot: every project as a dot on the one axis that
   organizes this page. Dot colour is fixed at the project's own
   spectrum position — the axis previews the whole descent. */
.plot {
  margin-top: var(--s5);
}

.plot-axis {
  position: relative;
  height: 56px;
  margin: 0 var(--s1);
}

.plot-line {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--logic), var(--feel));
  opacity: 0.45;
}

.plot-dot {
  position: absolute;
  top: 50%;
  left: calc(var(--pt) * 100%);
  width: 30px;
  height: 44px;
  transform: translate(-50%, -50%);
}
.plot-dot::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: color-mix(in oklch, var(--logic) calc((1 - var(--pt)) * 100%), var(--feel));
  transform: translate(-50%, -50%);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) linear;
}
.plot-dot:hover::before,
.plot-dot:focus-visible::before,
.plot-dot.is-active::before {
  transform: translate(-50%, -50%) scale(1.45);
  box-shadow: 0 0 0 5px
    color-mix(in oklch,
      color-mix(in oklch, var(--logic) calc((1 - var(--pt)) * 100%), var(--feel)) 22%,
      transparent);
}

.plot-scale {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s1);
}
.plot-pole { font-size: 10px; }
.plot-pole--logic { color: var(--logic); }
.plot-pole--feel  { color: var(--feel); }

.plot-readout {
  margin-top: var(--s3);
  min-height: 2.6em;
  color: var(--muted);
  transition: color var(--dur-fast) linear;
}
.plot-readout.is-active { color: var(--ink); }
.plot-readout .ro-n { color: var(--accent); margin-right: 1em; }
.plot-readout .ro-cat { color: var(--muted); margin-left: 1em; }

@media (max-width: 640px) {
  .hero { padding-top: var(--s5); }
  .hero-lede { margin-top: var(--s3); }
  .plot { margin-top: var(--s4); }
}

/* ------------------------------------------------------------
   Entries (Group 4) — the core of the site.
   A ledger: meta column left, substance right. The expanded
   brief keeps the same two columns so its labels align with
   the meta column above them.
   ------------------------------------------------------------ */
.entries {
  padding-bottom: var(--s5);
}

/* expand/collapse-all — sits in the meta column's grid lane */
.entries-tools {
  display: grid;
  grid-template-columns: 230px 1fr;
  column-gap: var(--s4);
  padding: var(--s2) 0;
}
.expand-all {
  justify-self: start;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.expand-all .tgl {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1;
  transition: transform var(--dur-med) var(--ease-out);
}
.expand-all[aria-pressed="true"] .tgl { transform: rotate(45deg); }
.expand-all:hover { text-decoration: underline; text-underline-offset: 4px; }

.entry {
  border-top: 1px solid var(--hair);
  padding: var(--s5) 0;
}

.entry-head {
  display: grid;
  grid-template-columns: 230px 1fr;
  column-gap: var(--s4);
  cursor: pointer;
}

/* meta column */
.entry-meta { display: flex; flex-direction: column; gap: var(--s2); }
.entry-pos { color: var(--accent); }
.entry-cat { color: var(--muted); }

/* miniature of the hero axis: where this entry sits */
.entry-axis {
  position: relative;
  width: 72px;
  height: 1px;
  background: var(--hair);
}
.entry-axis i {
  position: absolute;
  top: 50%;
  left: calc(var(--pt) * 100%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--accent);
}

/* main column */
.entry-name {
  font-size: clamp(30px, 3.8vw, 46px);
}
.entry-one {
  margin-top: var(--s2);
  max-width: var(--measure);
  color: color-mix(in oklab, var(--ink) 80%, var(--muted));
}

.entry-actions {
  margin-top: var(--s3);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s2) var(--s4);
}

.entry-toggle {
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}
.entry-toggle .tgl {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1;
  transition: transform var(--dur-med) var(--ease-out);
}
.entry.is-open .entry-toggle .tgl { transform: rotate(45deg); }
.entry-toggle:hover { text-decoration: underline; text-underline-offset: 4px; }

.entry-link {
  color: var(--muted);
  text-decoration: none;
  transition: color var(--dur-fast) linear;
}
.entry-link:hover { color: var(--accent); }

/* expanded brief: animated with the 0fr → 1fr grid technique —
   smooth height, no measuring, no jump on the entries below */
.entry-brief {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--dur-med) var(--ease-out);
}
.entry.is-open .entry-brief {
  grid-template-rows: 1fr;
}
/* collapsed content stays in the DOM and findable: the inner
   carries hidden="until-found" (content-visibility, searchable);
   script.js lifts it on expand and on beforematch */
.entry.no-anim .entry-brief,
.entry.no-anim .brief-row {
  transition: none !important;
}
.entry-brief-inner {
  overflow: hidden;
  min-height: 0;
}

.brief {
  padding-top: var(--s4);
  display: flex;
  flex-direction: column;
}

.brief-row {
  display: grid;
  grid-template-columns: 230px 1fr;
  column-gap: var(--s4);
  padding: var(--s3) 0;
  border-top: 1px dashed color-mix(in oklab, var(--hair) 72%, var(--muted));
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity var(--dur-med) var(--ease-out),
    transform var(--dur-med) var(--ease-out);
}
.entry.is-open .brief-row { opacity: 1; transform: none; }
.entry.is-open .brief-row:nth-child(1) { transition-delay: 60ms; }
.entry.is-open .brief-row:nth-child(2) { transition-delay: 110ms; }
.entry.is-open .brief-row:nth-child(3) { transition-delay: 160ms; }
.entry.is-open .brief-row:nth-child(4) { transition-delay: 210ms; }
.entry.is-open .brief-row:nth-child(5) { transition-delay: 260ms; }

.brief-row dt { color: var(--accent); padding-top: 3px; }
.brief-row dd {
  max-width: var(--measure);
  color: color-mix(in oklab, var(--ink) 86%, var(--muted));
}

/* the visible to-fill placeholders — meant to be found */
mark.ph {
  background: none;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82em;
  border: 1px dashed color-mix(in oklab, var(--accent) 45%, transparent);
  border-radius: 2px;
  padding: 1px 7px;
}

/* ------------------------------------------------------------
   Entries — stacked below 760px
   ------------------------------------------------------------ */
@media (max-width: 760px) {
  .entry { padding: var(--s4) 0; }
  .entry-head,
  .brief-row {
    grid-template-columns: 1fr;
    row-gap: var(--s2);
  }
  .entry-meta {
    flex-direction: row;
    align-items: center;
    gap: var(--s2);
    flex-wrap: wrap;
  }
  .entry-axis { width: 44px; }
  .brief-row { row-gap: var(--s1); }
}

/* ------------------------------------------------------------
   Ending (Group 5) — the page closes on the feeling end.
   A composed sign-off, not leftover space: statement, contact,
   baseline. Nothing trails below the baseline row.
   ------------------------------------------------------------ */
.ending {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--s6) var(--pad-x) var(--s4);
  /* mirrors the coda's dissolving rule so the ending reads as a
     continuation of it, not a new section */
  border-image: linear-gradient(90deg, transparent 5%, var(--hair) 70%) 1;
  border-top: 1px solid;
}

.ending-eyebrow { color: var(--accent); }

.ending-statement {
  margin-top: var(--s3);
  font-size: clamp(32px, 4.4vw, 58px);
  max-width: 21em;
}

.ending-contact {
  margin-top: var(--s5);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s4);
}
.ending-contact a {
  color: var(--ink);
  text-decoration: none;
  padding: 6px 0;
  border-bottom: 1px solid var(--hair);
  transition: color var(--dur-fast) linear, border-color var(--dur-fast) linear;
}
.ending-contact a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ending-base {
  margin-top: var(--s5);
  padding-top: var(--s3);
  border-top: 1px solid var(--hair);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  color: var(--muted);
}

/* the axis, one last time: two poles on a hairline */
.ending-glyph {
  position: relative;
  flex: 0 1 96px;
  height: 1px;
  background: var(--hair);
}
.ending-glyph .pole {
  position: absolute;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.pole--logic { left: 0;    background: var(--logic); }
.pole--feel  { left: 100%; background: var(--feel); }

@media (max-width: 640px) {
  .ending { padding-top: var(--s5); }
  .ending-contact { margin-top: var(--s4); }
  .ending-base {
    margin-top: var(--s5);
    flex-wrap: wrap;
  }
  .ending-glyph { display: none; }
}

/* once the load stagger has played, hand opacity control back to
   the reveal engine so the hero can dissolve out like everything else */
.stagger-done > * {
  animation: none !important;
  opacity: 1;
}

/* ------------------------------------------------------------
   The coda (Live sets) — the ledger deliberately comes apart.
   No category, no expander, no labels: one paragraph at the
   loosest end of the Fraunces register, and a hairline above
   that dissolves instead of ruling a row off.
   ------------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.entry--coda {
  border-top: 0;
  border-image: linear-gradient(90deg, var(--hair) 30%, transparent 95%) 1;
  border-top: 1px solid;
  padding-top: var(--s6);
}

.entry--coda .entry-head { cursor: default; }

/* position number and mini-axis at their quietest */
.entry--coda .entry-meta { opacity: 0.5; }
.entry--coda .entry-pos { color: var(--muted); }
.entry--coda .entry-axis i { background: var(--muted); }

.coda-text {
  font-size: clamp(24px, 3vw, 40px);
  font-variation-settings: "SOFT" 100, "WONK" 1;
  font-weight: 330;
  letter-spacing: 0.014em;
  line-height: 1.44;
  max-width: 26em;
  color: var(--ink);
}

.coda-link {
  display: inline-block;
  margin-top: var(--s4);
  font-size: 15px;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--hair);
  padding-bottom: 4px;
  transition: color var(--dur-fast) linear, border-color var(--dur-fast) linear;
}
.coda-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 760px) {
  .entry--coda { padding-top: var(--s5); }
}
