/* ============================================================
   Fiber Knight, design tokens and page chrome.

   This sheet holds only what the single page uses: the palettes, the
   background, the corner mark, the theme toggle and the footer. The
   tool's own styling is inline in index.html under the dm- prefix.

   THEME
   -----
   Three states, and all three must work:
     :root                              light (the complete palette)
     :root:not([data-theme="light"]) under prefers-color-scheme: dark
     :root[data-theme="dark"]           explicit choice, wins either way
   Every colour gets its definition in the bare :root block. The dark
   blocks only REdefine tokens. Never introduce one there, or the light
   theme is left with an undefined variable.
   ============================================================ */
:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1c2a33;
  --ink-soft: #5b6b74;
  --line: #dce3e7;
  --accent: #0f6e8c;
  --accent-soft: #e4f1f6;
  --ok: #1a7f4e;
  --ok-soft: #e6f5ec;
  --warn: #a8631a;
  --warn-soft: #fbf0e1;
  --err: #b3312c;
  --err-soft: #fbe8e7;

  /* Surface one step back from --panel: inputs, logs, table stripes. */
  --ink-3: #f7fafb;
  --steel: var(--ink-soft);

  /* Text sitting ON a solid --accent / --err / --warn fill. In dark those
     three are LIGHT colours, so white text on them is unreadable. This
     flips to near-black there. Never hard-code #fff on a filled chip. */
  --on-accent: #ffffff;

  --shadow: 0 1px 2px rgba(20, 35, 45, .06), 0 4px 14px rgba(20, 35, 45, .05);
  --glow-a: rgba(15, 110, 140, 0.07);
  --glow-b: rgba(26, 127, 78, 0.05);
  --glow-ring: rgba(92, 105, 120, 0.035);

  --mono: "DM Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: var(--body);

  --radius: 10px;
  --max-w: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10171c;
    --panel: #172127;
    --ink: #e6edf1;
    --ink-soft: #93a4ae;
    --line: #2a3841;
    --accent: #58b6d2;
    --accent-soft: #15323d;
    --ok: #4cc38a;
    --ok-soft: #122c20;
    --warn: #e0a458;
    --warn-soft: #33260f;
    --err: #f2726c;
    --err-soft: #3a1a19;

    --ink-3: #0e161a;
    --on-accent: #0b1418;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --glow-a: rgba(88, 182, 210, 0.06);
    --glow-b: rgba(76, 195, 138, 0.045);
    --glow-ring: rgba(148, 170, 186, 0.03);
  }
}

:root[data-theme="dark"] {
  --bg: #10171c;
  --panel: #172127;
  --ink: #e6edf1;
  --ink-soft: #93a4ae;
  --line: #2a3841;
  --accent: #58b6d2;
  --accent-soft: #15323d;
  --ok: #4cc38a;
  --ok-soft: #122c20;
  --warn: #e0a458;
  --warn-soft: #33260f;
  --err: #f2726c;
  --err-soft: #3a1a19;

  --ink-3: #0e161a;
  --on-accent: #0b1418;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --glow-a: rgba(88, 182, 210, 0.06);
  --glow-b: rgba(76, 195, 138, 0.045);
  --glow-ring: rgba(148, 170, 186, 0.03);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  color-scheme: light dark;
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle at 18% 20%, var(--glow-a), transparent 38%),
    radial-gradient(circle at 82% 78%, var(--glow-b), transparent 42%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0, transparent 72px, var(--glow-ring) 73px, transparent 74px);
}

a { color: inherit; }

/* ============================================================
   Fixed corner mark (top-left). Not a link. There is nowhere to
   go from here; this page is the whole tool.
   ============================================================ */
.corner-mark {
  position: fixed;
  z-index: 20;
  top: 1.6rem;
  left: 1.8rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  /* Both fixed marks sit over scrolling content, so they carry the page
     surface with them. Otherwise the wordmark lands on top of a result
     tile and neither is readable. */
  padding: 0.3rem 0.75rem 0.3rem 0.4rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.logo-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

/* ============================================================
   The Fiber Knight mark, next to the page title.
   ------------------------------------------------------------
   This is the PRODUCT logo. The Jacops J in the corner mark above
   is the company one and stays where it is. The two are not
   interchangeable and neither replaces the other.

   The <img> carries onerror="this.remove()", so if assets/knight.svg
   is missing the title simply stands on its own instead of showing
   a broken-image icon. Drop the file in and the mark appears; no
   markup change needed.
   ============================================================ */
.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-mark {
  width: 2.4em;                 /* scales with the heading it sits beside */
  height: 2.4em;
  flex-shrink: 0;
  object-fit: contain;
}

@media (max-width: 640px) {
  .brand-mark { width: 1.9em; height: 1.9em; }
}

.wordmark {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--steel);
}

/* ============================================================
   Theme switch (top-right)
   ------------------------------------------------------------
   Three explicit segments rather than one cycling button: the
   current theme is readable at a glance, and picking one is a
   single click instead of up to three.
   ============================================================ */
.theme-switch {
  position: fixed;
  z-index: 20;
  top: 1.6rem;
  right: 1.8rem;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--steel);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: color .15s, background .15s;
}

.theme-switch button:hover { color: var(--ink); }
.theme-switch button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.theme-switch button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.theme-switch svg { width: 13px; height: 13px; flex: 0 0 auto; }

/* The labels are the wide part; below the breakpoint the icons carry it. */
@media (max-width: 900px) {
  .theme-switch button span { display: none; }
  .theme-switch button { padding: 0.35rem 0.45rem; }
}

/* Eyebrow above the H1 in the tool header. */
.card-bearing {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0;
}

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  position: relative;
  z-index: 1;
  border-top: 1px solid var(--line);
  padding: 2.2rem 2rem 5rem;
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--steel);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 720px) {
  .corner-mark { top: 1.1rem; left: 1.2rem; }
  .corner-mark .wordmark { display: none; }
  .theme-switch { top: 1.1rem; right: 1.2rem; }
  .site-footer { padding: 1.8rem 1.3rem 4rem; }
}

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