/* Ink & Chaaya: three reader-pickable themes, light only. <html data-theme> holds the choice (default: notebook).
     notebook    school ruled notebook, fountain-pen ink (default)
     chayakkada  hand-painted tea-shop signboard, chai-amber band
     ksrtc       KSRTC bus livery meets cinema poster, loud for the satire
   Structure lives in the shared section; each theme sets tokens + a few signature details. */

/* ── Shared tokens ─────────────────────────────────────── */
:root {
  --hand: "Chilanka", cursive;
  --wrap: 72rem;
  --band: transparent;       /* masthead background */
  --band-ink: var(--ink);
  --foot: transparent;
  --foot-ink: var(--muted);
  --plate: oklch(0.99 0.006 90); /* cover image backing */
}

/* ── Theme: notebook (default) ─────────────────────────── */
:root, :root[data-theme="notebook"] {
  --paper: oklch(0.985 0.006 250);
  --paper-deep: oklch(0.955 0.012 245);
  --ink: oklch(0.28 0.06 265);
  --muted: oklch(0.46 0.04 260);
  --rule: oklch(0.86 0.035 240);
  --accent: oklch(0.53 0.17 25);
  --line: oklch(0.9 0.03 240);
  --margin: oklch(0.7 0.13 20);
  --tape: oklch(0.93 0.04 95 / 0.8);
  --mark: oklch(0.94 0.1 100 / 0.75);
  --head: "Gayathri", "Manjari", sans-serif;
  --body: "Manjari", sans-serif;
  color-scheme: light;
}

/* ── Theme: chayakkada ─────────────────────────────────── */
:root[data-theme="chayakkada"] {
  --paper: oklch(0.975 0.014 85);
  --paper-deep: oklch(0.935 0.035 78);
  --ink: oklch(0.25 0.03 50);
  --muted: oklch(0.45 0.035 55);
  --rule: oklch(0.85 0.045 75);
  --accent: oklch(0.5 0.14 45);
  --amber: oklch(0.76 0.145 68);
  --band: var(--amber);
  --band-ink: oklch(0.25 0.03 50);
  --foot: oklch(0.25 0.03 50);
  --foot-ink: oklch(0.85 0.03 80);
  --plate: oklch(0.99 0.008 85);
  --head: "Baloo Chettan 2", "Noto Sans Malayalam", sans-serif;
  --body: "Noto Sans Malayalam", sans-serif;
  color-scheme: light;
}

/* ── Theme: ksrtc ──────────────────────────────────────── */
:root[data-theme="ksrtc"] {
  --paper: oklch(0.965 0.03 92);
  --paper-deep: oklch(0.93 0.05 92);
  --ink: oklch(0.22 0.02 30);
  --muted: oklch(0.42 0.03 40);
  --rule: oklch(0.22 0.02 30);
  --red: oklch(0.52 0.19 27);
  --yellow: oklch(0.87 0.16 92);
  --card: oklch(0.97 0.02 92);
  --outline: oklch(0.22 0.02 30);
  --shadow: oklch(0.22 0.02 30);
  --accent: var(--red);
  --band: var(--red);
  --band-ink: oklch(0.97 0.02 92);
  --foot: oklch(0.22 0.02 30);
  --foot-ink: oklch(0.97 0.02 92);
  --head: "Anek Malayalam", "Noto Sans Malayalam", sans-serif;
  --body: "Noto Sans Malayalam", sans-serif;
  color-scheme: light;
}

/* ── Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 1.1rem/1.95 var(--body); }
a { color: inherit; }
img { display: block; max-width: 100%; height: auto; }
.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 1.25rem; }
.hand { font-family: var(--hand); color: var(--accent); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--ink); color: var(--paper); padding: .5rem 1rem; z-index: 9; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* full-bleed band behind a .wrap element */
.masthead, .footer { box-shadow: 0 0 0 100vmax var(--bleed); clip-path: inset(0 -100vmax); }

/* ── Masthead ──────────────────────────────────────────── */
.masthead { --bleed: var(--band); background: var(--band); color: var(--band-ink); padding-block: 1rem .9rem; margin-bottom: 2.75rem; text-align: center; }
.masthead-top {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem 1rem; flex-wrap: wrap;
  font: 600 .8rem/1.4 var(--head); padding-bottom: .5rem;
  border-bottom: 1px solid color-mix(in oklch, var(--band-ink) 18%, transparent);
}
.masthead-top .hand { font-size: 1rem; color: inherit; flex: 1; min-width: 0; text-align: left; }
@media (max-width: 40rem) {
  .masthead-top { flex-wrap: nowrap; }
  .masthead-top .hand { font-size: .85rem; line-height: 1.35; }
}
.nameplate {
  display: inline-flex; align-items: center; gap: .3em; text-decoration: none; color: inherit;
  font: 800 clamp(3rem, 12vw, 6.8rem)/1 var(--head); padding: .9rem 0 .5rem;
}
/* the logo, exactly as drawn: no recolouring, filters or backing */
.logo { height: 1.2em; width: auto; }
.sections { display: flex; justify-content: center; flex-wrap: wrap; gap: .3rem 1.3rem; padding: .55rem 0 .1rem; font: 700 .98rem/1.5 var(--head); }
.sections a { text-decoration: none; white-space: nowrap; }
.sections a:hover, .sections a[aria-current] { color: var(--accent); text-decoration: underline 2px; text-underline-offset: 6px; }
@media (max-width: 40rem) {
  .sections { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; scrollbar-width: none; }
}

/* theme picker */
.themes { display: flex; align-items: center; gap: .45rem; }
.themes button {
  width: 1.9rem; height: 1.9rem; border-radius: 50%; padding: 0; cursor: pointer;
  border: 2px solid color-mix(in oklch, var(--band-ink) 35%, transparent);
}
.themes button[aria-pressed="true"] { border-color: var(--band-ink); outline: 2px solid var(--band-ink); outline-offset: 2px; }
.swatch-notebook { background: linear-gradient(90deg, transparent 38%, oklch(0.7 0.13 20) 38% 46%, transparent 46%), repeating-linear-gradient(oklch(0.985 0.006 250) 0 5px, oklch(0.8 0.05 240) 5px 6px); }
.swatch-chayakkada { background: radial-gradient(circle at 50% 60%, oklch(0.62 0.13 55) 0 38%, oklch(0.76 0.145 68) 39%); }
.swatch-ksrtc { background: linear-gradient(oklch(0.52 0.19 27) 0 58%, oklch(0.87 0.16 92) 58%); }

/* ── Shared bits ───────────────────────────────────────── */
.kicker { display: block; font: 700 .82rem/1.4 var(--head); color: var(--accent); }
.kicker a { text-decoration: none; }
.kicker a:hover { text-decoration: underline; }
time { display: block; font: 500 .85rem/1.4 var(--head); color: var(--muted); }
.dek { display: block; color: var(--muted); }
.print { display: block; overflow: hidden; background: var(--plate); border: 1px solid var(--rule); aspect-ratio: 16 / 9; }
.print img { width: 100%; height: 100%; object-fit: cover; mix-blend-mode: multiply; transition: transform .5s cubic-bezier(.22, 1, .36, 1); }
.rule-head { font: 700 1.1rem/1.4 var(--head); margin: 3.5rem 0 1.5rem; display: flex; align-items: center; gap: 1rem; }
.rule-head::after { content: ""; flex: 1; border-top: 1.5px solid var(--ink); }
.rule-head.big { font-size: clamp(1.8rem, 5vw, 2.6rem); font-weight: 800; margin-top: 0; }

/* ── Home ──────────────────────────────────────────────── */
.lead { display: grid; gap: 1.75rem; text-decoration: none; align-items: center; }
.lead-title { display: block; margin: .5rem 0 .9rem; font: 800 clamp(1.7rem, 3.4vw, 2.5rem)/1.3 var(--head); }
.lead .dek { font-size: 1.1rem; margin-bottom: 1rem; }
.lead:hover .lead-title, .card:hover .card-title { color: var(--accent); }
.lead:hover img, .card:hover img { transform: scale(1.03); }
@media (min-width: 48rem) { .lead { grid-template-columns: 3fr 2fr; gap: 2.5rem; } }
.grid { display: grid; gap: 2.5rem 2rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); }
.card { display: flex; flex-direction: column; gap: .45rem; text-decoration: none; }
.card .print { margin-bottom: .35rem; }
.card-title { font: 700 1.28rem/1.5 var(--head); transition: color .2s; }
@media (prefers-reduced-motion: no-preference) {
  .lead, .grid > * { animation: rise .6s cubic-bezier(.22, 1, .36, 1) both; }
  .grid > *:nth-child(2) { animation-delay: .06s; }
  .grid > *:nth-child(3) { animation-delay: .12s; }
  .grid > *:nth-child(n+4) { animation-delay: .18s; }
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } }
}

/* ── Post ──────────────────────────────────────────────── */
.post-head { max-width: 46rem; margin: 0 auto 2rem; text-align: center; }
.post-head h1 { font: 800 clamp(2rem, 5.5vw, 3.3rem)/1.25 var(--head); margin: .6rem 0 1rem; }
.post-head .dek { font-size: 1.15rem; margin-bottom: 1rem; }
.post-cover { max-width: 60rem; margin: 0 auto 3rem; }
.prose { max-width: 40rem; margin-inline: auto; font-size: 1.15rem; line-height: 2.05; }
.prose h2, .prose h3 { font-family: var(--head); line-height: 1.4; margin: 2.6rem 0 .8rem; }
.prose h2 { font-size: 1.6rem; }
.prose h3 { font-size: 1.3rem; }
.prose a { color: var(--accent); text-underline-offset: 4px; }
.prose blockquote { margin: 2rem 0; padding: 1rem 1.25rem; background: var(--paper-deep); border-radius: 12px; font-size: 1.15rem; }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li { margin: .35rem 0; }
.prose hr { border: 0; text-align: center; margin: 2.5rem 0; }
.prose hr::after { content: "☕"; opacity: .6; }
.prose table { width: 100%; border-collapse: collapse; font-size: 1rem; display: block; overflow-x: auto; }
.prose th, .prose td { border-bottom: 1px solid var(--rule); padding: .5rem .6rem; text-align: left; }
.prose strong { font-weight: 700; }
.endnote { max-width: 40rem; margin: 3.5rem auto 0; padding: 1.4rem 1.6rem; background: var(--paper-deep); border-radius: 14px; }
.endnote .hand { font-size: 1.3rem; margin: 0 0 .3rem; }
.endnote p:last-child { margin: 0; color: var(--muted); }
.endnote a { color: var(--accent); }
.more { max-width: 52rem; margin: 4rem auto 0; display: grid; gap: 2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr)); }
.label { font: 700 .82rem/1 var(--head); color: var(--muted); margin: 0 0 .8rem; }

/* ── About / footer ────────────────────────────────────── */
.page { max-width: 40rem; margin-inline: auto; font-size: 1.12rem; }
.page h1 { font: 800 clamp(2rem, 5vw, 2.8rem)/1.3 var(--head); }
.page h2 { font: 700 1.4rem/1.4 var(--head); margin-top: 2.4rem; }
.page a { color: var(--accent); }
.qr { width: 9rem; border: 1px solid var(--rule); background: var(--plate); padding: .4rem; }
.footer { --bleed: var(--foot); background: var(--foot); color: var(--foot-ink); margin-top: 5rem; padding-block: 2rem 3rem; text-align: center; font: 500 .92rem/1.8 var(--head); border-top: 1.5px solid var(--rule); }
.footer .hand { font-size: 1.15rem; margin: 0 0 .3rem; }
.footer a { color: inherit; }

/* ═══ Theme signatures ════════════════════════════════════ */

/* notebook: ruled paper, red margin, taped covers, highlighter quotes */
:root:not([data-theme]) body, [data-theme="notebook"] body {
  --m: 2.4rem;
  --lh: 2.25rem;         /* one ruled line = one line of text; keep it a whole number of px (36px) or Chrome drops 1px rules */
  --rule-nudge: -.5rem;  /* ponytail: calibration knob, moves rules up/down so Malayalam sits on them; retune if the body font changes */
  --margin-line: linear-gradient(to right, transparent var(--m), var(--margin) var(--m), var(--margin) calc(var(--m) + 1.5px), transparent calc(var(--m) + 1.5px));
  --rules: repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--line) calc(var(--lh) - 1px) var(--lh));
  background-image: var(--margin-line); /* rules only where text can sit on them: see .prose below */
}
@media (max-width: 40rem) { :root:not([data-theme]) body, [data-theme="notebook"] body { --m: .55rem; } }

/* Rules belong to the article text: drawn from the prose block's own top, full width,
   and every block below takes whole lines so the writing never drifts off them.
   Home/listing pages mix type sizes and image heights, so they get plain paper + margin. */
[data-theme="notebook"] .prose { position: relative; isolation: isolate; line-height: var(--lh); }
[data-theme="notebook"] .prose::before {
  content: ""; position: absolute; z-index: -1; top: 0; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw);
  background: var(--rules) 0 var(--rule-nudge);
}
[data-theme="notebook"] .prose > * { margin-block: 0 var(--lh); }
[data-theme="notebook"] .prose h2, [data-theme="notebook"] .prose h3 { line-height: var(--lh); margin-block: var(--lh) 0; }
[data-theme="notebook"] .prose h2 { font-size: 1.5rem; }
[data-theme="notebook"] .prose li { margin: 0; }
[data-theme="notebook"] .prose hr { margin-block: 0 var(--lh); line-height: var(--lh); }
[data-theme="notebook"] .sections { border-top: 1.5px solid var(--ink); border-bottom: 1.5px solid var(--ink); padding-bottom: .55rem; margin-top: .2rem; }
[data-theme="notebook"] .print { position: relative; overflow: visible; box-shadow: 0 6px 18px -12px oklch(0.3 0.05 260 / .5); }
[data-theme="notebook"] .print img { mix-blend-mode: normal; }
[data-theme="notebook"] .print::after {
  content: ""; position: absolute; top: -.6rem; left: 50%; width: 4.5rem; height: 1.3rem;
  translate: -50% 0; rotate: -3deg; background: var(--tape);
}
[data-theme="notebook"] .card:hover img, [data-theme="notebook"] .lead:hover img { transform: none; }
[data-theme="notebook"] .card:hover .print, [data-theme="notebook"] .lead:hover .print { rotate: -.6deg; transition: rotate .3s cubic-bezier(.22, 1, .36, 1); }
[data-theme="notebook"] .prose blockquote { border-radius: 0; padding: 0 .4rem; font-size: inherit; background: linear-gradient(transparent 12%, var(--mark) 12% 88%, transparent 88%); }
[data-theme="notebook"] .endnote { border-radius: 0; rotate: .5deg; background: oklch(0.96 0.06 95); color: oklch(0.28 0.06 265); box-shadow: 0 8px 20px -14px oklch(0.4 0.05 80 / .6); }
[data-theme="notebook"] .endnote p:last-child { color: oklch(0.4 0.04 260); }
[data-theme="notebook"] .footer { border-top-color: var(--margin); }

/* chayakkada: amber signboard, painted pills, soft rounded plates */
[data-theme="chayakkada"] .sections { gap: .5rem; }
[data-theme="chayakkada"] .sections a { background: var(--paper); color: var(--ink); border-radius: 999px; padding: .2rem .9rem; }
[data-theme="chayakkada"] .sections a:hover, [data-theme="chayakkada"] .sections a[aria-current] { background: var(--band-ink); color: var(--amber); text-decoration: none; }
[data-theme="chayakkada"] .kicker { display: inline-block; width: fit-content; background: color-mix(in oklch, var(--amber) 35%, transparent); color: var(--ink); border-radius: 999px; padding: .05rem .6rem; }
[data-theme="chayakkada"] .print { border: 0; border-radius: 18px; box-shadow: 0 10px 30px -18px oklch(0.35 0.08 50 / .55); }
[data-theme="chayakkada"] .rule-head::after { border-top: 3px dotted var(--rule); }
[data-theme="chayakkada"] .endnote { background: color-mix(in oklch, var(--amber) 30%, transparent); border-radius: 20px; }
[data-theme="chayakkada"] .footer { border: 0; }
[data-theme="chayakkada"] .footer .hand { color: var(--amber); }

/* ksrtc: red livery, yellow stripe, thick outlines, hard poster shadows */
[data-theme="ksrtc"] .masthead { padding-bottom: 0; }
[data-theme="ksrtc"] .masthead-top .hand { color: var(--yellow); }
[data-theme="ksrtc"] .nameplate { font-stretch: 72%; font-size: clamp(3.4rem, 15vw, 8rem); }
[data-theme="ksrtc"] .sections {
  --bleed: var(--yellow); background: var(--yellow); color: oklch(0.22 0.02 30);
  box-shadow: 0 0 0 100vmax var(--yellow); clip-path: inset(0 -100vmax);
  margin-top: .4rem; padding-block: .6rem; border-bottom: 3px solid var(--outline);
}
[data-theme="ksrtc"] .sections a:hover, [data-theme="ksrtc"] .sections a[aria-current] { color: oklch(0.52 0.19 27); }
[data-theme="ksrtc"] .kicker { display: inline-block; width: fit-content; background: var(--red); color: oklch(0.97 0.02 92); padding: .1rem .55rem; }
[data-theme="ksrtc"] .lead { border: 3px solid var(--outline); box-shadow: 8px 8px 0 var(--shadow); background: var(--yellow); color: oklch(0.22 0.02 30); gap: 0; }
[data-theme="ksrtc"] .lead .print { border: 0; border-right: 3px solid var(--outline); }
[data-theme="ksrtc"] .lead-text { padding: 1.5rem; }
[data-theme="ksrtc"] .lead .dek, [data-theme="ksrtc"] .lead time { color: oklch(0.32 0.03 40); }
[data-theme="ksrtc"] .lead:hover .lead-title { color: oklch(0.52 0.19 27); }
@media (max-width: 48rem) { [data-theme="ksrtc"] .lead .print { border-right: 0; border-bottom: 3px solid var(--outline); } }
[data-theme="ksrtc"] .lead-title, [data-theme="ksrtc"] .post-head h1 { font-stretch: 75%; }
[data-theme="ksrtc"] .card { border: 3px solid var(--outline); background: var(--card); box-shadow: 6px 6px 0 var(--shadow); padding-bottom: 1rem; transition: translate .2s cubic-bezier(.22, 1, .36, 1), box-shadow .2s cubic-bezier(.22, 1, .36, 1); }
[data-theme="ksrtc"] .card > :not(.print) { padding-inline: 1rem; }
[data-theme="ksrtc"] .card .print { border: 0; border-bottom: 3px solid var(--outline); }
[data-theme="ksrtc"] .card:hover { translate: -3px -3px; box-shadow: 9px 9px 0 var(--shadow); }
[data-theme="ksrtc"] .card:hover img { transform: none; }
[data-theme="ksrtc"] .rule-head { color: var(--accent); font-weight: 800; font-size: 1.3rem; }
[data-theme="ksrtc"] .rule-head::after { border-top: 3px solid var(--outline); }
[data-theme="ksrtc"] .post-cover { border: 3px solid var(--outline); box-shadow: 8px 8px 0 var(--shadow); }
[data-theme="ksrtc"] .prose blockquote { border-radius: 0; border: 3px solid var(--outline); background: var(--yellow); color: oklch(0.22 0.02 30); }
[data-theme="ksrtc"] .endnote { border-radius: 0; border: 3px solid var(--outline); background: var(--yellow); color: oklch(0.22 0.02 30); box-shadow: 6px 6px 0 var(--shadow); rotate: -1deg; }
[data-theme="ksrtc"] .endnote .hand, [data-theme="ksrtc"] .endnote a { color: oklch(0.52 0.19 27); }
[data-theme="ksrtc"] .endnote p:last-child { color: oklch(0.32 0.03 40); }
[data-theme="ksrtc"] .footer { border: 0; }
[data-theme="ksrtc"] .footer .hand { color: var(--yellow); }
