/* ==========================================================================
   Prateek MainaVi — journal theme
   Plain CSS (no build step). Light + dark, responsive, accessible.
   ========================================================================== */

:root {
  --paper:   #F6F1E7;
  --card:    #FBF7EE;
  --ink:     #16140F;
  --softink: #3D362C;
  --muted:   #6B604E;
  --subtle:  #A89C85;
  --rule:    #D9CFB8;
  --accent:  #6B2B2B;
  --on-ink:  #F6F1E7;
  --field:   rgba(255, 255, 255, .45);
  --hover:   rgba(255, 255, 255, .38);
  --grain:   .25;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:   #15130F;
    --card:    #1D1A15;
    --ink:     #EDE6D6;
    --softink: #D0C7B3;
    --muted:   #A39984;
    --subtle:  #6F6656;
    --rule:    #3A342A;
    --accent:  #D79A8A;
    --on-ink:  #15130F;
    --field:   rgba(255, 255, 255, .05);
    --hover:   rgba(255, 255, 255, .05);
    --grain:   .12;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper:   #15130F;
  --card:    #1D1A15;
  --ink:     #EDE6D6;
  --softink: #D0C7B3;
  --muted:   #A39984;
  --subtle:  #6F6656;
  --rule:    #3A342A;
  --accent:  #D79A8A;
  --on-ink:  #15130F;
  --field:   rgba(255, 255, 255, .05);
  --hover:   rgba(255, 255, 255, .05);
  --grain:   .12;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Source Serif 4", "Noto Serif Devanagari", Georgia, serif;
  font-variation-settings: "opsz" 14, "wght" 420;
  font-feature-settings: "kern", "liga", "calt";
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body::before { /* paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--grain);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.08 0 0 0 0 0.07 0 0 0 0 0.05 0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
.masthead, .main, .footer, #progress { position: relative; z-index: 1; }
img { max-width: 100%; height: auto; }
a { color: inherit; }
::selection { background: var(--ink); color: var(--paper); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: var(--paper); padding: .6rem 1rem; z-index: 100; }
.skip:focus { left: 0; }

/* ---------- Typography ---------- */
.display       { font-family: "Fraunces", "Noto Serif Devanagari", serif; font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 380; font-feature-settings: "ss01", "liga", "dlig"; letter-spacing: -.018em; font-weight: 400; }
.display-heavy { font-family: "Fraunces", "Noto Serif Devanagari", serif; font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 500; letter-spacing: -.02em; font-weight: 500; }
.body-text     { font-family: "Source Serif 4", "Noto Serif Devanagari", Georgia, serif; font-variation-settings: "opsz" 18, "wght" 400; font-feature-settings: "kern", "liga", "onum"; }
.label, .label-fine, .btn { font-family: "Fraunces", serif; text-transform: uppercase; }
.label      { font-variation-settings: "opsz" 9, "wght" 500; letter-spacing: .22em; font-size: .6875rem; }
.label-fine { font-variation-settings: "opsz" 9, "wght" 450; letter-spacing: .2em; font-size: .625rem; }
.old-num { font-feature-settings: "onum"; }
.italic  { font-style: italic; }
.muted   { color: var(--muted); }
.accent  { color: var(--accent); }
.ink     { color: var(--ink); }
.softink { color: var(--softink); }
.small   { font-size: .875rem; }
.center  { text-align: center; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }

/* spacing helpers */
.mb-xs { margin-bottom: .35rem; } .mb-sm { margin-bottom: .75rem; } .mb-md { margin-bottom: 1.25rem; } .mb-lg { margin-bottom: 2.5rem; }
.mt-xs { margin-top: .35rem; } .mt-sm { margin-top: .75rem; } .mt-md { margin-top: 1.5rem; }
.ml-xs { margin-left: .35rem; }
.my-xl { margin-top: 4rem; margin-bottom: 4rem; }
.pt-lg { padding-top: 2rem; }

/* ---------- Layout ---------- */
.wrap { width: 100%; max-width: 78rem; margin: 0 auto; padding: 0 1.5rem; }
@media (min-width: 1024px) { .wrap { padding: 0 2.5rem; } }
.main { flex: 1; padding-top: 3.5rem; padding-bottom: 4rem; min-height: 60vh; }
@media (min-width: 1024px) { .main { padding-top: 5rem; padding-bottom: 5rem; } }
.reading { max-width: 38rem; margin: 0 auto; }
.line { display: inline-block; height: 1px; background: var(--ink); width: 3rem; }
.hide-sm { display: none; } .hide-md { display: none; }
@media (min-width: 640px)  { .hide-sm { display: inline; } }
@media (min-width: 768px)  { .hide-md { display: block; } }

/* rules */
.rule        { border-top: 1px solid var(--rule); }
.rule-double { border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); height: 4px; }
.mid-rule    { max-width: 48rem; margin: 3.5rem auto; }
.narrow-rule { max-width: 42rem; margin-left: auto; margin-right: auto; }

/* ---------- Masthead ---------- */
.masthead { border-bottom: 1px solid var(--rule); }
.mast-top { border-bottom: 1px solid color-mix(in srgb, var(--rule) 60%, transparent); }
.mast-top-in { display: flex; justify-content: space-between; gap: 1rem; padding-top: .65rem; padding-bottom: .65rem; }
.mast-main { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; padding-top: 1.25rem; padding-bottom: 1.25rem; }
.brand { text-decoration: none; display: block; }
.brand-name { display: block; font-size: 1.5rem; line-height: 1; }
@media (min-width: 1024px) { .brand-name { font-size: 1.875rem; } }
.brand-tag { display: block; margin-top: .4rem; }
.nav { display: flex; align-items: center; gap: 1.5rem; }
@media (min-width: 1024px) { .nav { gap: 2.5rem; } }
.nav-link { position: relative; text-decoration: none; transition: color .2s; white-space: nowrap; }
@media (max-width: 480px) {
  .mast-main { gap: .75rem; }
  .brand-name { font-size: 1.2rem; }
  .nav { gap: .85rem; }
  .nav.label { letter-spacing: .14em; }
  .nav-link { letter-spacing: .14em; }
}
.nav-link::after { content: ""; position: absolute; left: 0; bottom: -5px; height: 1px; width: 0; background: var(--ink); transition: width .3s; }
.nav-link:hover::after, .nav-link.active::after { width: 100%; }
.theme-toggle { background: none; border: 1px solid transparent; color: var(--ink); width: 2.2rem; height: 2.2rem; display: inline-grid; place-items: center; cursor: pointer; border-radius: 2px; transition: border-color .2s, color .2s; }
.theme-toggle:hover { border-color: var(--rule); color: var(--accent); }
.theme-toggle .ico-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ico-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ico-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ico-moon { display: none; }
}

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 1.5rem 0 2.5rem; }
.hero-title { font-size: clamp(2.5rem, 6.4vw, 5.5rem); line-height: .98; max-width: 56rem; margin: 0 auto; font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 360; }
.hero-by { margin-top: 2rem; display: flex; align-items: center; justify-content: center; gap: 1rem; font-size: 1.125rem; }

/* ---------- Featured ---------- */
.featured { max-width: 48rem; margin: 0 auto; }
.featured-link, .archive-link, .continue-card { text-decoration: none; display: block; }
.featured-link { text-align: center; padding: 1.5rem .5rem; }
.featured-title { font-size: clamp(2.25rem, 5vw, 4.5rem); line-height: 1.02; margin-bottom: 1.5rem; }
.featured-excerpt { font-size: clamp(1.05rem, 1.6vw, 1.25rem); line-height: 1.6; color: var(--softink); max-width: 40rem; margin: 0 auto 1.5rem; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem; }
.dot { color: var(--subtle); }
.entry { transition: background-color .3s; }
.entry:hover { background: var(--hover); }
.entry-title { transition: color .3s; }
.entry:hover .entry-title { color: var(--accent); }
.ulink { background: linear-gradient(currentColor, currentColor) 0 100% / 100% 1px no-repeat; padding-bottom: 2px; text-decoration: none; transition: color .3s; }
.ulink:hover { color: var(--accent); }

/* ---------- Archive ---------- */
.archive-head { max-width: 64rem; margin: 0 auto 2.5rem; padding: 0 .5rem; display: grid; gap: 1rem; align-items: baseline; }
@media (min-width: 768px) { .archive-head { grid-template-columns: 1fr 1fr; } .archive-head > p { text-align: right; } }
.archive-title { font-size: clamp(1.875rem, 3vw, 2.5rem); line-height: 1.1; }
.archive { max-width: 64rem; margin: 0 auto; border-top: 1px solid var(--ink); }
.archive-row { border-bottom: 1px solid var(--rule); }
.archive-link { display: grid; gap: .75rem 1.5rem; padding: 1.5rem .5rem; align-items: baseline; }
@media (min-width: 768px) { .archive-link { grid-template-columns: 7.5rem 1fr 5rem; padding: 1.75rem .5rem; } }
.num-big { font-size: 1.875rem; line-height: 1; }
.archive-row-title { font-size: clamp(1.4rem, 2.4vw, 1.875rem); line-height: 1.15; margin-bottom: .5rem; }
.archive-side { display: none; }
@media (min-width: 768px) { .archive-side { display: block; text-align: right; } }
.read-more { margin-top: .5rem; opacity: 0; transition: opacity .2s; }
.archive-row:hover .read-more, .archive-link:focus-visible .read-more { opacity: 1; }

.pager { max-width: 64rem; margin: 3rem auto 0; display: flex; justify-content: space-between; align-items: center; padding: 0 .5rem; }

.empty { text-align: center; max-width: 28rem; margin: 3rem auto; }
.empty-title { font-size: clamp(1.8rem, 4vw, 2.5rem); line-height: 1.15; margin-bottom: 1rem; }

/* ---------- Story ---------- */
.back-link { display: inline-block; margin-bottom: 3rem; text-decoration: none; transition: color .2s; }
.back-link:hover { color: var(--ink); }
.story-head { margin-bottom: 3rem; }
.story-kicker { display: flex; align-items: center; gap: .75rem; margin-bottom: 1.5rem; }
.story-kicker .line { flex: 1; width: auto; background: var(--rule); }
.story-title { font-size: clamp(2.5rem, 6vw, 4.5rem); line-height: 1.03; margin-bottom: 1.75rem; font-variation-settings: "opsz" 144, "SOFT" 30, "wght" 480; }
.story-head .meta-line { justify-content: flex-start; gap: .6rem; }
.about-title { font-size: clamp(2.4rem, 5.5vw, 3.75rem); line-height: 1.06; margin-bottom: 2.5rem; }
.cover { margin: 0 0 2.5rem; }
.cover img { width: 100%; display: block; border-radius: 2px; background: var(--card); }
.preview-banner { background: var(--ink); color: var(--paper); padding: .7rem 1rem; margin-bottom: 2rem; text-align: center; }
.end-mark { margin: 3.5rem 0 2.5rem; text-align: center; font-size: 1.5rem; }
.writer-box { padding-bottom: 1rem; }

.continue { max-width: 64rem; margin: 5rem auto 0; border-top: 1px solid var(--ink); padding-top: 2.5rem; }
.continue-grid { display: grid; gap: 1.5rem; }
@media (min-width: 768px) { .continue-grid { grid-template-columns: 1fr 1fr; } }
.continue-card { border: 1px solid var(--rule); padding: 1.25rem; }
.continue-card h4 { font-size: 1.5rem; line-height: 1.15; }
.continue-card.right { text-align: right; }

/* ---------- Prose ---------- */
.prose { font-size: 1.1875rem; line-height: 1.72; font-variation-settings: "opsz" 20, "wght" 410; font-feature-settings: "kern", "liga", "onum"; overflow-wrap: break-word; }
.prose:lang(hi) { line-height: 1.9; }
.prose p { margin: 0 0 .8em; hyphens: auto; -webkit-hyphens: auto; }
.prose p + p { text-indent: 1.5em; }
.prose p:lang(hi), .prose:lang(hi) p { hyphens: none; }
.prose h2 + p, .prose h3 + p, .prose blockquote + p, .prose figure + p, .prose hr + p, .prose ul + p, .prose ol + p { text-indent: 0; }
.prose em, .prose i { font-style: italic; color: var(--softink); }
.prose strong, .prose b { font-weight: 600; }
.prose blockquote {
  font-family: "Fraunces", "Noto Serif Devanagari", serif; font-style: italic; font-variation-settings: "opsz" 36, "wght" 360, "SOFT" 50;
  font-size: 1.4rem; line-height: 1.5; text-align: center; max-width: 32rem; margin: 2.25rem auto; padding: 1rem 1.5rem; color: var(--softink);
}
.prose h2 { font-family: "Fraunces", "Noto Serif Devanagari", serif; font-variation-settings: "opsz" 60, "wght" 460, "SOFT" 30; font-size: 1.85rem; line-height: 1.18; text-align: center; margin: 2.5em 0 1em; letter-spacing: -.01em; }
.prose h3 { font-family: "Fraunces", "Noto Serif Devanagari", serif; font-variation-settings: "opsz" 36, "wght" 500; font-size: 1.35rem; line-height: 1.3; margin: 2em 0 .7em; }
.prose ul, .prose ol { margin: 0 0 1.2em; padding-left: 1.6rem; }
.prose li { margin-bottom: .35em; padding-left: .2rem; }
.prose hr { border: 0; text-align: center; margin: 2.75em 0; }
.prose hr::before { content: "❦"; font-family: "Fraunces", serif; font-size: 1.5rem; color: var(--accent); letter-spacing: .5em; }
.prose a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent); transition: opacity .2s; }
.prose a:hover { opacity: .6; }
.prose figure { margin: 2.5em -2rem; text-indent: 0; }
@media (max-width: 700px) { .prose figure { margin: 2em 0; } }
.prose figure img { display: block; width: 100%; border-radius: 2px; background: var(--card); }
.prose figcaption { font-family: "Fraunces", serif; font-variation-settings: "opsz" 9, "wght" 420; font-style: italic; font-size: .8125rem; line-height: 1.5; color: var(--muted); text-align: center; margin-top: .85em; }
.prose figcaption::before { content: "Fig. "; font-style: normal; font-variation-settings: "wght" 500; text-transform: uppercase; letter-spacing: .18em; font-size: .7em; color: var(--accent); margin-right: .3em; }
.prose .inline-img { display: inline-block; vertical-align: middle; }
.prose.dropcap > p:first-child::first-letter {
  font-family: "Fraunces", serif; font-variation-settings: "opsz" 144, "wght" 400, "SOFT" 30;
  font-size: 4.6rem; line-height: .86; float: left; margin: .45rem .55rem -.1rem 0; color: var(--ink);
}

/* ---------- About ---------- */
.about-facts { margin-top: 3.5rem; padding-top: 2.5rem; display: grid; gap: 1.5rem; }
@media (min-width: 640px) { .about-facts { grid-template-columns: 1fr 1fr; } }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--ink); margin-top: 3rem; }
.footer-grid { display: grid; gap: 2rem; padding-top: 3rem; padding-bottom: 3rem; }
@media (min-width: 768px) { .footer-grid { grid-template-columns: 5fr 4fr 3fr; } .footer-colophon { text-align: right; } }
.footer-name { font-size: 1.5rem; margin-bottom: .5rem; }
.footer-about p { max-width: 24rem; line-height: 1.6; }
.footer-base { border-top: 1px solid var(--rule); }
.footer-base-in { display: flex; flex-direction: column; gap: .5rem; align-items: center; justify-content: space-between; padding-top: 1rem; padding-bottom: 1rem; }
@media (min-width: 640px) { .footer-base-in { flex-direction: row; } }
.desk-link { text-decoration: none; opacity: .75; } .desk-link:hover { opacity: 1; color: var(--accent); }

/* ---------- Buttons & forms (shared with admin) ---------- */
.btn { font-variation-settings: "opsz" 9, "wght" 500; letter-spacing: .18em; font-size: .6875rem; padding: .85rem 1.5rem; border: 1px solid var(--ink); background: transparent; color: var(--ink); cursor: pointer; display: inline-block; text-align: center; text-decoration: none; transition: all .2s; line-height: 1.2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-solid { background: var(--ink); color: var(--paper); }
.btn-solid:hover { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.btn-ghost:hover { background: var(--ink); color: var(--paper); }
.btn-danger { color: var(--accent); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: var(--paper); }
.btn-sm { padding: .45rem .85rem; font-size: .625rem; letter-spacing: .16em; }
.field { border: 1px solid var(--rule); background: var(--field); transition: border-color .2s; }
.field:focus-within { border-color: var(--ink); }
input, textarea, select { font-family: "Source Serif 4", "Noto Serif Devanagari", Georgia, serif; color: var(--ink); background: transparent; }
input:focus, textarea:focus, select:focus { outline: none; }

/* ---------- Reading progress ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 50; }
#progress-bar { height: 100%; width: 0; background: var(--accent); }

/* ---------- Motion ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade   { animation: fadeUp .6s ease-out both; }
.fade-1 { animation: fadeUp .6s ease-out .08s both; }
.fade-2 { animation: fadeUp .6s ease-out .16s both; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .fade, .fade-1, .fade-2 { animation: none; }
  * { transition: none !important; }
}

@media print {
  body::before, .masthead, .footer, #progress, .back-link, .continue { display: none !important; }
  body { background: #fff; color: #000; }
  .main { padding: 0; }
}
