/* ============================================================================
   Grimalkin — Faceted Ink design system
   Drop-in extension for the existing assets/style.css.
   Load AFTER style.css:
     <link rel="stylesheet" href="/assets/style.css">
     <link rel="stylesheet" href="/assets/design-system.css">
   No JS. No build step. Every rule is progressive-enhancement safe.
   ========================================================================== */

/* ---- 1. Tokens ----------------------------------------------------------- */
/* Redefines + extends the :root from style.css. Plum stays the brand anchor;
   a cool "crystalline indigo" (same chroma/lightness, different hue) joins it
   for geometric glints and hover states. All new colors in oklch with hex
   fallbacks folded in via the values chosen. */
:root {
  /* surfaces (warm paper, unchanged + one deeper panel) */
  --paper:        #faf9f6;
  --paper-2:      #f2f0ea;
  --paper-3:      #ebe7dd;   /* NEW — deepest panel / faceted fills */
  --ink:          #181716;
  --muted:        #5c574f;
  --line:         #e2ded4;
  --line-strong:  #cfc8ba;   /* NEW — facet hairlines that need presence */

  /* accents — matched chroma/lightness, varied hue */
  --accent:       #5b3e7e;   /* plum  ~ oklch(0.42 0.093 312) */
  --accent-ink:   #432e5e;
  --accent-2:     #3f4a86;   /* crystalline indigo ~ oklch(0.42 0.093 268) */
  --accent-2-ink: #2f3868;

  /* facet system */
  --facet-line:   color-mix(in srgb, var(--ink) 12%, transparent);
  --facet-line-2: color-mix(in srgb, var(--ink) 22%, transparent);
  --facet-fill:   color-mix(in srgb, var(--accent) 5%, var(--paper));

  /* geometry + motion */
  --edge:         14px;      /* the canonical facet cut length */
  --shadow-crisp: 0 1px 0 var(--line-strong);
  --ease-facet:   cubic-bezier(.2, .7, .2, 1);

  /* mark matting — inert in light mode (the ink cat reads on warm paper). See §8a. */
  --mat-bg:       transparent;
  --mat-line:     transparent;
  --mat-pad:      0;
  --mat-pad-chip: 0;
  --mat-edge:     0px;
  --mat-edge-chip:0px;
  --mat-blend:    normal;
}

/* ---- 2. Dark theme ------------------------------------------------------- */
/* Two ways in: system preference (default), OR an explicit data-theme
   override on <html> set by the header's .theme-toggle button (see
   assets/theme-toggle.js) — the override exists mainly so a dark-mode
   device can still preview/debug the light theme, and vice versa. Warm
   near-black keeps the "ink on paper" soul at night. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #14130f;
    --paper-2:      #1c1a15;
    --paper-3:      #26231b;
    --ink:          #f2efe8;
    --muted:        #a49d90;
    --line:         #33302a;
    --line-strong:  #47423a;
    --accent:       #b79fd6;   /* plum, lifted for contrast on dark */
    --accent-ink:   #cbb6e6;
    --accent-2:     #9fb0ea;   /* indigo, lifted */
    --accent-2-ink: #b9c5f2;
    --facet-line:   color-mix(in srgb, var(--ink) 10%, transparent);
    --facet-line-2: color-mix(in srgb, var(--ink) 20%, transparent);
    --facet-fill:   color-mix(in srgb, var(--accent) 8%, var(--paper));
    /* the mat lights up: a warm-paper ground the ink cat can sit on at night */
    --mat-bg:       #faf9f6;
    --mat-line:     #d8d2c6;
    --mat-pad:      1.15rem 1.4rem;
    --mat-pad-chip: 3px 4px;
    --mat-edge:     16px;
    --mat-edge-chip:7px;
    --mat-blend:    multiply;
    color-scheme: dark;
  }
  :root:not([data-theme="light"]) .theme-toggle .icon-light { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-dark { display: inline; }
}
[data-theme="dark"] {
  --paper:#14130f; --paper-2:#1c1a15; --paper-3:#26231b;
  --ink:#f2efe8; --muted:#a49d90; --line:#33302a; --line-strong:#47423a;
  --accent:#b79fd6; --accent-ink:#cbb6e6; --accent-2:#9fb0ea; --accent-2-ink:#b9c5f2;
  --facet-line: color-mix(in srgb, var(--ink) 10%, transparent);
  --facet-line-2: color-mix(in srgb, var(--ink) 20%, transparent);
  --facet-fill: color-mix(in srgb, var(--accent) 8%, var(--paper));
  --mat-bg:#faf9f6; --mat-line:#d8d2c6; --mat-pad:1.15rem 1.4rem;
  --mat-pad-chip:3px 4px; --mat-edge:16px; --mat-edge-chip:7px; --mat-blend:multiply;
  color-scheme: dark;
}
[data-theme="dark"] .theme-toggle .icon-light { display: none; }
[data-theme="dark"] .theme-toggle .icon-dark { display: inline; }

/* ---- 3. Facet motif utilities ------------------------------------------- */
/* The single idea: a beveled corner. Applied consistently it becomes the brand.
   Use on cards, buttons, images, panels. One variable (--edge) tunes all of it. */
.facet        { clip-path: polygon(var(--edge) 0, 100% 0, 100% calc(100% - var(--edge)), calc(100% - var(--edge)) 100%, 0 100%, 0 var(--edge)); }
.facet--sm    { --edge: 9px; }
.facet--lg    { --edge: 22px; }
.facet--tl    { clip-path: polygon(var(--edge) 0, 100% 0, 100% 100%, 0 100%, 0 var(--edge)); }   /* top-left cut only */
.facet--br    { clip-path: polygon(0 0, 100% 0, 100% calc(100% - var(--edge)), calc(100% - var(--edge)) 100%, 0 100%); }

/* Hairline crystalline border that respects the bevel (uses a gradient outline
   trick so the cut edge is drawn, not just clipped). */
.facet-outline {
  position: relative;
  background: var(--paper);
}
.facet-outline::before {
  content: "";
  position: absolute; inset: 0;
  padding: 1px;
  background: linear-gradient(135deg, var(--line-strong), var(--facet-line));
  clip-path: polygon(var(--edge) 0, 100% 0, 100% calc(100% - var(--edge)), calc(100% - var(--edge)) 100%, 0 100%, 0 var(--edge));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* ---- 4. Vine divider ----------------------------------------------------- */
/* Replaces the plain 1px section rule with a running-vine hairline band —
   a wavy stem with alternating leaves, drawn from the same botanical vocabulary
   as the mark. Rendered as an INLINE <svg> (see DESIGN.md for the copy-paste
   partial) so stroke="currentColor" themes automatically and it survives every
   renderer. This class just colors + sizes the inline svg you drop inside it. */
.section + .section { border-top: 0; }        /* retire the flat rule */
.facet-divider { color: var(--facet-line-2); line-height: 0; }
.facet-divider svg { display: block; width: 100%; height: 44px; }

/* Production-only alternative (no extra markup) — CSS mask of the standalone
   SVG file. Well supported in shipping browsers; use if you prefer zero markup:
     .facet-divider--mask {
       height: 44px; color: var(--facet-line-2); background: currentColor;
       -webkit-mask: url(/assets/facet-divider.svg) center / auto 100% repeat-x;
               mask: url(/assets/facet-divider.svg) center / auto 100% repeat-x;
     }
*/

/* ---- 5. Veinwork mark + leaf marks -------------------------------------- */
/* The botanical mark (footer, empty states, eyebrow art) ships as an inline
   <svg> with class .veinmark — a symmetric leafed sprig, currentColor-themed.
   The gem is gone; the mark now speaks to the leaf-vein linework inside the cat
   logo and the branching "tree-of-life" form. Small repeating marks (bullets,
   eyebrow ticks) use a pure-CSS LEAF instead of SVG: cheaper and bulletproof. */
.veinmark { display: inline-block; width: 1em; height: 1em; color: var(--accent); vertical-align: -0.12em; }
.veinmark path, .veinmark circle { stroke: currentColor; }

/* CSS leaf primitive — a square with two pointed and two rounded corners */
.eyebrow { display: inline-flex; align-items: center; gap: .5em; }
.center .eyebrow { justify-content: center; }
.eyebrow::before {
  content: ""; width: .52em; height: .52em; flex: none;
  background: currentColor;
  border-radius: 0 100% 0 100%;
  transform: rotate(-10deg);
}
/* Leaf bullets for lists */
.facet-list { list-style: none; padding-left: 0; }
.facet-list > li { position: relative; padding-left: 1.6em; }
.facet-list > li::before {
  content: ""; position: absolute; left: .1em; top: .58em; width: .62em; height: .62em;
  background: var(--accent-2);
  border-radius: 0 100% 0 100%;
  transform: rotate(-10deg);
}

/* ---- 6. Cards ------------------------------------------------------------ */
/* Beveled top-right corner + hairline; hover lifts the crystalline indigo. */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 0;                             /* crystalline = no round */
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  transition: border-color .18s var(--ease-facet), transform .12s var(--ease-facet);
}
.card:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.card .price { color: var(--accent); }
/* Optional accent facet chip in the cut corner */
.card--marked { position: relative; }
.card--marked::after {
  content: ""; position: absolute; top: 0; right: 0;
  border-width: 0 18px 18px 0; border-style: solid;
  border-color: transparent var(--accent) transparent transparent;
  opacity: .9;
}

/* ---- 7. Buttons ---------------------------------------------------------- */
/* Faceted corners; indigo focus ring; crisp, no rounded pill. */
.btn { border-radius: 0; clip-path: polygon(8px 0,100% 0,100% calc(100% - 8px),calc(100% - 8px) 100%,0 100%,0 8px); }
.btn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.btn--primary { background: var(--accent-ink); border-color: var(--accent-ink); color: var(--paper); }
.btn--primary:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
/* style.css hard-codes #fff on these; var(--paper) stays legible in dark mode
   (near-black text on the lifted lavender accents). */
.skip-link { color: var(--paper); }

/* ---- 8. Hero ------------------------------------------------------------- */
/* A branching "tree-of-life" dendrite grows faintly behind the art (inline
   <svg class="hero-facets">). The full cat portrait is the once-per-page hero
   mark; the ear (§8b) stands in for it wherever the face is offscreen. */
.hero { position: relative; overflow: clip; }
.hero-facets {
  position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%;
  color: var(--facet-line); pointer-events: none;
}
.hero-facets svg { position: absolute; right: 0; bottom: 0; width: min(46%, 460px); height: auto; }
.hero-art { position: relative; }

/* ---- 8a. Mark matting ---------------------------------------------------- */
/* The cat marks are dark hairline ink on a transparent ground: they read on
   warm paper but nearly vanish on the near-black dark theme. In dark mode the
   art sits on a light "mat" — like a framed portrait — and the ink is
   multiplied onto it. All values come from the --mat-* tokens, which are inert
   in light mode, so light mode is left exactly as it was. */
.mark-mat {
  display: inline-block; position: relative; line-height: 0;
  background: var(--mat-bg);
  border: 1px solid var(--mat-line);
  padding: var(--mat-pad);
  clip-path: polygon(var(--mat-edge) 0, 100% 0, 100% calc(100% - var(--mat-edge)), calc(100% - var(--mat-edge)) 100%, 0 100%, 0 var(--mat-edge));
}
.mark-mat img { mix-blend-mode: var(--mat-blend); }
/* smaller frame for the header wordmark's cat */
.mark-mat--chip {
  padding: var(--mat-pad-chip);
  clip-path: polygon(var(--mat-edge-chip) 0, 100% 0, 100% calc(100% - var(--mat-edge-chip)), calc(100% - var(--mat-edge-chip)) 100%, 0 100%, 0 var(--mat-edge-chip));
}

/* ---- 8b. The ear — the cat where the face isn't -------------------------- */
/* The everyday form of the mark: a single ear, hairline, bled off a corner,
   one per view. Reserved for margins/views where the full portrait is
   offscreen — never set alongside the hero mark. */
.ear { position: absolute; width: 86px; height: 86px; color: var(--accent-2); opacity: .85; pointer-events: none; }
.ear path { stroke: currentColor; }
.ear--footer { top: -6px; right: -6px; transform: scaleX(-1); }

/* ---- 9. Geometric section headers --------------------------------------- */
/* A short faceted rule under the eyebrow, and an optional index number. */
.section-head { display: flex; align-items: baseline; gap: 1rem; }
.section-index {
  font-family: var(--mono); font-size: .78rem; letter-spacing: .1em;
  color: var(--accent-2); border: 1px solid var(--line-strong);
  padding: .1rem .5rem;
  clip-path: polygon(5px 0,100% 0,100% calc(100% - 5px),calc(100% - 5px) 100%,0 100%,0 5px);
}
/* The site's lifecycle chips carry the same bevel — no pills in this system. */
.tag {
  border-radius: 0; border-color: var(--line-strong);
  clip-path: polygon(5px 0,100% 0,100% calc(100% - 5px),calc(100% - 5px) 100%,0 100%,0 5px);
}

/* ---- 10. Notes / callouts ----------------------------------------------- */
.note {
  border: 1px dashed var(--accent);
  border-radius: 0;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
  background: var(--facet-fill);
}

/* ---- 11. Links ----------------------------------------------------------- */
a { color: var(--accent-ink); }
a:hover { color: var(--accent-2); }
.site-header .nav a:hover, .site-header .nav a[aria-current="page"] { color: var(--ink); }

/* ---- 12. Focus + reduced motion ----------------------------------------- */
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
