/**
 * Techoian dual scheme — C light (Ink Editorial) + B dark (Graphite + Lime)
 * Spec: specs/design-system.md (TS-050)
 */

@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=IBM+Plex+Sans:wght@400;500;600&family=Source+Sans+3:wght@400;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root,
html[data-tch-scheme="light"] {
  --tch-page: #fafaf8;
  --tch-card: #ffffff;
  --tch-surface: #f0f0ec;
  --tch-border: rgba(17, 17, 17, 0.1);
  --tch-border-m: rgba(17, 17, 17, 0.16);
  --tch-txt1: #111111;
  --tch-txt2: #3f3f46;
  --tch-txt3: #62626b; /* 5.3:1 on --tch-surface (was #71717a, 4.2:1) */
  --tch-accent: #c2410c;
  --tch-accent-soft: rgba(194, 65, 12, 0.12);
  --tch-hero: #141414;
  --tch-hero-fg: #fafaf8;
  --tch-hero-muted: #a1a1aa;
  --tch-font-display: "Fraunces", "Source Serif 4", Georgia, serif;
  --tch-font-body: "Source Sans 3", system-ui, sans-serif;
  --tch-r-md: 8px;
  --tch-r-lg: 12px;
  /* Type scale (TS-092): use these, not ad-hoc rem values. Minimum text size is --tch-fs-xs. */
  --tch-fs-xs: .8rem;
  --tch-fs-sm: .9rem;
  --tch-fs-base: 1rem;
  --tch-fs-md: 1.125rem;
  --tch-fs-lg: 1.3rem;
  --tch-fs-xl: clamp(1.7rem, 4vw, 2.3rem);
  --tch-fs-2xl: clamp(2rem, 5vw, 3.2rem);
}

html[data-tch-scheme="dark"] {
  --tch-page: #0c0c0c;
  --tch-card: #171717;
  --tch-surface: #1f1f1f;
  --tch-border: rgba(245, 245, 245, 0.12);
  --tch-border-m: rgba(245, 245, 245, 0.2);
  --tch-txt1: #f5f5f5;
  --tch-txt2: #a3a3a3;
  --tch-txt3: #8a8a8a; /* 4.8:1 on --tch-surface (was #737373, ~3.7:1) */
  --tch-accent: #65a30d;
  --tch-accent-soft: rgba(101, 163, 13, 0.16);
  --tch-hero: #0c0c0c;
  --tch-hero-fg: #f5f5f5;
  --tch-hero-muted: #8a8a8a;
  --tch-font-display: "Space Grotesk", system-ui, sans-serif;
  --tch-font-body: "IBM Plex Sans", system-ui, sans-serif;
}

/* Blocksy draws headings, header, footer and forms from its own palette; point that at the tokens so both schemes reach every surface */
html[data-tch-scheme] {
  --theme-palette-color-1: var(--tch-accent);
  --theme-palette-color-2: var(--tch-accent);
  --theme-palette-color-3: var(--tch-txt2);
  --theme-palette-color-4: var(--tch-txt1);
  --theme-palette-color-5: var(--tch-border-m);
  --theme-palette-color-6: var(--tch-surface);
  --theme-palette-color-7: var(--tch-page);
  --theme-palette-color-8: var(--tch-card);
}

html {
  color-scheme: light;
}

html[data-tch-scheme="dark"] {
  color-scheme: dark;
}

body.brand-techoian {
  /* Blocksy reads its link colors from these; point them at the tokens so every plain link follows the scheme */
  --theme-link-initial-color: var(--tch-accent);
  --theme-link-hover-color: var(--tch-txt1);
  background: var(--tch-page);
  color: var(--tch-txt1);
  font-family: var(--tch-font-body);
}

body.brand-techoian h1,
body.brand-techoian h2,
body.brand-techoian h3 {
  font-family: var(--tch-font-display);
}

/* Buttons */
body.brand-techoian .tch-btn-primary,
body.brand-techoian .tch-btn-ghost {
  display: inline-block;
  padding: 0.8rem 1.3rem;
  border-radius: var(--tch-r-md);
  font-weight: 700;
  font-size: var(--tch-fs-sm);
  text-decoration: none;
}
body.brand-techoian .tch-btn-primary { background: var(--tch-accent); color: #fff; border: 1px solid var(--tch-accent); }
html[data-tch-scheme="dark"] body.brand-techoian .tch-btn-primary { color: #0c0c0c; }
body.brand-techoian .tch-btn-ghost { color: var(--tch-txt1); border: 1px solid var(--tch-border-m); background: transparent; }
body.brand-techoian .tch-btn-primary:hover,
body.brand-techoian .tch-btn-ghost:hover { filter: brightness(1.08); }

/* Header chrome */
body.brand-techoian .tch-intent-nav .current-menu-item > a {
  color: var(--tch-accent);
}

/* Scheme toggle */
.tch-scheme-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 9999;
  border: 1px solid var(--tch-border-m);
  background: var(--tch-card);
  color: var(--tch-txt1);
  font: 600 var(--tch-fs-xs)/1 var(--tch-font-body);
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.tch-scheme-toggle:hover {
  border-color: var(--tch-accent);
}

.tch-scheme-toggle:focus-visible {
  outline: 2px solid var(--tch-accent);
  outline-offset: 2px;
}

/* Keyboard focus (TS-092): one visible ring on every interactive element, both schemes */
body.brand-techoian a:focus-visible,
body.brand-techoian button:focus-visible,
body.brand-techoian summary:focus-visible,
body.brand-techoian input:focus-visible {
  outline: 2px solid var(--tch-accent);
  outline-offset: 2px;
}

/* 404 */
.tch-notfound .search-form { margin: 0 0 20px; }
