/* ===========================================================================
   docs.shabinder.in — shared theme
   ---------------------------------------------------------------------------
   This file is the single source of visual truth for the site AND for every
   self-contained artifact published into it.

   An agent publishing an artifact links this file and then styles against the
   tokens below. The artifact keeps its own layout and its own components; it
   inherits palette, type and spacing. That is the deal: consistent identity,
   no re-templating of authored work.

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

   Tokens are defined once on :root (light), then redefined for dark under both
   the system preference and an explicit [data-theme] stamp, so a page renders
   correctly in all three viewer states: explicit light, explicit dark, and the
   un-stamped default that follows the OS.
   ========================================================================= */

:root {
  /* ---- palette: warm ink on paper, single saturated accent ---- */
  --paper:        #FBFAF7;
  --surface:      #FFFFFF;
  --surface-2:    #F3F1EC;
  --rule:         #DFDBD1;
  --rule-soft:    #EBE8E1;

  --ink:          #1A1815;
  --ink-2:        #55504A;
  --ink-3:        #8A837A;

  --accent:       #7A4B1E;
  --accent-ink:   #6B4119;
  --accent-wash:  #F2E7DA;

  --good:         #3F6B4A;
  --warn:         #8A6A1F;
  --bad:          #9B3B26;

  /* ---- type ---- */
  --font-sans:  "Inter var", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-serif: "Spectral", Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono:  ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --step--1: clamp(0.80rem, 0.78rem + 0.10vw, 0.86rem);
  --step-0:  clamp(0.95rem, 0.92rem + 0.14vw, 1.02rem);
  --step-1:  clamp(1.14rem, 1.06rem + 0.38vw, 1.36rem);
  --step-2:  clamp(1.39rem, 1.24rem + 0.74vw, 1.85rem);
  --step-3:  clamp(1.69rem, 1.43rem + 1.28vw, 2.52rem);

  /* ---- space & shape ---- */
  --sp-1: 0.25rem;  --sp-2: 0.5rem;   --sp-3: 0.75rem;
  --sp-4: 1rem;     --sp-5: 1.5rem;   --sp-6: 2rem;
  --sp-7: 3rem;     --sp-8: 4.5rem;
  --radius: 3px;
  --measure: 68ch;
  --shadow: 0 1px 2px rgba(26, 24, 21, .05), 0 10px 28px -16px rgba(26, 24, 21, .22);

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:       #14130F;
    --surface:     #1B1A16;
    --surface-2:   #232119;
    --rule:        #35322A;
    --rule-soft:   #2A2721;

    --ink:         #EFEBE2;
    --ink-2:       #BBB4A8;
    --ink-3:       #857E73;

    --accent:      #D89A5C;
    --accent-ink:  #E3AC74;
    --accent-wash: #2E2318;

    --good:        #7FB08C;
    --warn:        #D0AE62;
    --bad:         #DF8B72;

    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 12px 32px -18px rgba(0,0,0,.8);
  }
}

:root[data-theme="dark"] {
  --paper:       #14130F;
  --surface:     #1B1A16;
  --surface-2:   #232119;
  --rule:        #35322A;
  --rule-soft:   #2A2721;

  --ink:         #EFEBE2;
  --ink-2:       #BBB4A8;
  --ink-3:       #857E73;

  --accent:      #D89A5C;
  --accent-ink:  #E3AC74;
  --accent-wash: #2E2318;

  --good:        #7FB08C;
  --warn:        #D0AE62;
  --bad:         #DF8B72;

  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 12px 32px -18px rgba(0,0,0,.8);
}

/* ===================== base ===================== */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  /* Explicit background: an artifact composites over a ground the viewer
     paints in its own theme. A transparent body borrows the wrong one. */
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  line-height: 1.2;
  letter-spacing: -0.018em;
  text-wrap: balance;
  margin: 0;
  font-weight: 600;
}
h1 { font-size: var(--step-3); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }

p, li { max-width: var(--measure); }
p { margin: 0 0 var(--sp-4); }

a { color: var(--accent-ink); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.9em; }
code {
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 2px;
}
pre {
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: var(--sp-4);
  overflow-x: auto;
  line-height: 1.5;
}
pre code { background: none; padding: 0; }

hr { border: 0; border-top: 1px solid var(--rule); margin: var(--sp-6) 0; }

img, svg, video { max-width: 100%; height: auto; }

blockquote {
  margin: var(--sp-5) 0;
  padding-left: var(--sp-4);
  border-left: 2px solid var(--accent);
  color: var(--ink-2);
  font-family: var(--font-serif);
  font-size: var(--step-1);
}

/* Tables scroll in their own container so the page never scrolls sideways. */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: var(--step--1); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
th {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  border-bottom: 1px solid var(--rule);
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ===================== shared furniture ===================== */

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2em 0.55em;
  border-radius: 2px;
  border: 1px solid currentColor;
}
.badge--private { color: var(--accent-ink); }
.badge--public  { color: var(--good); }

.wrap {
  max-width: 62rem;
  margin-inline: auto;
  padding-inline: var(--sp-4);
}
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--sp-4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  body { background: #fff; color: #000; }
  .no-print { display: none !important; }
}
