/* ==========================================================
   TIKRI PROJECT — Design System
   Art direction: editorial archive, documentary field journal
   Palette: warm archival parchment + deep teal accent
   Typography: Source Serif 4 (display) + Work Sans (body)
   ========================================================== */

/* ----------------------------------------------------------
   TOKENS
---------------------------------------------------------- */
:root,
[data-theme="light"] {
  /* Type scale */
  --text-xs:   clamp(0.75rem,  0.72rem + 0.15vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.84rem + 0.2vw,  1rem);
  --text-base: clamp(1rem,     0.96rem + 0.22vw, 1.125rem);
  --text-lg:   clamp(1.2rem,   1.05rem + 0.7vw,  1.6rem);
  --text-xl:   clamp(1.8rem,   1.3rem  + 2vw,    3rem);
  --text-2xl:  clamp(2.6rem,   1.5rem  + 4vw,    5rem);

  /* Spacing (4px base) */
  --sp-1:  0.25rem;
  --sp-2:  0.5rem;
  --sp-3:  0.75rem;
  --sp-4:  1rem;
  --sp-5:  1.25rem;
  --sp-6:  1.5rem;
  --sp-8:  2rem;
  --sp-10: 2.5rem;
  --sp-12: 3rem;
  --sp-16: 4rem;
  --sp-20: 5rem;
  --sp-24: 6rem;

  /* Colors — warm parchment surfaces */
  --bg:              #f5f2eb;
  --surface:         #faf8f2;
  --surface-2:       #f0ece3;
  --surface-offset:  #e7e0d4;
  --border:          rgba(44, 35, 22, 0.13);
  --divider:         rgba(44, 35, 22, 0.09);
  --text:            #1e1710;
  --text-muted:      #635a50;
  --text-faint:      #9a9189;
  --text-inverse:    #fdfaf4;

  /* Accent — deep archival teal */
  --primary:         #1a5c63;
  --primary-hover:   #134b52;
  --primary-hl:      rgba(26, 92, 99, 0.10);

  /* Warm amber accent for <strong> / highlights */
  --amber:           #7c4a1e;
  --amber-soft:      rgba(124, 74, 30, 0.09);

  /* Radius */
  --r-sm:  0.4rem;
  --r-md:  0.75rem;
  --r-lg:  1.2rem;
  --r-xl:  1.8rem;

  /* Shadows */
  --sh-sm: 0 1px 3px rgba(28, 22, 14, 0.06);
  --sh-md: 0 8px 24px rgba(28, 22, 14, 0.09);
  --sh-lg: 0 20px 56px rgba(28, 22, 14, 0.13);

  /* Fonts */
  --font-display: 'Source Serif 4', Georgia, serif;
  --font-body:    'Work Sans', 'Helvetica Neue', Arial, sans-serif;

  /* Layout */
  --content-max: min(1100px, calc(100vw - 2.5rem));
  --reading-max: 70ch;
  --ease: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] {
  --bg:              #141210;
  --surface:         #1c1916;
  --surface-2:       #24201c;
  --surface-offset:  #2d2924;
  --border:          rgba(235, 228, 216, 0.12);
  --divider:         rgba(235, 228, 216, 0.08);
  --text:            #ede7dc;
  --text-muted:      #c0b9af;
  --text-faint:      #8f8880;
  --text-inverse:    #141210;
  --primary:         #79b8bf;
  --primary-hover:   #93cacf;
  --primary-hl:      rgba(121, 184, 191, 0.12);
  --amber:           #e0a96d;
  --amber-soft:      rgba(224, 169, 109, 0.11);
  --sh-sm: 0 1px 3px rgba(0, 0, 0, 0.22);
  --sh-md: 0 8px 24px rgba(0, 0, 0, 0.30);
  --sh-lg: 0 20px 56px rgba(0, 0, 0, 0.38);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg:              #141210;
    --surface:         #1c1916;
    --surface-2:       #24201c;
    --surface-offset:  #2d2924;
    --border:          rgba(235, 228, 216, 0.12);
    --divider:         rgba(235, 228, 216, 0.08);
    --text:            #ede7dc;
    --text-muted:      #c0b9af;
    --text-faint:      #8f8880;
    --text-inverse:    #141210;
    --primary:         #79b8bf;
    --primary-hover:   #93cacf;
    --primary-hl:      rgba(121, 184, 191, 0.12);
    --amber:           #e0a96d;
    --amber-soft:      rgba(224, 169, 109, 0.11);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg { display: block; max-width: 100%; height: auto; }
input, button, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
h1, h2, h3, h4, h5, h6 { text-wrap: balance; }
p, li { text-wrap: pretty; max-width: var(--reading-max); }

a {
  color: var(--primary);
  text-underline-offset: 0.15em;
  transition: color var(--ease), background var(--ease), outline-color var(--ease);
}
a:hover { color: var(--primary-hover); }

::selection { background: var(--primary-hl); }

:focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

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

/* ----------------------------------------------------------
   SKIP LINK
---------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: var(--sp-4);
  top: -10rem;
  z-index: 999;
  padding: var(--sp-3) var(--sp-5);
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: var(--r-md);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--ease);
}
.skip-link:focus { top: var(--sp-4); }

/* ----------------------------------------------------------
   SITE SHELL
---------------------------------------------------------- */
.site-shell {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ----------------------------------------------------------
   HEADER
---------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
}

.header-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-block: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

/* Brand */
.site-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--amber);
  flex-shrink: 0;
}
.brand-mark svg { width: 2rem; height: 2rem; }

.brand-text { display: flex; flex-direction: column; gap: 0.1rem; }

.site-title {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.site-tagline {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.2;
}

/* Nav toggle (mobile) */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 99px;
  transition: transform var(--ease), opacity var(--ease);
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Header right (nav + modes) */
.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-left: auto;
}

/* Primary nav */
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  padding: 0.6rem 0.9rem;
  border-radius: 99px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text);
  transition: background var(--ease), color var(--ease);
}
.site-nav a:hover,
.site-nav a:focus-visible {
  background: var(--surface-2);
  color: var(--primary);
}

/* Icon buttons */
.mode-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text);
  transition: background var(--ease), border-color var(--ease);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }

.icon-btn--text {
  padding-inline: 0.8rem;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Theme icon swap */
.icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="dark"] .icon-sun  { display: none; }

/* Reading mode active state */
[data-reading] #reading-toggle {
  background: var(--amber-soft);
  border-color: var(--amber);
  color: var(--amber);
}

/* ----------------------------------------------------------
   MAIN CONTENT
---------------------------------------------------------- */
.content {
  padding-block: clamp(var(--sp-10), 5vw, var(--sp-24));
}

.content-inner {
  max-width: var(--content-max);
  margin-inline: auto;
}

/* Typography */
.content h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin-bottom: var(--sp-6);
  max-width: 14ch;
}

.content h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-top: var(--sp-16);
  margin-bottom: var(--sp-4);
}

.content h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.015em;
  margin-top: var(--sp-10);
  margin-bottom: var(--sp-3);
}

.content h4 {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: var(--sp-8);
  margin-bottom: var(--sp-3);
}

.content p {
  margin-bottom: var(--sp-5);
  line-height: 1.75;
}

.content > * + p { margin-top: 0; }

/* Lead paragraph after h1 */
.content h1 + p {
  font-size: var(--text-lg);
  color: var(--text-muted);
  max-width: 56ch;
  margin-bottom: var(--sp-8);
}

.content strong { color: var(--amber); font-weight: 700; }
.content em     { font-style: italic; }

.content ul,
.content ol {
  padding-left: 1.4rem;
  margin-bottom: var(--sp-6);
}
.content li + li { margin-top: var(--sp-2); }

.content sup { font-size: 0.75em; }

.content blockquote {
  margin: var(--sp-8) 0;
  padding: var(--sp-5) var(--sp-6) var(--sp-5) var(--sp-6);
  border-left: 3px solid var(--amber);
  background: var(--amber-soft);
  border-radius: 0 var(--r-lg) var(--r-lg) 0;
  color: var(--text-muted);
  max-width: var(--reading-max);
}

.content hr {
  border: 0;
  border-top: 1px solid var(--divider);
  margin: var(--sp-12) 0;
}

.content a { font-weight: 500; }

/* ----------------------------------------------------------
   MAP
---------------------------------------------------------- */
#map {
  width: 100%;
  height: clamp(18rem, 40vw, 32rem);
  margin: var(--sp-8) 0 var(--sp-10);
  border-radius: var(--r-xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--sh-md);
}

/* ----------------------------------------------------------
   TABLE
---------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  margin: var(--sp-8) 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
}

table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
}

th {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--divider);
  text-align: left;
}

td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--divider);
}

tr:last-child td { border-bottom: 0; }

/* ----------------------------------------------------------
   CODE
---------------------------------------------------------- */
code {
  font-size: 0.88em;
  font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}

pre {
  overflow-x: auto;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}

pre code { background: none; border: none; padding: 0; }

/* ----------------------------------------------------------
   FOOTER
---------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--divider);
  background: var(--surface);
}

.footer-inner {
  max-width: var(--content-max);
  margin-inline: auto;
  padding-block: var(--sp-10) var(--sp-12);
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--sp-8);
  text-align: center;        /* ← add */
  justify-items: center;     /* ← add */
}

.footer-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-3);
}

.footer-col p {
  color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--sp-2);
  max-width: none;           /* ← change from 40ch to none */
}

.footer-col a { font-weight: 500; }

/* ----------------------------------------------------------
   READING / FOCUS MODE
   Activated via [data-reading] on <html>
   Designed for neurodivergent-friendly reading
---------------------------------------------------------- */
[data-reading] body {
  background-color: #fdf8ee;
}

[data-reading][data-theme="dark"] body {
  background-color: #13100d;
}

[data-reading] .content-inner {
  max-width: 72ch;
}

[data-reading] .content {
  font-size: clamp(1.05rem, 1rem + 0.3vw, 1.2rem);
  line-height: 1.9;
  letter-spacing: 0.012em;
}

[data-reading] .content p,
[data-reading] .content li {
  max-width: 66ch;
}

[data-reading] .content h1,
[data-reading] .content h2,
[data-reading] .content h3 {
  letter-spacing: -0.01em;
}

[data-reading] .site-header {
  box-shadow: 0 1px 0 var(--divider);
}

/* ----------------------------------------------------------
   RESPONSIVE
---------------------------------------------------------- */
@media (max-width: 900px) {
  .nav-toggle { display: flex; }
  .header-right { position: relative; }

  /* Hide mode controls from header row on mobile */
  .mode-controls {
    display: none;
  }

  .site-nav {
    display: none;
    position: absolute;
    top: calc(100% + var(--sp-2));
    right: 0;
    min-width: 220px;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--sh-lg);
    padding: var(--sp-2);
    z-index: 200;
  }

.site-nav.is-open .mode-controls { display: flex !important; }
   
  .site-nav a {
    border-radius: var(--r-md);
    padding: 0.8rem 1rem;
  }

  /* Show mode controls inside the dropdown when nav is open */
  .site-nav.is-open ~ .mode-controls {
    display: flex;
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
    border-top: 1px solid var(--divider);
    margin-top: var(--sp-1);
  }
}

@media (max-width: 640px) {
  .footer-inner {
    grid-template-columns: 1fr;
  }

  .content h1 {
    max-width: 100%;
  }

  /* Prevent header overflow on small screens */
  .header-inner {
    gap: var(--sp-3);
    padding-inline: var(--sp-3);
  }

  .site-tagline {
    display: none;
  }

  .site-title {
    font-size: clamp(1rem, 5vw, 1.3rem);
  }

  .brand-mark {
    width: 2.4rem;
    height: 2.4rem;
  }

  .brand-mark svg {
    width: 1.5rem;
    height: 1.5rem;
  }
}
