/* ════════════════════════════════════════════════════════════
   style.css — Scholar's Study layout
   Colors set via js/config.js at runtime.
   Change colors there, not here.
════════════════════════════════════════════════════════════ */

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

:root {
  --bg:        #f4f1ec;
  --bg2:       #ebe6dd;
  --panel:     #faf7f2;
  --text:      #3a3020;
  --text-dim:  #7a6a58;
  --heading:   #1e1810;
  --accent:    #5b7ec9;
  --accent2:   #3d5fa8;
  --accent-bg: #eef1f9;
  --border:    #d6cec4;
  --gold:      #b5820a;
  --gold-lt:   #cfa030;
  --t1: #5c7fa8; --t2: #c0b89a; --t3: #9e3030; --t4: #4a7a5a; --t5: #b5820a;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'DM Mono', 'Cascadia Code', ui-monospace, 'Courier New', monospace;
  --nav-w: 160px;
  --pad:   44px;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.78;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--accent2); }

/* ── Skip link (ADA) ── */
.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--accent); color: #fff;
  padding: 10px 18px; font-size: 14px; font-weight: 500;
  text-decoration: none; border-radius: 0 0 6px 0;
  z-index: 9999; transition: top 0.15s;
}
.skip-link:focus { top: 0; }

/* ── Focus rings ── */
*:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
*:focus:not(:focus-visible) { outline: none; }

/* ════════════════════════════════════════════════════════════
   TIBETAN FIVE-ELEMENT BAND
════════════════════════════════════════════════════════════ */
.band {
  display: flex;
  height: 4px;
  flex-shrink: 0;
  width: 100%;
}
.band div { flex: 1; }

/* ════════════════════════════════════════════════════════════
   SITE WRAPPER
════════════════════════════════════════════════════════════ */
.site-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 1080px;
  margin: 0 auto;
  width: 100%;
}

/* ════════════════════════════════════════════════════════════
   SHARED HEADER ROW
   One row, full width. Left cell = Mihir Patel. Right = page label.
   Gold rule sits immediately below — only under the content column.
════════════════════════════════════════════════════════════ */
.header-row {
  display: flex;
  align-items: flex-end;
  padding: 28px 0 8px;
  flex-shrink: 0;
}
.header-name {
  width: var(--nav-w);
  flex-shrink: 0;
  padding: 0 0 0 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 500;
  color: var(--heading);
  line-height: 1.3;
}
.header-label {
  flex: 1;
  padding: 0 var(--pad);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Gold paintbrush rule — content column only */
.gold-rule {
  height: 1.5px;
  flex-shrink: 0;
  margin-left: var(--nav-w);
  margin-right: var(--pad);
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-lt) 35%, var(--gold) 75%, transparent 100%);
  opacity: 0.45;
}

/* ════════════════════════════════════════════════════════════
   BODY LAYOUT
════════════════════════════════════════════════════════════ */
.layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ════════════════════════════════════════════════════════════
   NAV COLUMN — sutra thread
════════════════════════════════════════════════════════════ */
.nav-col {
  width: var(--nav-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sutra-wrap {
  flex: 1;
  display: flex;
  padding: 10px 0 18px;
  position: relative;
}

.sutra-brush-svg {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
}

.sutra-items {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
}

.sutra-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0 11px 0;
  cursor: pointer;
}

.sutra-knot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
  position: relative; z-index: 2;
  opacity: 0; /* SVG draws them */
}

.sutra-label {
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
  transition: color 0.2s;
  white-space: nowrap;
  font-family: var(--font-body);
}
.sutra-item.active .sutra-label {
  color: var(--heading);
  font-weight: 500;
}

/* ════════════════════════════════════════════════════════════
   CONTENT COLUMN
════════════════════════════════════════════════════════════ */
.content-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-body-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 18px var(--pad) 24px;
}

/* Pages */
.page { display: none; flex-direction: column; }
.page.active { display: flex; }

/* ── About ── */
.about-text p {
  margin-bottom: 20px;
  color: var(--text);
  font-size: 15.5px;
  max-width: 62ch;
}
.about-text p:last-child { margin-bottom: 0; }

/* ── Writing list ── */
.writing-list { display: flex; flex-direction: column; }
.writing-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 0.5px solid var(--border);
  text-decoration: none;
  transition: opacity 0.15s;
}
.writing-item:first-child { padding-top: 0; }
.writing-item:hover .wi-title { color: var(--accent); }
.wi-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--heading);
  font-family: var(--font-body);
  transition: color 0.15s;
  flex: 1;
}
.wi-date {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  font-family: var(--font-mono);
  flex-shrink: 0;
}

/* ── Misc ── */
.misc-list { display: flex; flex-direction: column; gap: 14px; }
.misc-item { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); }
.misc-item::before {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--gold); flex-shrink: 0; opacity: 0.75;
}

/* ── Post viewer ── */
.reading-progress {
  position: fixed; top: 0; left: 0;
  width: 0; height: 3px;
  background: var(--accent); z-index: 9998;
  transition: width 0.08s linear;
}

.post-header { margin-bottom: 22px; }
.post-header h1 {
  font-size: 22px; font-weight: 600;
  color: var(--heading); line-height: 1.35;
  margin-bottom: 6px; font-family: var(--font-body);
}
.post-header-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.post-meta { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); }

.print-btn {
  font-family: var(--font-body); font-size: 12px;
  color: var(--text-dim); background: none;
  border: 1px solid var(--border); border-radius: 5px;
  padding: 3px 10px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s; line-height: 1.5;
}
.print-btn:hover { color: var(--text); border-color: var(--text-dim); }

.post-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: 0 0 10px 10px;
  padding: 28px 32px 32px;
  box-shadow: 0 2px 14px rgba(58,48,32,0.06);
}
.post-body { max-width: 66ch; overflow-wrap: break-word; word-break: break-word; }
.post-body h1,.post-body h2,.post-body h3,.post-body h4 {
  font-family: var(--font-body); color: var(--accent);
  line-height: 1.4; margin: 26px 0 9px;
}
.post-body h1 { font-size: 20px; font-weight: 700; }
.post-body h2 { font-size: 16px; font-weight: 700; padding-bottom: 5px; border-bottom: 0.5px solid var(--border); }
.post-body h3 { font-size: 15px; font-weight: 700; }
.post-body p  { font-size: 14.5px; margin-bottom: 16px; color: var(--text); }
.post-body ul,.post-body ol { padding-left: 20px; margin-bottom: 16px; }
.post-body li { font-size: 14.5px; color: var(--text); margin-bottom: 4px; }
.post-body blockquote {
  border-left: 3px solid var(--accent); padding: 10px 18px;
  margin: 18px 0; background: var(--accent-bg);
  border-radius: 0 5px 5px 0; font-style: italic; font-size: 14px;
}
.post-body blockquote p { margin-bottom: 0; }
.post-body hr { border: none; border-top: 0.5px solid var(--border); margin: 28px 0; }
.post-body img { max-width: 100%; border-radius: 7px; margin: 12px 0; border: 1px solid var(--border); display: block; }
.post-body strong { color: var(--heading); font-weight: 600; }
.post-body table { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 13.5px; }
.post-body th { background: var(--bg2); color: var(--heading); font-weight: 600; text-align: left; padding: 9px 12px; border: 1px solid var(--border); }
.post-body td { padding: 7px 12px; border: 1px solid var(--border); color: var(--text); }
.post-body tr:nth-child(even) td { background: var(--bg2); }
.post-body code {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 5px;
  font-family: var(--font-mono); font-size: 12.5px; color: var(--accent2);
}
.post-body pre {
  position: relative; background: var(--panel);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 16px 18px; overflow-x: auto; margin-bottom: 18px;
  max-width: calc(100vw - var(--pad) * 2 - 40px);
}
.post-body pre code { background: none; border: none; padding: 0; color: var(--text); font-size: 13px; line-height: 1.65; }
.copy-btn {
  position: absolute; top: 10px; right: 10px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 5px; padding: 3px 9px;
  font-family: var(--font-body); font-size: 11.5px;
  color: var(--text-dim); cursor: pointer; transition: background 0.15s;
}
.copy-btn:hover { background: var(--accent-bg); color: var(--accent2); }
.copy-btn.copied { color: var(--accent2); background: var(--accent-bg); }

/* Footnotes */
.post-body .footnotes {
  margin-top: 36px; padding-top: 18px;
  border-top: 0.5px solid var(--border);
}
.post-body .footnotes::before {
  content: "Notes"; display: block;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-dim); margin-bottom: 9px;
}
.post-body .footnotes ol { padding-left: 16px; margin-bottom: 0; }
.post-body .footnotes li { font-size: 12.5px; color: var(--text-dim); line-height: 1.65; margin-bottom: 5px; }
.post-body .footnotes li p { font-size: 12.5px; color: var(--text-dim); margin-bottom: 0; display: inline; }

/* Viewers */
.pdf-viewer { width: 100%; height: 82vh; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); }
.image-viewer { max-width: 100%; border-radius: 7px; border: 1px solid var(--border); display: block; margin-bottom: 9px; }
.image-caption { font-size: 12px; color: var(--text-dim); font-family: var(--font-mono); text-align: center; margin-bottom: 18px; }
.html-viewer { width: 100%; min-height: 400px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); }
.state-msg { color: var(--text-dim); font-size: 13.5px; font-family: var(--font-mono); padding: 28px 0; line-height: 1.8; }
.state-msg a { color: var(--accent); }

/* ════════════════════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════════════════ */
footer {
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.footer-left {
  display: flex; align-items: center;
  font-size: 11px; color: var(--text-dim);
  gap: 0; flex-wrap: wrap; row-gap: 4px;
}
.footer-cc {
  color: var(--text-dim); text-decoration: none;
  font-size: 11px; opacity: 0.75; transition: opacity 0.15s;
}
.footer-cc:hover { opacity: 1; text-decoration: underline; }
.footer-dot {
  display: inline-block; width: 3px; height: 3px;
  border-radius: 50%; background: var(--text-dim);
  opacity: 0.35; margin: 0 8px; vertical-align: middle; flex-shrink: 0;
}
.footer-news {
  font-size: 11px; color: var(--gold); text-decoration: none;
  opacity: 0.8; cursor: pointer; white-space: nowrap; transition: opacity 0.15s;
  background: none; border: none; padding: 0; font-family: var(--font-body);
}
.footer-news:hover { opacity: 1; }
.footer-icons { display: flex; gap: 14px; align-items: center; }
.footer-social-link {
  color: var(--text-dim); text-decoration: none;
  opacity: 0.45; transition: opacity 0.18s;
  display: flex; align-items: center;
}
.footer-social-link:hover { opacity: 1; }
.footer-social-link svg { width: 14px; height: 14px; fill: currentColor; display: block; }

/* ════════════════════════════════════════════════════════════
   PRINT
════════════════════════════════════════════════════════════ */
@media print {
  *, *::before, *::after { background: #fff !important; color: #000 !important; box-shadow: none !important; }
  .band, .nav-col, .header-row, .gold-rule, footer,
  .reading-progress, .copy-btn, .print-btn, .skip-link { display: none !important; }
  .site-wrapper { max-width: 100%; padding: 0; }
  .layout { display: block; }
  .content-col { width: 100%; }
  .content-body-wrap { padding: 0; }
  .post-card { border: none !important; padding: 0 !important; border-radius: 0 !important; }
  .post-header h1 { font-size: 20pt; margin-bottom: 4pt; }
  .post-meta { font-size: 9pt; margin-bottom: 14pt; }
  .post-body { max-width: 100%; font-size: 11pt; line-height: 1.6; }
  .post-body h2 { font-size: 13pt; }
  .post-body p { font-size: 11pt; margin-bottom: 9pt; }
  .post-body pre { font-size: 8pt; border: 0.5pt solid #ccc !important; white-space: pre-wrap; }
  .post-body a[href]::after { content: " (" attr(href) ")"; font-size: 8.5pt; color: #555 !important; }
  .post-body a[href^="#"]::after, .post-body .footnotes a::after { content: none; }
  .post-body img { max-width: 100% !important; page-break-inside: avoid; }
  .post-body .footnotes li { font-size: 8.5pt; }
}

/* ════════════════════════════════════════════════════════════
   TABLET  521–860px
════════════════════════════════════════════════════════════ */
@media (min-width: 521px) and (max-width: 860px) {
  :root { --nav-w: 130px; --pad: 28px; }
  .header-name { font-size: 11.5px; }
  .sutra-label { font-size: 9.5px; }
}

/* ════════════════════════════════════════════════════════════
   PHONE  ≤520px
════════════════════════════════════════════════════════════ */
@media (max-width: 520px) {
  :root { --pad: 20px; }
  .header-row { display: none; }
  .gold-rule { margin-left: 0; margin-right: 0; }
  .layout { flex-direction: column; }

  .nav-col {
    width: 100%;
    border-top: 2px solid var(--gold);
    border-bottom: 0.5px solid var(--border);
    flex-direction: row;
  }
  .sutra-wrap { padding: 0; flex: 1; }
  .sutra-brush-svg { display: none; }
  .sutra-items { flex-direction: row; height: 52px; }
  .sutra-item {
    flex: 1; flex-direction: column; justify-content: center;
    padding: 8px 4px; gap: 5px;
    border-left: 0.5px solid var(--border);
  }
  .sutra-item:first-child { border-left: none; }
  .sutra-knot { opacity: 1; width: 7px; height: 7px; margin-left: 0; }
  .sutra-item.active .sutra-knot { border-color: var(--gold); background: var(--gold); }
  .sutra-item.active { border-bottom: 2px solid var(--gold); }
  .sutra-label { font-size: 8px; letter-spacing: 0.1em; }

  .content-body-wrap { padding: 14px var(--pad); }
  .writing-item:first-child { padding-top: 14px; }

  footer { padding: 12px var(--pad); flex-direction: column; align-items: flex-start; gap: 10px; }
  .pdf-viewer { height: 60vh; }
}
