/* =========================================================================
   Clawso · E · Design Tokens (v2 — light, technical, spacious)
   Reference posture: accio.com — small tech type, generous whitespace,
   single restrained accent. Brand colour: claw amber #eb7b2d.
   ========================================================================= */

@import url("https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500&family=Fraunces:ital,opsz,wght@1,9..144,400;1,9..144,500&display=swap");

:root {
  /* ---- surface (light, slightly warm — never pure white) */
  --paper:        #fafaf7;   /* primary surface */
  --paper-2:      #f4f2ed;   /* alternating section tone */
  --paper-3:      #ecebe5;   /* recessed input surface */
  --paper-card:   #ffffff;   /* lifted cards (rare) */

  /* ---- ink (text + the one dark surface used for hero pull-quotes) */
  --ink:          #15161d;   /* primary text — matches logo "so" */
  --ink-soft:     #4a4c57;   /* secondary text */
  --ink-quiet:    #84858f;   /* tertiary text, mono labels */
  --ink-faint:    #b6b6bd;   /* placeholder, disabled */

  /* ---- rule (always near-invisible) */
  --rule:         rgba(21,22,29,0.08);
  --rule-soft:    rgba(21,22,29,0.05);
  --rule-strong:  rgba(21,22,29,0.16);

  /* ---- ember (claw — singular, used sparingly) */
  --ember:        #eb7b2d;
  --ember-bright: #ff9243;
  --ember-deep:   #b85a13;
  --ember-tint:   rgba(235,123,45,0.08);

  /* ---- semantic (kept quiet) */
  --info:         #3f6f9f;
  --leaf:         #5a8c4f;
  --rust:         #a8472b;

  /* ---- type */
  --sans:    "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  --mono:    "Geist Mono", ui-monospace, "JetBrains Mono", monospace;
  --serif:   "Fraunces", "Times New Roman", serif;  /* used only for one italic accent */

  /* ---- type metrics (small + technical) */
  --t-mono-eyebrow: 11px;
  --t-mono-label:   11px;
  --t-body-sm:      13px;
  --t-body:         14px;
  --t-body-lg:      15px;
  --t-h4:           18px;
  --t-h3:           22px;
  --t-h2:           32px;
  --t-h1:           clamp(40px, 5.2vw, 64px);

  --tracking-display: -0.022em;
  --tracking-tight:   -0.012em;
  --tracking-mono:     0.02em;
  --tracking-eyebrow:  0.12em;

  /* ---- rhythm (generous) */
  --gutter:        clamp(20px, 5vw, 56px);
  --section-y:     clamp(80px, 12vw, 160px);
  --content:       1180px;
  --content-narrow: 880px;
  --baseline:      24px;

  /* ---- shape */
  --radius-xs:     2px;
  --radius-sm:     4px;
  --radius:        6px;
  --radius-lg:     10px;
  --radius-xl:     16px;

  /* ---- motion */
  --ease:          cubic-bezier(0.2, 0.7, 0.1, 1);
  --ease-out:      cubic-bezier(0, 0, 0.2, 1);
  --t-fast:        160ms;
  --t-base:        240ms;
  --t-slow:        420ms;
}

/* =========================================================================
   Resets — calm, tight defaults
   ========================================================================= */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-feature-settings: "ss01", "ss03", "cv01", "cv11";
  font-size: var(--t-body);
  line-height: 1.55;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

::selection { background: var(--ember); color: var(--paper); }

/* =========================================================================
   Signature primitives — small, restrained
   ========================================================================= */

/* eyebrow — small mono caps with a quiet leader dot */
.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-mono-eyebrow);
  font-weight: 400;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--ink-quiet);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--ember);
  border-radius: 50%;
  flex-shrink: 0;
}
.eyebrow.dark { color: var(--ink); }

/* claw-mark — three thin slashes, the brand motif (small by default) */
.claw-mark {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 14px;
}
.claw-mark span {
  display: block;
  width: 2px;
  height: 14px;
  background: var(--ember);
  transform: skewX(-18deg);
}
.claw-mark span:nth-child(2) { background: var(--ember-bright); height: 16px; }
.claw-mark span:nth-child(3) { background: var(--ember-deep); height: 12px; }
.claw-mark.lg { height: 22px; gap: 4px; }
.claw-mark.lg span { width: 3px; height: 22px; }
.claw-mark.lg span:nth-child(2) { height: 26px; }
.claw-mark.lg span:nth-child(3) { height: 18px; }

/* serif italic — one display flourish, used sparingly */
.flair {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  letter-spacing: -0.012em;
}

/* btn — small, technical, pill-less */
.btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--paper);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-size: var(--t-body-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  background: var(--btn-bg);
  color: var(--btn-fg);
  padding: 10px 16px;
  border: 1px solid var(--btn-bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}
.btn:hover { background: #000; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .arrow {
  font-size: 12px;
  transition: transform var(--t-fast) var(--ease);
}
.btn:hover .arrow { transform: translateX(2px); }

.btn.ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  border-color: var(--rule-strong);
}
.btn.ghost:hover { background: var(--paper-2); border-color: var(--ink); transform: none; }

.btn.ember {
  --btn-bg: var(--ember);
  --btn-fg: var(--ink);
}
.btn.ember:hover { background: var(--ember-bright); }

/* link — minimal underline-on-hover */
.link {
  position: relative;
  color: var(--ink);
  font-weight: 500;
  font-size: var(--t-body-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color var(--t-fast) var(--ease);
}
.link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--t-base) var(--ease);
}
.link:hover::after { transform: scaleX(1); }

/* tag — small mono */
.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: var(--tracking-mono);
  text-transform: uppercase;
  color: var(--ink-quiet);
  padding: 3px 7px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-xs);
  display: inline-block;
  line-height: 1.2;
}
.tag.ember { color: var(--ember); border-color: var(--ember); }
.tag.solid { background: var(--paper-3); border-color: transparent; }

/* kbd — keyboard hint */
.kbd {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: var(--tracking-mono);
  padding: 2px 5px;
  border: 1px solid var(--rule-strong);
  border-bottom-width: 2px;
  border-radius: 3px;
  color: var(--ink-quiet);
  background: var(--paper);
}

/* dot — status pip */
.pip {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--leaf);
  display: inline-block;
  flex-shrink: 0;
}
.pip.run { background: var(--ember); animation: pulse 1.6s infinite ease-in-out; }
.pip.idle { background: var(--ink-faint); }
.pip.fail { background: var(--rust); }

@keyframes pulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.25); }
}

/* utility — generous spacing */
.container { max-width: var(--content); margin: 0 auto; padding: 0 var(--gutter); }
.narrow { max-width: var(--content-narrow); margin: 0 auto; padding: 0 var(--gutter); }

/* fade-up — single subtle entrance */
.fade-up { opacity: 0; transform: translateY(12px); animation: fadeUp 700ms var(--ease) forwards; }
.delay-1 { animation-delay: 80ms; }
.delay-2 { animation-delay: 160ms; }
.delay-3 { animation-delay: 240ms; }
.delay-4 { animation-delay: 320ms; }
@keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   Dark mode — a quiet inversion, not a re-skin.
   Posture: same restraint as light. Surface is warm-black graphite (never
   pure #000), text is warm off-white (never pure #fff), ember keeps its
   weight without glowing, rules stay near-invisible. The brand stays.
   ========================================================================= */
[data-theme="dark"] {
  /* Aligned to N-02 (packages/design-system/src/tokens.css, PR #197) — the
     v3 client design-system package is the canonical source of truth for
     dark values. Edit there first; mirror here. */
  /* F-43: tell the WebView's UA stylesheet to use dark form-control colors
     for native widgets (datalist autocomplete dropdowns, scrollbars, the
     select arrow). Without this, Tauri's WebKit shows a near-invisible
     dark-on-dark autocomplete popup in dark mode — only --ink-* var-driven
     CSS adapts, and native controls ignore CSS vars by design. */
  color-scheme: dark;

  --paper:        #15161d;
  --paper-2:      #1c1d23;
  --paper-3:      #25262d;
  --paper-card:   #101116;   /* recessed — darker than paper */

  --ink:          #fafaf7;
  --ink-soft:     #d5d3cc;
  --ink-quiet:    #a4a29b;
  --ink-faint:    #73736d;

  --rule:         rgba(250,250,247,0.10);
  --rule-soft:    rgba(250,250,247,0.06);
  --rule-strong:  rgba(250,250,247,0.20);

  --ember:        #eb7b2d;   /* unchanged from light — brand fixed */
  --ember-bright: #ff9243;
  --ember-deep:   #b85a13;
  --ember-tint:   rgba(235,123,45,0.14);

  --leaf:         #79a86e;
  --info:         #7ca7cf;
  --rust:         #c56044;
}

/* dark-mode body inherits from base; nothing else to override since vars cascade */
[data-theme="dark"] body {
  color: var(--ink);
  background: var(--paper);
}

/* selection — flip so ember stays the highlight, ink reads on it */
[data-theme="dark"] ::selection { background: var(--ember); color: var(--paper); }

/* primary button — invert to light surface so ember CTA still reads as "the one accent" */
[data-theme="dark"] .btn {
  --btn-bg: var(--ink);
  --btn-fg: var(--paper);
}
[data-theme="dark"] .btn:hover { background: #ffffff; }
[data-theme="dark"] .btn.ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink);
  border-color: var(--rule-strong);
}
[data-theme="dark"] .btn.ghost:hover { background: var(--paper-2); border-color: var(--ink); }
[data-theme="dark"] .btn.ember {
  --btn-bg: var(--ember);
  --btn-fg: var(--paper);  /* ink-on-ember would crush; paper-on-ember reads */
}

/* kbd — keyboard hint sits on paper-3 in dark for separation */
[data-theme="dark"] .kbd { background: var(--paper-3); color: var(--ink-soft); }

/* tag.solid — paper-3 already adapts via var, but ensure border still hides */
[data-theme="dark"] .tag.solid { background: var(--paper-3); }

/* =========================================================================
   Auto mode — opt-in via [data-theme="auto"]. Falls through to dark tokens
   when the OS prefers dark. Apps that ship light/dark only can ignore this.
   ========================================================================= */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    color-scheme: dark; /* F-43: same as explicit dark theme above */
    --paper:        #15161d;
    --paper-2:      #1c1d23;
    --paper-3:      #25262d;
    --paper-card:   #101116;
    --ink:          #fafaf7;
    --ink-soft:     #d5d3cc;
    --ink-quiet:    #a4a29b;
    --ink-faint:    #73736d;
    --rule:         rgba(250,250,247,0.10);
    --rule-soft:    rgba(250,250,247,0.06);
    --rule-strong:  rgba(250,250,247,0.20);
    --ember:        #eb7b2d;
    --ember-bright: #ff9243;
    --ember-deep:   #b85a13;
    --ember-tint:   rgba(235,123,45,0.14);
    --leaf:         #79a86e;
    --info:         #7ca7cf;
    --rust:         #c56044;
  }
}
