/* Inventarc brand tokens and motion system.
   Family: Holarc, Finarc, Arca. Fraunces for display, Public Sans for text.
   Every color is a token; nothing hard-codes a hex outside this file. */

:root {
  color-scheme: light;

  /* Surfaces */
  --paper:      #F7F5F0;   /* page */
  --paper-2:    #FFFFFF;   /* cards */
  --paper-3:    #EFEBE2;   /* wells, rails */
  --ink:        #101722;   /* primary text, dark surfaces */
  --ink-2:      #3A4654;   /* secondary text */
  --ink-3:      #5E6977;   /* tertiary, captions — 5.1:1 on paper, 4.7:1 on the wells */
  --line:       #DCD6C9;   /* hairlines on paper */
  --line-dark:  rgba(247,245,240,.16);

  /* Brand */
  --brass:      #C9962E;   /* the idea, the spark, the active state */
  --brass-2:    #E7BC5C;   /* brass highlight */
  --brass-ink:  #6A4C0E;   /* brass text on light */
  --teal:       #1F6F6B;   /* verified, cleared, done */
  --teal-2:     #2E938D;
  --clay:       #B2503C;   /* risk, flag, blocked */
  --clay-2:     #D2715C;
  --slate:      #3E5E86;   /* informational, links */

  /* The rail and Leonardo's button are the brand's dark anchor and look the same
     in both themes. They get tokens of their own, fixed rather than derived from
     --ink and --paper, which invert. Deriving them is what made the rail
     illegible in dark mode. */
  --rail-bg:        #101722;
  --rail-ink:       #E4DFD3;   /* 12.4:1 on --rail-bg */
  --rail-ink-dim:   #A9A294;   /*  6.1:1 */
  --rail-ink-faint: #8E8778;   /*  4.6:1, headings and captions only */
  --rail-hair:      rgba(228,223,211,.12);
  --rail-on-bg:     rgba(201,150,46,.20);
  --rail-on-ink:    #F6E3B4;   /* 11.2:1 */

  /* Type */
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --text: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, monospace;

  /* Space and shape */
  --rail: 268px;           /* fixed left navigation width */
  --gut: 24px;
  --radius: 10px;
  --radius-lg: 16px;
  /* The drawing board. Minor and major rules in the 1:5 ratio of real
     engineering paper; the major lines are what make it read as paper
     rather than as noise. */
  --grid-minor: rgba(16, 23, 34, .045);
  --grid-major: rgba(16, 23, 34, .085);
  --shadow-1: 0 1px 2px rgba(16,23,34,.06), 0 2px 8px rgba(16,23,34,.05);
  --shadow-2: 0 2px 6px rgba(16,23,34,.08), 0 12px 32px rgba(16,23,34,.10);

  /* Motion. Durations are short on purpose; nothing blocks the page. */
  --t-fast: 140ms;
  --t: 240ms;
  --t-slow: 520ms;
  --ease: cubic-bezier(.22,.61,.36,1);
  --ease-out: cubic-bezier(.16,1,.3,1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper:   #0C1118;
    --paper-2: #141C27;
    --paper-3: #1B2430;
    --ink:     #EDE8DD;
    --ink-2:   #B3BCC8;
    --ink-3:   #8290A0;
    --line:    rgba(237,232,221,.14);
    --grid-minor: rgba(237, 232, 221, .035);
    --grid-major: rgba(237, 232, 221, .07);
    --brass-ink: var(--brass-2);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 2px 6px rgba(0,0,0,.45), 0 16px 40px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper:   #0C1118;
  --paper-2: #141C27;
  --paper-3: #1B2430;
  --ink:     #EDE8DD;
  --ink-2:   #B3BCC8;
  --ink-3:   #8290A0;
  --line:    rgba(237,232,221,.14);
  --grid-minor: rgba(237, 232, 221, .035);
  --grid-major: rgba(237, 232, 221, .07);
  --brass-ink: var(--brass-2);
}


/* ------------------------------------------------------- the drawing board

   The page is the surface an inventor would draw on, so the substrate is
   engineering paper: a minor rule every 16px and a major every fifth line,
   the 1:5 ratio of the real thing. A single flat grid reads as noise; it is
   the major lines that make it read as paper.

   It is weighted rather than uniform. At full strength across the page it
   would sit under every paragraph, and text over ruled lines is harder to
   read for everyone and markedly harder for some. So the grid is masked:
   present at the edges, where it is atmosphere, and gone behind the middle
   where the words are. That one decision is also what gives the page depth,
   rather than reaching for a second effect to supply it.

   Drawn on its own fixed layer behind everything, so it never repaints with
   the content and never intercepts a click. */
body::before {
  content: '';
  position: fixed;
  /* Spans the content area only, starting where the fixed rail ends, so the
     mask percentages below measure the reading area rather than the window.
     Overscanned top and bottom so the drift never reveals an edge. */
  inset: -10vh 0 -10vh var(--rail);
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(to right,  var(--grid-major) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-major) 1px, transparent 1px),
    linear-gradient(to right,  var(--grid-minor) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-minor) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;

  /* The board shows beside the sheet, never under it.

     A grid at even strength across the page puts ruled lines under every
     paragraph. That is harder to read for everyone and markedly harder for
     some, and no amount of lowering the opacity makes it free. So the grid
     is absent across the measure where the words are and appears to the
     right of it, which is also the truer picture: a sheet laid on a drawing
     board, with the board visible past its edge. */
  -webkit-mask-image: linear-gradient(to right,
     transparent 0%, transparent 58%,
     rgba(0,0,0,.45) 72%, rgba(0,0,0,1) 88%, rgba(0,0,0,1) 100%);
          mask-image: linear-gradient(to right,
     transparent 0%, transparent 58%,
     rgba(0,0,0,.45) 72%, rgba(0,0,0,1) 88%, rgba(0,0,0,1) 100%);
}

/* The board sits still while the sheet moves over it. One effect, driven by
   the reader's own scrolling rather than played at them, and only where the
   browser can do it without script. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    body::before {
      animation: board-drift linear both;
      animation-timeline: scroll();
    }
    @keyframes board-drift {
      from { transform: translateY(0); }
      to   { transform: translateY(-6vh); }
    }
  }
}

/* Below this width the rail collapses and the text uses the full measure,
   so there is no margin for the board to show in. It goes away rather than
   being faded under the words. */
@media (max-width: 1100px) {
  body::before { display: none; }
}

/* Anyone who has asked their system for more contrast is told, by that
   setting, that subtle texture is not working for them. */
@media (prefers-contrast: more) {
  body::before { display: none; }
}

/* ---------------------------------------------------------- base */

* { box-sizing: border-box; }
/* Components below set display explicitly, which would otherwise defeat the
   hidden attribute the app uses to gate steps and the signed-out state. */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.62 var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4 { font-family: var(--display); font-weight: 500; line-height: 1.18; margin: 0 0 .5em; letter-spacing: -.012em; }
h1 { font-size: clamp(2rem, 1.3rem + 2.4vw, 3.1rem); }
h2 { font-size: clamp(1.45rem, 1.1rem + 1.3vw, 2.05rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--slate); text-underline-offset: 3px; }
small, .small { font-size: .875rem; }
.muted { color: var(--ink-3); }
.lede { font-size: 1.14rem; color: var(--ink-2); max-width: 62ch; }

/* ---------------------------------------------------------- the mark */

.mark { display: block; }
.mark .page   { fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }
.mark .arc    { fill: none; stroke: var(--brass); stroke-width: 2.8; stroke-linecap: round; }
.mark .spark  { fill: var(--brass); }
.mark .rule   { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; opacity: .42; }

/* The mark draws itself: the spark appears, the arc sweeps, the page rules fill in. */
.mark.draw .arc {
  stroke-dasharray: var(--arc-len, 120);
  stroke-dashoffset: var(--arc-len, 120);
  animation: arc-draw 900ms var(--ease-out) 120ms forwards;
}
.mark.draw .page {
  stroke-dasharray: 240; stroke-dashoffset: 240;
  animation: arc-draw 760ms var(--ease-out) forwards;
}
.mark.draw .spark { transform-origin: 13px 42px; animation: spark-in 420ms var(--ease-out) 80ms backwards; }
.mark.draw .rule  { stroke-dasharray: 40; stroke-dashoffset: 40; animation: arc-draw 420ms var(--ease) forwards; }
.mark.draw .rule:nth-of-type(1) { animation-delay: 740ms; }
.mark.draw .rule:nth-of-type(2) { animation-delay: 830ms; }
.mark.draw .rule:nth-of-type(3) { animation-delay: 920ms; }

@keyframes arc-draw { to { stroke-dashoffset: 0; } }
@keyframes spark-in { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.wordmark {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: -.02em;
  font-size: 1.32rem;
  color: var(--ink);
}
.wordmark .arcsyl { color: var(--brass-ink); }

/* ---------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  font: 600 .95rem/1 var(--text);
  padding: .78em 1.25em;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--ink); color: var(--paper);
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t) var(--ease), background var(--t) var(--ease);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.brass { background: var(--brass); color: #1A1204; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper-3); }
.btn.sm { padding: .55em .9em; font-size: .86rem; }

/* ---------------------------------------------------------- forms */

label.field { display: block; margin: 0 0 1rem; }
label.field > span { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .34rem; }
input[type=text], input[type=email], input[type=password], input[type=tel], textarea, select {
  width: 100%; padding: .72em .85em;
  font: 400 1rem/1.4 var(--text);
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brass);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass) 22%, transparent);
}
textarea { min-height: 7.5rem; resize: vertical; }
.hint { font-size: .84rem; color: var(--ink-3); margin-top: .3rem; }
.err { color: var(--clay); font-size: .88rem; margin-top: .35rem; }

.check { display: flex; gap: .7rem; align-items: flex-start; margin: .9rem 0; }
.check input { margin-top: .28rem; width: 18px; height: 18px; accent-color: var(--brass); flex: 0 0 auto; }
.check span { font-size: .95rem; }

/* ---------------------------------------------------------- cards, wells */

.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.4rem 1.5rem;
  box-shadow: var(--shadow-1);
}
.well { background: var(--paper-3); border-radius: var(--radius); padding: 1rem 1.15rem; }

/* Disclosure block: a standing, visible statement, never a footnote. */
.disclosure {
  border-left: 3px solid var(--brass);
  background: color-mix(in srgb, var(--brass) 7%, transparent);
  padding: .85rem 1rem; border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .92rem; color: var(--ink-2);
  margin: 1rem 0;
}
.disclosure strong { color: var(--ink); }
.disclosure.flag { border-left-color: var(--clay); background: color-mix(in srgb, var(--clay) 7%, transparent); }
.disclosure.clear { border-left-color: var(--teal); background: color-mix(in srgb, var(--teal) 7%, transparent); }

.pill {
  display: inline-flex; align-items: center; gap: .4em;
  font: 600 .74rem/1 var(--text); letter-spacing: .04em; text-transform: uppercase;
  padding: .42em .7em; border-radius: 999px;
  background: var(--paper-3); color: var(--ink-2);
}
.pill.brass { background: color-mix(in srgb, var(--brass) 18%, transparent); color: var(--brass-ink); }
.pill.teal  { background: color-mix(in srgb, var(--teal) 16%, transparent);  color: var(--teal); }
.pill.clay  { background: color-mix(in srgb, var(--clay) 16%, transparent);  color: var(--clay); }

/* ---------------------------------------------------------- motion utilities */

/* Rise: content settles into place as it enters the viewport. */
.rise { opacity: 0; transform: translateY(14px); transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out); }
.rise.in { opacity: 1; transform: none; }
.rise.d1 { transition-delay: 70ms; } .rise.d2 { transition-delay: 140ms; }
.rise.d3 { transition-delay: 210ms; } .rise.d4 { transition-delay: 280ms; }

/* Count: a number ticking up, used on the review checks. */
@keyframes tick-in { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* Pulse: Leonardo listening. */
@keyframes listen { 0%,100% { transform: scale(1); opacity: .55; } 50% { transform: scale(1.5); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .rise { opacity: 1; transform: none; }
  .mark.draw .arc, .mark.draw .page, .mark.draw .rule { stroke-dashoffset: 0; }
}
