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

:root,
html[data-theme="light"] {
  --paper: #f6f1e6;
  --paper-2: #fffdf8;
  --ink: #1c2a2e;
  --muted: #5b6a6e;
  --teal: #2c6a73;
  --teal-dark: #1e4d54;
  --lime: #6eae3a;
  --flame: #e8941a;
  --line: #d9d0c0;
  --shadow: 0 18px 40px rgba(28, 42, 46, 0.08);
  --header-bg: rgba(246, 241, 230, 0.92);
  --footer-bg: rgba(255, 253, 248, 0.7);
  --tag-bg: rgba(44, 106, 115, 0.1);
  --note-bg: rgba(232, 148, 26, 0.1);
  --help-bg: #1e4d54;
  --help-ink: #f6f1e6;
  --help-muted: rgba(246, 241, 230, 0.86);
  --help-link: #f3d27a;
  --switch-bg: #fffdf8;
  --switch-on: #2c6a73;
  --switch-on-ink: #fff;
  --dot-a: rgba(44, 106, 115, 0.07);
  --dot-b: rgba(232, 148, 26, 0.08);
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --tamil: "Noto Sans Tamil", "Latha", sans-serif;
  --max: 68rem;
  color-scheme: light;
}

html[data-theme="dark"] {
  --paper: #141a1c;
  --paper-2: #1c2428;
  --ink: #e8efe8;
  --muted: #9aada8;
  --teal: #4a9aa3;
  --teal-dark: #7ec4cb;
  --lime: #8bcf4a;
  --flame: #f0a83a;
  --line: #2e3a3e;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --header-bg: rgba(20, 26, 28, 0.92);
  --footer-bg: rgba(28, 36, 40, 0.85);
  --tag-bg: rgba(74, 154, 163, 0.18);
  --note-bg: rgba(240, 168, 58, 0.14);
  --help-bg: #163a40;
  --help-ink: #e8efe8;
  --help-muted: rgba(232, 239, 232, 0.82);
  --help-link: #f3d27a;
  --switch-bg: #1c2428;
  --switch-on: #4a9aa3;
  --switch-on-ink: #141a1c;
  --dot-a: rgba(74, 154, 163, 0.12);
  --dot-b: rgba(240, 168, 58, 0.1);
  color-scheme: dark;
}

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

html.i18n-pending body {
  visibility: hidden;
}

html[lang="ta"] body {
  font-family: var(--tamil), var(--sans);
}

html[lang="ta"] h1,
html[lang="ta"] h2,
html[lang="ta"] h3 {
  font-family: var(--tamil), var(--serif);
}

html[lang="ta"] .eyebrow {
  letter-spacing: 0.04em;
  text-transform: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.6;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 12px 12px, var(--dot-a) 1.2px, transparent 1.4px),
    radial-gradient(circle at 36px 36px, var(--dot-b) 1.2px, transparent 1.4px);
  background-size: 48px 48px;
  overflow-x: hidden;
}

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

a {
  color: var(--teal-dark);
}

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

.skip {
  position: absolute;
  left: 0.8rem;
  top: -3rem;
  background: var(--ink);
  color: var(--paper);
  padding: 0.4rem 0.7rem;
  z-index: 20;
}

.skip:focus {
  top: 0.8rem;
}

.wrap {
  width: min(var(--max), calc(100% - 1.5rem));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner,
.site-footer .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: var(--ink);
  flex-shrink: 0;
}

.brand img {
  height: 2.85rem;
  width: auto;
  max-width: 9rem;
  object-fit: contain;
}

.header-end {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

/* Compact A|அ and sun|moon switches — same shell, different glyphs */
.switch {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--switch-bg);
  padding: 2px;
  gap: 2px;
}

.switch-btn {
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1;
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: 0.35rem;
  cursor: pointer;
  color: var(--muted);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.switch-ta {
  font-family: var(--tamil), var(--sans);
  font-size: 1rem;
}

.switch-btn[aria-pressed="true"] {
  background: var(--switch-on);
  color: var(--switch-on-ink);
}

.switch-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--line);
  background: var(--switch-bg);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  min-height: 2.25rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1.1rem;
  margin-left: auto;
  margin-right: 0.65rem;
}

.site-nav a {
  text-decoration: none;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0;
}

.site-nav a[aria-current="page"],
.site-nav a:hover {
  color: var(--teal);
}

main {
  flex: 1;
  padding: 2rem 0 3.5rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 2rem;
  align-items: center;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.hero-logo {
  width: min(22rem, 100%);
  margin: 0 auto;
  display: block;
}

.eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--flame);
}

h1, h2, h3 {
  font-family: var(--serif);
  line-height: 1.25;
  font-weight: 700;
  overflow-wrap: anywhere;
}

h1 {
  margin-top: 0.45rem;
  font-size: clamp(1.75rem, 5vw, 3.15rem);
}

h2 {
  font-size: clamp(1.4rem, 3.5vw, 2.15rem);
}

.lede,
.prose p,
.langnote {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.5vw, 1.08rem);
}

.tamil-line {
  margin-top: 0.35rem;
  font-family: var(--tamil);
  color: var(--lime);
  font-weight: 600;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.4rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 700;
  border-radius: 10px;
  padding: 0.7rem 1.05rem;
  min-height: 2.75rem;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--teal);
  color: #fff;
}

.btn-primary:hover {
  background: var(--teal-dark);
  color: #fff;
}

html[data-theme="dark"] .btn-primary {
  color: #141a1c;
}

html[data-theme="dark"] .btn-primary:hover {
  color: #141a1c;
  background: var(--teal-dark);
}

.btn-ghost {
  background: transparent;
  color: var(--teal-dark);
  border: 1px solid var(--line);
}

.section {
  margin-top: 2.75rem;
}

.section-head {
  max-width: 40rem;
  margin-bottom: 1.3rem;
}

.section-head p {
  margin-top: 0.5rem;
  color: var(--muted);
}

.grid-3,
.grid-2 {
  display: grid;
  gap: 1rem;
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.15rem 1.15rem 1.25rem;
}

.card h3 {
  margin-top: 0.35rem;
  font-size: 1.2rem;
}

.card p {
  margin-top: 0.55rem;
  color: var(--muted);
}

.card a.more {
  display: inline-block;
  margin-top: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.15rem 0;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--teal-dark);
  background: var(--tag-bg);
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
}

html[lang="ta"] .tag {
  text-transform: none;
  letter-spacing: 0;
}

.note {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-left: 4px solid var(--flame);
  background: var(--note-bg);
  border-radius: 0 12px 12px 0;
  color: var(--ink);
}

.prose {
  max-width: 42rem;
}

.prose h2 {
  margin-top: 2rem;
}

.prose p + p {
  margin-top: 0.85rem;
}

.help-box {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--help-bg);
  color: var(--help-ink);
  border-radius: 16px;
}

.help-box h2 {
  color: var(--help-ink);
}

.help-box p,
.help-box li {
  color: var(--help-muted);
}

.help-box ul {
  margin: 0.8rem 0 0 1.1rem;
}

.help-box a {
  color: var(--help-link);
}

.help-cta {
  margin-top: 0.9rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 1.1rem 0 1.4rem;
  padding-bottom: max(1.4rem, env(safe-area-inset-bottom));
  background: var(--footer-bg);
}

.site-footer p {
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer .links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.site-footer .links a {
  text-decoration: none;
  font-weight: 600;
  padding: 0.25rem 0;
}

@media (max-width: 840px) {
  .hero,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .hero {
    padding: 1.25rem;
    border-radius: 18px;
    gap: 1.4rem;
  }

  .hero-logo {
    width: min(14rem, 70%);
    order: -1;
  }

  .nav-toggle {
    display: inline-flex;
    align-items: center;
  }

  .site-nav {
    display: none;
    flex-basis: 100%;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
    flex-direction: column;
    gap: 0;
    padding: 0.35rem 0 0.85rem;
    border-top: 1px solid var(--line);
    margin-top: 0.35rem;
  }

  .site-nav a {
    padding: 0.7rem 0.15rem;
    border-bottom: 1px solid var(--line);
  }

  .site-nav a:last-child {
    border-bottom: 0;
  }

  .site-nav.open {
    display: flex;
  }

  .header-inner {
    flex-wrap: wrap;
  }

  .brand img {
    height: 2.5rem;
    max-width: 7.5rem;
  }

  .site-footer .wrap {
    flex-direction: column;
    align-items: flex-start;
  }

  main {
    padding: 1.5rem 0 3rem;
  }

  .section {
    margin-top: 2.2rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .wrap {
    width: calc(100% - 1.15rem);
  }

  .switch-btn {
    min-width: 2.1rem;
    min-height: 2.1rem;
  }

  .header-end {
    gap: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
