/* Arklive design tokens.
   Ledger paper: pale rule lines, deep teal for anything held, copper for
   anything to watch, brick for anything wrong.
   Every tool imports this first. Don't redefine these locally — extend them. */

/* ── LIGHT AND DARK ───────────────────────────────────────────────────
   Each token is declared twice: a flat light value, then the same token
   as light-dark(). A browser without light-dark() keeps the first and
   renders the light theme; everything current takes the second and
   follows the reader. There is one declaration per token either way, so
   the two themes cannot drift apart the way parallel blocks do.

   Which theme applies:
     no attribute            follow the operating system
     data-theme="light"      force light
     data-theme="dark"       force dark
   shared/lib/theme.js sets the attribute and remembers the choice.
   color-scheme carries it into form controls and scrollbars too.

   The dark signal colours are NOT the light ones dimmed — they are
   lifted, because they now sit on a dark ground and have to clear AA
   against it rather than against paper. Verified figures are below.
   ─────────────────────────────────────────────────────────────────── */
:root{
  color-scheme: light dark;

  /* surface */
  --paper:      #F1F3EE;
  --paper:      light-dark(#F1F3EE, #0E1614);
  --paper-alt:  #E7EBE5;
  --paper-alt:  light-dark(#E7EBE5, #16211E);
  --paper-card: #FFFFFF;
  --paper-card: light-dark(#FFFFFF, #131E1B);
  --rule:       #C1CFC9;
  --rule:       light-dark(#C1CFC9, #2C3B36);

  /* ink */
  --ink:        #14211D;
  --ink:        light-dark(#14211D, #E9EEEA);
  --ink-soft:   #55675F;
  --ink-soft:   light-dark(#55675F, #9BAEA7);
  /* hover state of an ink surface — darker in light, dimmer in dark,
     because an ink surface is a light chip once the theme flips */
  --ink-lift:   #24352E;
  --ink-lift:   light-dark(#24352E, #CBD5D0);

  /* semantic — these carry meaning, not decoration.
     seal  = locked, healthy, constrained
     amber = watch it
     flag  = free to move, thin, broken, wrong

     Measured against every surface these sit on — paper, card and paper-alt.
     Worst case of the three, all clearing WCAG AA (4.5:1) for body text:
       light   seal 8.1 · amber 4.6 · flag 5.9 · ink 13.8 · ink-soft 5.0
       dark    seal 7.8 · amber 7.8 · flag 5.7 · ink 14.1 · ink-soft 7.1
     Amber is the tight one in light: it was drawn a shade deeper than a
     display copper so it still passes on paper-alt. Lighten it and it fails. */
  --seal:       #0F4C4A;
  --seal:       light-dark(#0F4C4A, #56C3B6);
  --amber:      #945B0A;
  --amber:      light-dark(#945B0A, #E0A94A);
  --flag:       #A32C1C;
  --flag:       light-dark(#A32C1C, #F0705C);

  /* type */
  --font-display: "IBM Plex Sans Condensed", system-ui, sans-serif;
  --font-body:    "IBM Plex Serif", Georgia, serif;
  --font-data:    "IBM Plex Mono", ui-monospace, monospace;

  /* scale */
  --pad:      clamp(16px, 3vw, 34px);
  --gap:      14px;
  --rule-w:   1px;
}

/* These two rules are what makes data-theme mean anything. light-dark() reads
   the used color-scheme, so narrowing the scheme to one option is what forces
   a theme — setting the attribute alone changes nothing. */
:root[data-theme="light"]{ color-scheme: only light }
:root[data-theme="dark"] { color-scheme: only dark }

/* ── ROLLBACK ──────────────────────────────────────────────────────────
   Everything replaced in the refresh is kept below, inert, behind an
   attribute. To restore the original look, add the attribute to the <html>
   tag of any page — nothing else needs touching:

     <html lang="en" data-palette="legacy">   original navy / oxblood
     <html lang="en" data-layout="legacy">    pre-bento mobile stacking

   Both may be set at once, and both compose with data-theme. Remove the
   attribute to return to current. The layout rollback lives with the layout
   rules it undoes: in this file at the foot, and in each tool's <style>.
   ──────────────────────────────────────────────────────────────────── */
:root[data-palette="legacy"]{
  --paper:      #F2F4EF;
  --paper:      light-dark(#F2F4EF, #10171A);
  --paper-alt:  #E9EDE5;
  --paper-alt:  light-dark(#E9EDE5, #182126);
  --paper-card: #FFFFFF;
  --paper-card: light-dark(#FFFFFF, #141D21);
  --rule:       #C3D0C0;
  --rule:       light-dark(#C3D0C0, #2E3B3D);

  --ink:        #1B2A24;
  --ink:        light-dark(#1B2A24, #E8EDEA);
  --ink-soft:   #5A6B62;
  --ink-soft:   light-dark(#5A6B62, #9AACA5);
  --ink-lift:   #2E4238;
  --ink-lift:   light-dark(#2E4238, #CAD4CF);

  --seal:       #1F4B7A;
  --seal:       light-dark(#1F4B7A, #79B0E0);
  --amber:      #8A6A12;
  --amber:      light-dark(#8A6A12, #D8B84E);
  --flag:       #8C2A1E;
  --flag:       light-dark(#8C2A1E, #E8836F);
}

*{ box-sizing: border-box }
html,body{ margin:0; padding:0 }

body{
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* nothing should ever push the page sideways */
  overflow-x: hidden;
}

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

/* eyebrow / section labels */
.eyebrow{
  font-family: var(--font-data);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

h2.sec{
  font-size: 12px;
  font-family: var(--font-data);
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  border-bottom: var(--rule-w) solid var(--ink);
  padding-bottom: 6px;
  margin: 34px 0 14px;
}

/* controls */
input[type=text],input[type=number],select{
  font-family: var(--font-data);
  font-size: 13px;
  padding: 9px 10px;
  border: var(--rule-w) solid var(--rule);
  background: var(--paper-card);
  color: var(--ink);
  border-radius: 0;
  width: 100%;
}
input:focus,select:focus{ outline: 2px solid var(--seal); outline-offset: -1px }

button{
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  background: var(--ink);
  color: var(--paper);
  border: var(--rule-w) solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: background .12s;
}
button:hover{ background: var(--ink-lift) }
button:focus-visible{ outline: 2px solid var(--seal); outline-offset: 2px }
button.ghost{ background: transparent; color: var(--ink) }
button.ghost:hover{ background: var(--rule) }
button:disabled{ opacity: .45; cursor: not-allowed }

label{
  font-family: var(--font-data);
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hint{
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-soft);
  margin: 10px 0 0;
  max-width: 80ch;
}
.hint code{
  font-family: var(--font-data);
  font-size: 12px;
  background: var(--paper-card);
  padding: 1px 4px;
  border: var(--rule-w) solid var(--rule);
}

a{ color: var(--seal) }

/* semantic value colouring — consistent across every tool */
.v-bad { color: var(--flag);  font-weight: 600 }
.v-warn{ color: var(--amber); font-weight: 600 }
.v-good{ color: var(--seal);  font-weight: 600 }
.v-dim { color: var(--ink-soft) }

.legend{
  display: flex; flex-wrap: wrap; gap: 16px;
  font-family: var(--font-data);
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-soft); margin: 0 0 14px;
}
.legend span::before{
  content:''; display:inline-block; width:9px; height:9px;
  margin-right:6px; vertical-align:middle;
}
.legend .lg::before{ background: var(--seal) }
.legend .lw::before{ background: var(--amber) }
.legend .lb::before{ background: var(--flag) }

/* data tables */
table.ledger{
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-data);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
table.ledger th{
  text-align: left;
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); font-weight: 500;
  padding: 6px 10px 6px 0;
  border-bottom: var(--rule-w) solid var(--ink);
}
table.ledger td{
  padding: 5px 9px 5px 0;
  border-bottom: var(--rule-w) solid var(--rule);
  vertical-align: top;
  /* break only where a line would otherwise overflow, not every character */
  overflow-wrap: anywhere;
}
table.ledger td.num, table.ledger th.num{
  text-align: right; padding-right: 0; white-space: nowrap;
}
table.ledger tr:nth-child(even) td{ background: rgba(193,207,201,.20) }

/* A wide table stays a table on a narrow screen — it scrolls sideways in its
   own box rather than being crushed. Wrap one in .scrollx to opt in. */
.scrollx{ overflow-x: auto; -webkit-overflow-scrolling: touch }
.scrollx > table{ min-width: 520px }

/* panels */
.panel{
  background: var(--paper-alt);
  border: var(--rule-w) solid var(--rule);
  padding: 16px;
  margin-bottom: 20px;
}
.row{ display:flex; flex-wrap:wrap; gap: var(--gap); align-items: flex-end }
.field{ display:flex; flex-direction:column; gap:5px; flex:1 1 240px; min-width:0 }

.empty{
  font-family: var(--font-body);
  font-style: italic;
  color: var(--ink-soft);
  border: 1px dashed var(--rule);
  padding: 22px; text-align: center; font-size: 14px;
}

.status{
  font-family: var(--font-data);
  font-size: 11.5px; color: var(--ink-soft);
  margin: 0 0 12px; min-height: 17px;
}

/* the finding stamp — Arklive's signature element.
   A verdict in plain language, stamped like a clerk approved it. */
.stamp{
  display: inline-block;
  font-family: var(--font-data);
  font-size: 11px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  border: 1.5px solid currentColor;
  padding: 4px 9px; margin-bottom: 9px;
  transform: rotate(-1.1deg);
}

@media (prefers-reduced-motion: reduce){ *{ transition: none !important } }

@media (max-width: 620px){
  .stamp{ transform: none }
  /* touch targets: a 10px button is not tappable */
  button{ min-height: 44px }
  .row{ gap: 10px }
}
