/*
 * tommenzi.es — shared design system
 * ────────────────────────────────────
 * Single source of truth for all apps.
 * Served from: https://tommenzi.es/shared/styles.css
 * Repo: tommenzi-infra/shared/styles.css
 *
 * Usage: <link rel="stylesheet" href="/shared/styles.css">
 * Then add app-specific styles in a local <style> or stylesheet.
 */


/* ── Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@300;400;500&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@300;400&display=swap');


/* ── Design Tokens ── */
:root {
  /* Palette — light (default) */
  --bg:             #f5f0ea;
  --bg-subtle:      #ebe5dc;
  --bg-elevated:    #faf7f3;
  --text:           #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.45);
  --text-tertiary:  rgba(26, 26, 26, 0.2);
  --accent:         #8a6e47;
  --accent-light:   rgba(138, 110, 71, 0.08);
  --accent-mid:     rgba(138, 110, 71, 0.2);
  --rule:           rgba(26, 26, 26, 0.1);
  --rule-hover:     rgba(138, 110, 71, 0.4);

  /* Typography — font stacks */
  --font-serif:     'Instrument Serif', Georgia, serif;
  --font-mono:      'DM Mono', 'Courier New', monospace;
  --font-mono-tight:'JetBrains Mono', 'Courier New', monospace;

  /* Typography — scale */
  --text-xs:   0.6rem;
  --text-sm:   0.72rem;
  --text-base: 1rem;
  --text-md:   1.15rem;
  --text-lg:   1.35rem;
  --text-xl:   clamp(1.8rem, 4vw, 2.4rem);
  --text-2xl:  clamp(2.8rem, 6vw, 3.6rem);

  /* Spacing */
  --space-xs:  0.5rem;
  --space-sm:  1rem;
  --space-md:  1.5rem;
  --space-lg:  2rem;
  --space-xl:  3rem;
  --space-2xl: 4rem;

  /* Layout */
  --content-width: 520px;
  --content-width-wide: 680px;

  /* Motion */
  --ease-out:    cubic-bezier(0.16, 1, 0.3, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
  --duration-fast: 0.2s;
  --duration-base: 0.3s;
  --duration-slow: 0.5s;

  /* Borders */
  --radius-sm: 2px;
  --radius-md: 4px;
}


/* ── Dark Mode (system preference) ── */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:             #121210;
    --bg-subtle:      #1a1916;
    --bg-elevated:    #201f1c;
    --text:           #e8e6e1;
    --text-secondary: rgba(232, 230, 225, 0.5);
    --text-tertiary:  rgba(232, 230, 225, 0.2);
    --accent:         #c4a882;
    --accent-light:   rgba(196, 168, 130, 0.1);
    --accent-mid:     rgba(196, 168, 130, 0.25);
    --rule:           rgba(232, 230, 225, 0.08);
    --rule-hover:     rgba(196, 168, 130, 0.4);
  }
}

/* ── Manual theme override ('T' key — persisted in localStorage) ── */
:root[data-theme="dark"] {
  --bg:             #121210;
  --bg-subtle:      #1a1916;
  --bg-elevated:    #201f1c;
  --text:           #e8e6e1;
  --text-secondary: rgba(232, 230, 225, 0.5);
  --text-tertiary:  rgba(232, 230, 225, 0.2);
  --accent:         #c4a882;
  --accent-light:   rgba(196, 168, 130, 0.1);
  --accent-mid:     rgba(196, 168, 130, 0.25);
  --rule:           rgba(232, 230, 225, 0.08);
  --rule-hover:     rgba(196, 168, 130, 0.4);
}

:root[data-theme="light"] {
  --bg:             #f5f0ea;
  --bg-subtle:      #ebe5dc;
  --bg-elevated:    #faf7f3;
  --text:           #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.45);
  --text-tertiary:  rgba(26, 26, 26, 0.2);
  --accent:         #8a6e47;
  --accent-light:   rgba(138, 110, 71, 0.08);
  --accent-mid:     rgba(138, 110, 71, 0.2);
  --rule:           rgba(26, 26, 26, 0.1);
  --rule-hover:     rgba(138, 110, 71, 0.4);
}


/* ── Reset ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}


/* ── Base Body ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  opacity: 0;
}


/* ── Texture Overlay ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}


/* ── Typography ── */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.1;
  color: var(--text);
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }

p {
  font-family: var(--font-mono);
  font-weight: 300;
  line-height: 1.7;
  color: var(--text-secondary);
}

a {
  color: var(--text);
  text-decoration: none;
  transition: color var(--duration-base) ease;
}

a:hover {
  color: var(--accent);
}


/* ── Utility: Labels & Meta ── */
.label {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.meta {
  font-family: var(--font-mono);
  font-weight: 300;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.index-number {
  font-family: var(--font-mono-tight);
  font-weight: 300;
  font-size: 0.65rem;
  color: var(--text-tertiary);
}


/* ── Utility: Rules ── */
.rule {
  border: none;
  border-top: 1px solid var(--rule);
}


/* ── Utility: Content Container ── */
.content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: var(--content-width);
  padding: var(--space-lg);
  margin: 0 auto;
}

.content-wide {
  max-width: var(--content-width-wide);
}


/* ── Shared Animation ── */
@keyframes enter {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
  opacity: 0;
  animation: enter var(--duration-slow) ease-out forwards;
}


/* ── Responsive Base ── */
@media (max-width: 600px) {
  .content {
    padding: var(--space-xl) var(--space-md);
  }
}
