/* ============================================================
   iainlivingstone.com — canonical theme
   Version 1.0.0  (2026-08-15)

   SINGLE SOURCE OF TRUTH for the visual language across every
   prototype on this domain. Derived from the Peekaboo Vision
   web app (peekaboo-web/index.html), which is the reference
   implementation.

   Usage:  <link rel="stylesheet" href="/assets/theme.css">

   Rules:
     1. Never hard-code a colour. Use a var(--…) token.
     2. If you need a token that doesn't exist, add it HERE
        first, then use it. Do not invent local variants.
     3. Prototypes that must ship as a single self-contained
        file (offline PWAs) should inline the TOKENS block
        verbatim rather than re-deriving values by eye.
   ============================================================ */

/* ---------- 1. TOKENS ------------------------------------- */
:root {
  /* Surfaces */
  --c-bg:            #f5f5f5;   /* page background            */
  --c-bg-alt:        #f8f8f8;   /* secondary screens          */
  --c-surface:       #ffffff;   /* cards, panels, buttons     */
  --c-surface-sunk:  #fafafa;   /* inset / read-only blocks   */
  --c-surface-press: #e8e8e8;   /* :active state of a surface */

  /* Lines */
  --c-border:        #d0d0d0;   /* standard 1px border        */
  --c-border-light:  #e0e0e0;   /* dividers, inset blocks     */
  --c-border-input:  #cccccc;   /* form controls              */

  /* Type */
  --c-text:          #333333;   /* primary                    */
  --c-text-2:        #555555;   /* secondary                  */
  --c-text-3:        #888888;   /* captions, meta             */
  --c-text-4:        #aaaaaa;   /* disabled                   */
  --c-text-inverse:  #ffffff;

  /* Brand / semantic */
  --c-accent:        #4CAF50;   /* Peekaboo green — primary   */
  --c-accent-press:  #43a047;
  --c-accent-deep:   #2E7D32;   /* text on light green        */
  --c-accent-tint:   #E8F5E9;   /* success/positive backdrop  */

  --c-link:          #007AFF;   /* iOS system blue — links    */
  --c-info:          #3D7AED;   /* informational emphasis     */

  --c-danger:        #E53935;   /* errors, destructive        */
  --c-warn:          #E65100;   /* cautions                   */
  --c-warn-tint:     #FFF3E0;
  --c-warn-border:   #FFB74D;
  --c-warn-text:     #B26A00;

  /* Type scale */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --fs-display: 34px;
  --fs-h1:      28px;
  --fs-h2:      22px;
  --fs-h3:      17px;
  --fs-body:    15px;
  --fs-small:   13px;
  --fs-micro:   12px;

  --lh-tight: 1.25;
  --lh-body:  1.6;

  /* Spacing — 4px base */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Shape */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Elevation — used sparingly; the house style is borders, not shadows */
  --shadow-1: 0 1px 2px rgba(0,0,0,.04);
  --shadow-2: 0 4px 16px rgba(0,0,0,.08);

  /* Motion */
  --t-fast: .15s;
  --t:      .2s;

  /* Layout */
  --maxw:      1040px;
  --maxw-text: 680px;
}

/* ---------- 2. RESET & BASE ------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

img, svg { max-width: 100%; display: block; }

a { color: var(--c-link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--c-link);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------- 3. LAYOUT ------------------------------------- */
.wrap      { width: 100%; max-width: var(--maxw); margin-inline: auto;
             padding-inline: var(--sp-5); }
.wrap-text { max-width: var(--maxw-text); }

.section    { padding-block: var(--sp-12); }
.section-sm { padding-block: var(--sp-8); }

.stack > * + * { margin-top: var(--sp-4); }

/* ---------- 4. TYPOGRAPHY --------------------------------- */
h1, h2, h3 { line-height: var(--lh-tight); font-weight: 700; color: var(--c-text); }
h1 { font-size: var(--fs-h1); letter-spacing: .5px; }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); }

.display { font-size: var(--fs-display); font-weight: 700;
           letter-spacing: -.5px; line-height: 1.15; }

.lede    { font-size: var(--fs-h3); color: var(--c-text-2); }
.muted   { color: var(--c-text-3); }
.small   { font-size: var(--fs-small); }
.micro   { font-size: var(--fs-micro); }

.eyebrow {
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--c-text-3);
}

/* ---------- 5. SURFACES ----------------------------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: var(--sp-5);
}

.panel {
  background: var(--c-surface-sunk);
  border: 1px solid var(--c-border-light);
  border-radius: var(--r-sm);
  padding: var(--sp-4);
}

/* ---------- 6. BUTTONS ------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r);
  padding: 14px var(--sp-5);
  font: inherit; font-size: var(--fs-body); font-weight: 600;
  color: var(--c-text);
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  transition: background var(--t-fast), transform .1s, border-color var(--t-fast);
}
.btn:hover  { background: var(--c-bg-alt); text-decoration: none; }
.btn:active { background: var(--c-surface-press); transform: scale(.97); }

.btn-primary {
  background: var(--c-accent);
  border-color: var(--c-accent);
  color: var(--c-text-inverse);
  font-size: 17px;
  padding: 16px var(--sp-6);
}
.btn-primary:hover  { background: var(--c-accent-press); border-color: var(--c-accent-press); }
.btn-primary:active { background: var(--c-accent-press); }

.btn-quiet {
  background: none; border: none; color: var(--c-link);
  padding: var(--sp-2) 0; font-weight: 600;
}
.btn-quiet:hover { background: none; text-decoration: underline; }

.btn-block { display: flex; width: 100%; }

/* ---------- 7. BADGES ------------------------------------- */
.badge {
  display: inline-block;
  font-size: var(--fs-micro); font-weight: 700; letter-spacing: .4px;
  padding: 3px 9px; border-radius: var(--r-pill);
  border: 1px solid transparent; white-space: nowrap;
}
.badge-live    { background: var(--c-accent-tint); color: var(--c-accent-deep);
                 border-color: #c8e6c9; }
.badge-dev     { background: var(--c-warn-tint);  color: var(--c-warn-text);
                 border-color: var(--c-warn-border); }
.badge-locked  { background: #f0f0f0; color: var(--c-text-2);
                 border-color: var(--c-border); }
.badge-research{ background: #EAF1FE; color: #1F4FA8; border-color: #C3D7F7; }

/* ---------- 8. FORMS -------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-small); font-weight: 600; color: var(--c-text-2); }

.input, .textarea, .select {
  font: inherit; font-size: var(--fs-body);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-input);
  border-radius: var(--r-sm);
  padding: 11px var(--sp-3);
  width: 100%;
}
.input:focus, .textarea:focus, .select:focus {
  outline: none; border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(76,175,80,.18);
}
.textarea { min-height: 130px; resize: vertical; line-height: var(--lh-body); }

/* Honeypot — must stay invisible to humans, reachable to bots */
.hp { position: absolute; left: -9999px; width: 1px; height: 1px;
      overflow: hidden; opacity: 0; }

/* ---------- 9. NOTICES ------------------------------------ */
.notice {
  border: 1px solid var(--c-border-light);
  border-left: 4px solid var(--c-text-3);
  border-radius: var(--r-sm);
  background: var(--c-surface-sunk);
  padding: var(--sp-4);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  color: var(--c-text-2);
}
.notice-warn    { background: var(--c-warn-tint); border-color: var(--c-warn-border);
                  border-left-color: var(--c-warn); color: var(--c-warn-text); }
.notice-success { background: var(--c-accent-tint); border-color: #c8e6c9;
                  border-left-color: var(--c-accent); color: var(--c-accent-deep); }
.notice-error   { background: #FFEBEE; border-color: #FFCDD2;
                  border-left-color: var(--c-danger); color: #B71C1C; }

/* ---------- 10. GRID -------------------------------------- */
.grid { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
@media (min-width: 620px)  { .grid-2, .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 940px)  { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---------- 11. UTILITIES --------------------------------- */
.row      { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row-tight{ gap: var(--sp-2); }
.between  { justify-content: space-between; }
.center   { text-align: center; }
.hr       { height: 1px; background: var(--c-border-light); border: 0;
            margin-block: var(--sp-8); }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 12. MOTION PREFERENCES ------------------------ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- 13. PRINT ------------------------------------- */
@media print {
  body { background: #fff; }
  .card { break-inside: avoid; border-color: #999; }
  .btn, nav, footer { display: none !important; }
}
