/* Atsy — "Ink & Signal" design system.
   Tokens first, components second. Every colour has its light value on bare
   :root; dark redefines the same tokens in two guarded blocks so an explicit
   choice wins in both directions. Never declare a colour only inside a media
   query — that is the classic unreadable-page bug. */

/* ---------- fonts (self-hosted; nothing is fetched from a third party) ---------- */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('/fonts/bricolage-grotesque-var.woff2') format('woff2-variations');
  font-weight: 200 800; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Instrument Sans';
  src: url('/fonts/instrument-sans-var.woff2') format('woff2-variations');
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/jetbrains-mono-var.woff2') format('woff2-variations');
  font-weight: 100 800; font-style: normal; font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --paper: #FAF8F4;
  --paper-2: #F2EEE7;
  --card: #FFFFFF;
  --edge: #E3DFD7;
  --ink: #14161A;
  --ink-2: #4A4E5C;
  --ink-3: #767B8A;

  --signal: #3A32E0;
  --signal-ink: #FFFFFF;
  --signal-soft: #EDECFF;
  --signal-edge: #CFCCFA;

  --sev-critical: #B3261E;
  --sev-major: #A85B00;
  --sev-minor: #5B6470;
  --band-risk: #B3261E;
  --band-work: #A85B00;
  --band-strong: #1F6F63;
  --band-great: #1B7A3D;

  --machine-bg: #101318;
  --machine-ink: #C4D0E0;
  --machine-dim: #6C7A8C;
  --machine-bad: #FF9E95;

  --shadow: 0 1px 2px rgba(20, 22, 26, .05), 0 12px 28px -18px rgba(20, 22, 26, .35);

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --s6: 32px; --s7: 48px; --s8: 64px; --s9: 96px;
  --r-ctl: 7px; --r-card: 14px;

  --display: 'Bricolage Grotesque', 'Trebuchet MS', system-ui, sans-serif;
  --body: 'Instrument Sans', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --paper: #101116;
    --paper-2: #15171E;
    --card: #181A22;
    --edge: #2A2D38;
    --ink: #F2F0EC;
    --ink-2: #B4B8C4;
    --ink-3: #868C9B;

    --signal: #9B94FF;
    --signal-ink: #111219;
    --signal-soft: #20213A;
    --signal-edge: #3A3A66;

    --sev-critical: #FF8D82;
    --sev-major: #F0B25A;
    --sev-minor: #9AA3B2;
    --band-risk: #FF8D82;
    --band-work: #F0B25A;
    --band-strong: #5FD1BE;
    --band-great: #67D389;

    --machine-bg: #080A0E;
    --machine-dim: #5E6B7D;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 32px -20px rgba(0, 0, 0, .8);

    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --paper: #101116;
  --paper-2: #15171E;
  --card: #181A22;
  --edge: #2A2D38;
  --ink: #F2F0EC;
  --ink-2: #B4B8C4;
  --ink-3: #868C9B;

  --signal: #9B94FF;
  --signal-ink: #111219;
  --signal-soft: #20213A;
  --signal-edge: #3A3A66;

  --sev-critical: #FF8D82;
  --sev-major: #F0B25A;
  --sev-minor: #9AA3B2;
  --band-risk: #FF8D82;
  --band-work: #F0B25A;
  --band-strong: #5FD1BE;
  --band-great: #67D389;

  --machine-bg: #080A0E;
  --machine-dim: #5E6B7D;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 32px -20px rgba(0, 0, 0, .8);

  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  /* Short pages must still put the footer at the bottom of the screen, not
     halfway up it. dvh so a phone's collapsing address bar cannot leave a gap. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }
.foot { flex: none; }

h1, h2, h3, h4 { font-family: var(--display); margin: 0; text-wrap: balance; }
p { margin: 0; }
img { max-width: 100%; }

a { color: var(--signal); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: 1060px; margin: 0 auto; padding: 0 var(--s5); }
.stack { display: flex; flex-direction: column; }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--card); color: var(--ink);
  padding: var(--s3) var(--s4); border: 1px solid var(--edge); border-radius: var(--r-ctl); z-index: 50;
}
.skip:focus { left: var(--s4); top: var(--s3); }

.eyebrow {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-3);
}

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 500; line-height: 1.2;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 48px; padding: 13px 22px;
  border-radius: var(--r-ctl); border: 1px solid transparent; cursor: pointer;
  text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primary { background: var(--signal); color: var(--signal-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--signal) 86%, #000); }
.btn-quiet { background: var(--card); color: var(--ink); border-color: var(--edge); }
.btn-quiet:hover { border-color: var(--ink-3); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--edge);
}
.nav .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4); min-height: 60px;
}
.mark {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-family: var(--display); font-weight: 800; font-size: 20px;
  letter-spacing: -.02em; color: var(--ink); text-decoration: none;
}
.mark i { width: 11px; height: 11px; border-radius: 2px; background: var(--signal); transform: rotate(45deg); }
.navactions { display: flex; align-items: center; gap: var(--s2); }
.themebtn {
  font: inherit; font-size: 14px; background: var(--card); color: var(--ink-2);
  border: 1px solid var(--edge); border-radius: 999px; padding: 8px 16px;
  min-height: 44px; cursor: pointer;
  transition: color .12s ease, border-color .12s ease;
}
.themebtn:hover { color: var(--ink); border-color: var(--ink-3); }
.btn-nav { min-height: 44px; padding: 10px 18px; font-size: 15px; }

/* ---------- hero ---------- */
.hero { padding: var(--s8) 0 var(--s7); }
.hero h1 {
  font-size: clamp(38px, 7.4vw, 72px); line-height: .98; letter-spacing: -.035em;
  font-weight: 800; max-width: 15ch; margin-top: var(--s4);
}
.hero h1 em { font-style: normal; color: var(--signal); }
.lede { max-width: 58ch; color: var(--ink-2); font-size: clamp(16px, 2.1vw, 19px); margin-top: var(--s4); }
.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-top: var(--s6); }
.cta-note { font-size: 14px; color: var(--ink-3); }

/* ---------- sections ---------- */
.section { padding: var(--s7) 0; border-top: 1px solid var(--edge); }
.shead { display: flex; flex-direction: column; gap: var(--s2); margin-bottom: var(--s6); max-width: 64ch; }
.shead h2 { font-size: clamp(24px, 3.4vw, 34px); letter-spacing: -.02em; font-weight: 600; }
.shead p { color: var(--ink-2); }

/* ---------- cards / bento ---------- */
.bento { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.card {
  min-width: 0;
  background: var(--card); border: 1px solid var(--edge); border-radius: var(--r-card);
  padding: var(--s5); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: var(--s2);
  margin-bottom: 0;
}
.card h3 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.card p { color: var(--ink-2); font-size: 15px; }
.card ul { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.card li { margin-bottom: var(--s1); }

.note {
  border: 1px solid var(--signal-edge); background: var(--signal-soft);
  border-radius: var(--r-card); padding: var(--s5); color: var(--ink-2); font-size: 15px;
}
.note b { color: var(--ink); }

/* ---------- machine-view demo ---------- */
.demo { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 920px) {
  .demo { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); align-items: start; }
}

.stage {
  min-width: 0;
  border: 1px solid var(--edge); border-radius: var(--r-card); background: var(--card);
  box-shadow: var(--shadow); overflow: hidden;
  /* Clear the sticky nav when anything inside is scrolled into view. */
  scroll-margin-top: 76px;
}
.stagebar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--edge); background: var(--paper-2);
}
.fname {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.toggle {
  display: flex; background: var(--paper); border: 1px solid var(--edge);
  border-radius: 999px; padding: 3px; gap: 2px; min-width: 0;
}
/* Paired actions sit side by side as equal halves, never stacked
   (Pricey incident #34). Below 560px the pair takes the full row. */
@media (max-width: 560px) {
  .stagebar { flex-direction: column; align-items: stretch; }
  .toggle { width: 100%; }
  .toggle button { flex: 1 1 0; min-width: 0; }
}
.toggle button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent;
  color: var(--ink-2); padding: 8px 14px; border-radius: 999px; cursor: pointer; min-height: 38px;
  transition: background-color .12s ease, color .12s ease;
}
.toggle button[aria-pressed='true'] { background: var(--signal); color: var(--signal-ink); }

.views { display: grid; padding: var(--s4); }
.view { grid-area: 1 / 1; min-width: 0; transition: opacity .32s ease; }
.view.is-out { opacity: 0; visibility: hidden; pointer-events: none; }

.cv {
  height: 100%; overflow: hidden; position: relative;
  background: #FFFFFF; color: #22242B; border: 1px solid #E8E4DC; border-radius: 8px;
  padding: 18px 20px 18px 38px; font-size: 11px; line-height: 1.45;
}
.cv .cvhdr {
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  border-bottom: 1px dashed #C9C4BA; padding-bottom: 7px; margin-bottom: 11px;
  color: #5A5E68; font-size: 9.5px;
}
.cv h4 { font-size: 19px; letter-spacing: -.02em; color: #15171C; margin-bottom: 2px; }
.cv .role { font-size: 10px; color: #5A5E68; margin-bottom: 12px; }
.cv .cols { display: grid; grid-template-columns: .72fr 1.28fr; gap: 16px; }
@media (max-width: 560px) {
  .cv { font-size: 10px; padding: 16px 12px 16px 34px; }
  .cv .cols { gap: 11px; }
  .cv h4 { font-size: 17px; }
}
.cv .lbl {
  font-family: var(--display); font-size: 9.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: #15171C; margin: 0 0 5px;
}
.cv ul { margin: 0 0 11px; padding-left: 14px; }
.cv .plain { list-style: none; padding: 0; }
.cv li { margin-bottom: 3px; }
.cv .dots { letter-spacing: 2px; color: #3A32E0; font-size: 9px; }
.cv .job { margin-bottom: 10px; }
.cv .when { color: #767B8A; font-size: 9.5px; font-family: var(--mono); }
/* Annotations are anchored to the elements they describe, not to fixed
   coordinates: a hardcoded box stops matching its content the moment the
   container changes width. The numbered pins are real elements in the page's
   left gutter — never pseudo-elements — so the overlap gate can measure them
   and a collision with the CV text fails the build. */
.flag { position: relative; border-radius: 3px; }
.flag-critical { outline: 1.5px solid var(--sev-critical); outline-offset: 2px; background: rgba(179, 38, 30, .07); }
.flag-major { outline: 1.5px solid var(--sev-major); outline-offset: 2px; background: rgba(168, 91, 0, .07); }
.pin {
  position: absolute; left: -26px; top: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 10px; font-weight: 500;
  color: #FFFFFF; background: var(--sev-critical);
}
.flag-major > .pin { background: var(--sev-major); }
/* The date is inline inside a bullet, so its pin rides with the text. */
.pin-inline {
  position: static; display: inline-grid; vertical-align: middle; margin-right: 4px;
}

.machine {
  height: 100%; overflow: auto; min-height: 0; border-radius: 8px; padding: 18px 20px;
  background: var(--machine-bg); color: var(--machine-ink);
  font-family: var(--mono); font-size: 11.5px; line-height: 1.75;
  border: 1px solid rgba(120, 140, 170, .18);
  white-space: pre-wrap; margin: 0;
}
.machine .m { color: var(--machine-dim); }
.machine .bad { color: var(--machine-bad); }

/* ---------- findings ---------- */
.finds { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.find {
  background: var(--card); border: 1px solid var(--edge); border-left: 3px solid var(--sev-critical);
  border-radius: var(--r-card); padding: var(--s4); box-shadow: var(--shadow);
}
.find.major { border-left-color: var(--sev-major); }
.find.minor { border-left-color: var(--sev-minor); }
.find .top { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: 6px; }
.find h3 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.find p { font-size: 14.5px; color: var(--ink-2); }
.find .pts { display: block; font-family: var(--mono); font-size: 12px; color: var(--signal); margin-top: var(--s2); }
.chip {
  font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 999px; padding: 3px 9px; white-space: nowrap;
}
.chip.crit { color: var(--sev-critical); }
.chip.maj { color: var(--sev-major); }
.chip.min { color: var(--sev-minor); }
.ev {
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-3); background: var(--paper-2);
  border: 1px solid var(--edge); border-radius: 6px; padding: 6px 9px; margin-top: var(--s2);
  overflow-wrap: anywhere;
}

/* ---------- app screens (sign in, account) ---------- */
.screenwrap { padding: var(--s7) 0 var(--s8); }
.prose { max-width: 44rem; }
.prose .card { margin-bottom: var(--s4); gap: var(--s3); }
.prose .card p { color: var(--ink-2); font-size: 15.5px; }
.screen { display: flex; flex-direction: column; gap: var(--s3); max-width: 34rem; }
.screen[hidden] { display: none; }
.screen-title { font-size: clamp(28px, 5vw, 40px); letter-spacing: -.025em; font-weight: 800; }
.screen-lede { color: var(--ink-2); }
.screen .card { margin-top: var(--s4); }
.cardtitle { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.tightlist { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 15px; }
.tightlist li { margin-bottom: var(--s1); }

.form { display: flex; flex-direction: column; gap: var(--s4); margin-top: var(--s4); align-items: flex-start; }
.field { display: flex; flex-direction: column; gap: var(--s2); width: 100%; }
.field-label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.input {
  font: inherit; font-size: 16px; /* never below 16px: iOS zooms the page otherwise */
  width: 100%; max-width: 22rem; min-height: 48px; padding: 12px 14px;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--edge); border-radius: var(--r-ctl);
}
.input:focus-visible { border-color: var(--signal); }
.input-code {
  font-family: var(--mono); font-size: 24px; letter-spacing: .34em;
  max-width: 11rem; text-align: center;
}
.turnstile-slot:empty { display: none; }
.formerror { color: var(--sev-critical); font-size: 14.5px; }
.formerror[hidden] { display: none; }
.fineprint { color: var(--ink-3); font-size: 14px; margin-top: var(--s3); }
.quietrow { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s3); }
.linkbtn {
  font: inherit; font-size: 14.5px; background: none; border: 0; padding: 8px 0;
  min-height: 44px; color: var(--signal); cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px;
}
.linkbtn[disabled] { color: var(--ink-3); cursor: default; text-decoration: none; }
.btn-danger { background: var(--card); color: var(--sev-critical); border-color: var(--sev-critical); }
.btn-danger:hover { background: var(--sev-critical); color: var(--card); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--edge); padding: var(--s7) 0 var(--s8); color: var(--ink-3); font-size: 14px; }
.foot .wrap { display: flex; flex-wrap: wrap; gap: var(--s4); justify-content: space-between; }
.foot a { color: var(--ink-2); }
.footnav { display: flex; flex-wrap: wrap; gap: var(--s4); }
.footnav a { text-decoration: underline; text-underline-offset: 3px; }
.footnav a:hover { color: var(--ink); }

/* ---------- folds ---------- */
.fold {
  background: var(--card); border: 1px solid var(--edge); border-radius: var(--r-card);
  padding: var(--s4) var(--s5); box-shadow: var(--shadow); margin-bottom: var(--s4);
}
/* Grid, not flex: with wrapping the chevron dropped onto the second line and
   sat under the description instead of beside the title it opens. */
.fold summary {
  cursor: pointer; list-style: none;
  display: grid; grid-template-columns: 1fr auto; column-gap: var(--s3); row-gap: var(--s1);
  align-items: start; min-height: 44px; padding: var(--s2) 0;
}
.fold summary::-webkit-details-marker { display: none; }
.fold summary::after {
  content: ''; grid-column: 2; grid-row: 1; margin-top: 6px;
  width: 9px; height: 9px;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg); transition: transform .16s ease;
}
.fold[open] summary::after { transform: rotate(-135deg); margin-top: 10px; }
.foldtitle {
  grid-column: 1; grid-row: 1;
  font-family: var(--display); font-size: 17px; font-weight: 600; letter-spacing: -.01em;
}
.foldnote { grid-column: 1 / -1; grid-row: 2; color: var(--ink-3); font-size: 14px; }

/* ---------- the published rubric ---------- */
.rubric-title {
  font-family: var(--display); font-size: clamp(22px, 3vw, 28px); font-weight: 600;
  letter-spacing: -.02em; margin-top: var(--s7);
}
.rubric-note { color: var(--ink-3); font-size: 14.5px; }
.rubric dl { display: grid; gap: var(--s3); margin: var(--s3) 0 0; }
.rubric dt {
  font-family: var(--mono); font-size: 12.5px; color: var(--ink-3);
  display: flex; align-items: baseline; gap: var(--s2); flex-wrap: wrap;
}
.rubric dt span {
  color: var(--signal); background: var(--signal-soft); border: 1px solid var(--signal-edge);
  border-radius: 999px; padding: 1px 9px; font-size: 11.5px;
}
.rubric dd { margin: 2px 0 0; font-size: 15px; color: var(--ink-2); }

/* ---------- small utilities (so no element needs a style attribute) ---------- */
.mt-5 { margin-top: var(--s5); }
.section, [id] { scroll-margin-top: 76px; }

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
