/* Theme stylesheet */

:root {
  --bg: #fbfaf8;
  --surface: #ffffff;
  --ink: #211f1d;
  --ink-soft: #57534e;
  --ink-faint: #8c867d;
  --line: #e7e1d7;
  --line-soft: #f1ece3;
  --accent: #bf3e1d;
  --accent-deep: #9c2f15;
  --accent-tint: #fbe9e2;
  --foot-bg: #1a1816;
  --foot-ink: #b0a99f;
  --foot-line: #322e29;

  --font-head: 'Spectral', Georgia, 'Times New Roman', serif;
  --font-body: 'Mulish', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sh-1: 0 1px 2px rgba(33,31,29,.05), 0 2px 8px rgba(33,31,29,.04);
  --sh-2: 0 8px 30px rgba(33,31,29,.10);
  --sh-3: 0 22px 60px rgba(33,31,29,.24);

  --ease: .25s cubic-bezier(.4,0,.2,1);
  --shell: 1120px;
  --read: 760px;
  --bar: 60px;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
/* Lock background scroll while an auth popup is open */
html:has(.authbox:target) { overflow: hidden; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.menu-open { overflow: hidden; }

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--accent-deep); }
ul, ol { list-style: none; }

.shell { width: 100%; max-width: var(--shell); margin: 0 auto; padding: 0 24px; }

.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; }

/* Reading progress */
.rbar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-deep)); z-index: 1100; transition: width .1s linear; }

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(251,250,248,.86);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.topbar.is-stuck { border-bottom-color: var(--line); box-shadow: var(--sh-1); }
.topbar-inner { height: var(--bar); display: flex; align-items: center; gap: 26px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); flex-shrink: 0; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; letter-spacing: -.01em; }

.mainnav { flex: 1; }
.nav-list { display: flex; gap: 4px; }
.nav-link { display: inline-flex; align-items: center; padding: 8px 14px; font-size: .94rem; font-weight: 600; color: var(--ink); border-radius: var(--r-sm); transition: background var(--ease), color var(--ease); }
.nav-link:hover { background: var(--accent-tint); color: var(--accent-deep); }

.tools { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }

/* Search */
.srch { position: relative; display: flex; }
.srch-toggle { display: inline-flex; padding: 8px; border: 0; background: none; cursor: pointer; color: var(--ink); border-radius: var(--r-sm); transition: background var(--ease); }
.srch-toggle:hover { background: var(--line-soft); }
.srch-panel { position: fixed; left: 0; right: 0; top: var(--bar); background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--sh-2); padding: 22px 0; animation: drop .22s var(--ease); }
.srch-panel-inner { max-width: 680px; position: relative; }
.srch-field { width: 100%; padding: 14px 18px; font-family: var(--font-body); font-size: 1.05rem; color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: var(--r-md); outline: none; transition: border-color var(--ease), box-shadow var(--ease); }
.srch-field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
.srch-results { position: absolute; left: 0; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--sh-2); padding: 6px; z-index: 5; }
.srch-item { padding: 11px 14px; font-size: .96rem; color: var(--ink-soft); border-radius: var(--r-sm); cursor: pointer; transition: background var(--ease), color var(--ease); }
.srch-item:hover, .srch-item.is-active { background: var(--accent-tint); color: var(--accent-deep); }

/* Account links */
.acct { display: flex; align-items: center; gap: 12px; }
.acct-link { font-size: .92rem; font-weight: 600; color: var(--ink); padding: 6px 2px; }
.acct-link:hover { color: var(--accent); }

/* Burger */
.burger { display: none; flex-direction: column; gap: 5px; padding: 8px 6px; border: 0; background: none; cursor: pointer; }
.burger span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform var(--ease), opacity var(--ease); }
.burger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger.is-open span:nth-child(2) { opacity: 0; }
.burger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; font-family: var(--font-body); font-size: .94rem; font-weight: 700; color: #fff; background: var(--accent); border: 2px solid var(--accent); border-radius: var(--r-md); cursor: pointer; white-space: nowrap; transition: background var(--ease), border-color var(--ease), transform var(--ease), box-shadow var(--ease); }
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; transform: translateY(-1px); box-shadow: var(--sh-1); }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 8px 16px; font-size: .86rem; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--accent-tint); color: var(--accent-deep); border-color: var(--accent); }

/* Stage: content as high as possible, flat reading column */
.stage { display: block; }
.read { max-width: var(--read); margin: 0 auto; padding: 40px 0 60px; }

/* Article (flat, no card) */
.story-head { margin-bottom: 30px; }
.story-title { font-family: var(--font-head); font-weight: 700; font-size: clamp(2rem, 4.4vw, 2.85rem); line-height: 1.18; letter-spacing: -.015em; margin-bottom: 16px; }
.story-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: .85rem; color: var(--ink-faint); }
.story-meta-item { display: inline-flex; align-items: center; gap: 6px; }
.story-meta-item svg { opacity: .65; }

/* Table of contents */
.toc { margin-bottom: 32px; background: var(--accent-tint); border: 1px solid #f1cdbf; border-radius: var(--r-md); padding: 18px 22px; }
.toc-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.toc-title { font-family: var(--font-body); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--accent-deep); }
.toc-toggle { border: 0; background: none; cursor: pointer; font-size: 1.2rem; line-height: 1; color: var(--accent-deep); padding: 0 4px; }
.toc-links { display: flex; flex-direction: column; gap: 7px; }
.toc-link { font-size: .92rem; color: var(--ink-soft); transition: color var(--ease); }
.toc-link:hover { color: var(--accent-deep); }
.toc-link-sub { padding-left: 18px; font-size: .86rem; position: relative; }
.toc-link-sub::before { content: ""; position: absolute; left: 4px; top: .65em; width: 6px; height: 1px; background: var(--ink-faint); }

/* Article body (the only place with real headings) */
.story-body { font-size: 1.085rem; line-height: 1.85; color: #322f2b; }
.story-body > * + * { margin-top: 1.25em; }
.story-body h2 { font-family: var(--font-head); font-weight: 600; font-size: 1.72rem; margin-top: 1.9em; margin-bottom: .1em; letter-spacing: -.01em; scroll-margin-top: calc(var(--bar) + 16px); }
.story-body h3 { font-family: var(--font-head); font-weight: 600; font-size: 1.34rem; margin-top: 1.5em; margin-bottom: .1em; scroll-margin-top: calc(var(--bar) + 16px); }
.story-body h4 { font-family: var(--font-head); font-weight: 600; font-size: 1.14rem; margin-top: 1.3em; }
.story-body p { margin-bottom: 0; }
.story-body a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.story-body a:hover { color: var(--accent-deep); }
.story-body ul, .story-body ol { padding-left: 1.4em; }
.story-body ul { list-style: disc; }
.story-body ol { list-style: decimal; }
.story-body li { margin-bottom: .4em; }
.story-body li::marker { color: var(--accent); }
.story-body blockquote { border-left: 3px solid var(--accent); background: var(--bg); padding: 16px 22px; border-radius: 0 var(--r-sm) var(--r-sm) 0; font-family: var(--font-head); font-style: italic; font-size: 1.14rem; color: var(--ink-soft); }
.story-body img { border-radius: var(--r-md); }
.story-body figure { margin: 1.6em 0; }
.story-body figcaption { margin-top: .6em; font-size: .85rem; color: var(--ink-faint); text-align: center; }
.story-body pre { background: #20232a; color: #e6e8ee; padding: 20px 22px; border-radius: var(--r-md); overflow-x: auto; font-size: .9rem; line-height: 1.65; }
.story-body code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--line-soft); padding: .15em .4em; border-radius: 4px; }
.story-body pre code { background: none; padding: 0; }
.story-body table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.story-body th, .story-body td { padding: 11px 14px; border: 1px solid var(--line); text-align: left; }
.story-body th { background: var(--bg); font-weight: 700; }
.story-body hr { border: 0; height: 1px; background: var(--line); margin: 2em 0; }

/* Share */
.story-share { margin-top: 36px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.share-label { font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-faint); }
.share-list { display: flex; gap: 8px; }
.share-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); color: var(--ink-soft); cursor: pointer; transition: border-color var(--ease), color var(--ease), background var(--ease), transform var(--ease); }
.share-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); transform: translateY(-2px); }
.ico-done { display: none; color: var(--accent); }
.share-btn-copy.is-copied .ico-copy { display: none; }
.share-btn-copy.is-copied .ico-done { display: block; }
.share-btn-copy.is-copied { border-color: var(--accent); }

.divider { border: 0; height: 1px; background: var(--line); margin: 40px 0; }

/* Section titles rendered as spans (not headings) */
.sec-title { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.44rem; margin-bottom: 22px; position: relative; padding-bottom: 12px; }
.sec-title::after { content: ""; position: absolute; left: 0; bottom: 0; width: 44px; height: 3px; background: var(--accent); border-radius: 2px; }

/* Related */
.morefrom { margin-top: 8px; }
.rel-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.rel-card { display: block; padding: 20px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease); }
.rel-card:hover { border-color: var(--accent); box-shadow: var(--sh-1); transform: translateX(3px); }
.rel-title { display: block; font-family: var(--font-head); font-size: 1.06rem; font-weight: 600; color: var(--ink); }

/* Comments */
.discuss { margin-top: 52px; }
.cform { display: flex; flex-direction: column; gap: 16px; }
.cform-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Fields */
.inp { width: 100%; padding: 13px 16px; font-family: var(--font-body); font-size: .96rem; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); outline: none; transition: border-color var(--ease), box-shadow var(--ease); }
.inp::placeholder { color: var(--ink-faint); }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-tint); }
.inp-area { resize: vertical; min-height: 120px; }

/* Widgets band (below content) */
.extra { border-top: 1px solid var(--line); background: var(--bg); padding: 56px 0; }
.wgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; align-items: start; }
.widget { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-lg); padding: 28px; box-shadow: var(--sh-1); }
.widget .widget-title { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.16rem; margin-bottom: 8px; }
.widget-text { font-size: .9rem; color: var(--ink-soft); margin-bottom: 16px; }
.nlform, .cnform { display: flex; flex-direction: column; gap: 12px; }
.popular { display: flex; flex-direction: column; }
.pop-item { border-bottom: 1px solid var(--line-soft); }
.pop-item:last-child { border-bottom: 0; }
.pop-item a { display: block; padding: 12px 0; font-size: .94rem; color: var(--ink); transition: color var(--ease), padding var(--ease); }
.pop-item a:hover { color: var(--accent); padding-left: 6px; }

/* Footer */
.pagefoot { background: var(--foot-bg); color: var(--foot-ink); padding: 50px 0 40px; }
.foot-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; flex-wrap: wrap; }
.brand-light .brand-name { color: #fff; }
.brand-light { color: #fff; margin-bottom: 8px; }
.foot-brand { display: flex; flex-direction: column; gap: 2px; }
.foot-copy { font-size: .85rem; color: var(--foot-ink); }
.social { display: flex; gap: 10px; }
.social-link { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--r-sm); background: rgba(255,255,255,.07); color: var(--foot-ink); transition: background var(--ease), color var(--ease), transform var(--ease); }
.social-link:hover { background: var(--accent); color: #fff; transform: translateY(-2px); }
.foot-nav { display: flex; gap: 22px; }
.foot-link { font-size: .9rem; color: var(--foot-ink); }
.foot-link:hover { color: #fff; }

/* Back to top */
.totop { position: fixed; right: 28px; bottom: 28px; width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; border: 0; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-2); opacity: 0; visibility: hidden; transform: translateY(14px) scale(.9); transition: opacity var(--ease), visibility var(--ease), transform var(--ease), background var(--ease); z-index: 900; }
.totop.is-visible { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.totop:hover { background: var(--accent-deep); transform: translateY(-3px) scale(1); }

/* Cookie bar */
.cookie { position: fixed; left: 0; right: 0; bottom: 0; background: var(--foot-bg); color: #d6dbd9; z-index: 950; padding: 16px 0; box-shadow: 0 -4px 24px rgba(0,0,0,.18); animation: rise .3s var(--ease); }
.cookie-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.cookie-text { font-size: .88rem; flex: 1; min-width: 240px; }
.cookie-text a { color: #f0a98f; }

/* Auth popup via :target (markup at very bottom of HTML) */
.authbox { display: none; position: fixed; inset: 0; z-index: 1200; align-items: center; justify-content: center; padding: 24px; }
.authbox:target { display: flex; }
.authbox-overlay { position: absolute; inset: 0; background: rgba(26,24,22,.55); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .25s var(--ease); }
.authbox-card { position: relative; width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-3); padding: 34px; animation: pop .28s var(--ease); }
.authbox-close { position: absolute; top: 12px; right: 16px; font-size: 1.7rem; line-height: 1; color: var(--ink-faint); }
.authbox-close:hover { color: var(--ink); }
.authbox-title { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.5rem; margin-bottom: 22px; }
.aform { display: flex; flex-direction: column; gap: 14px; }
.aform-foot { display: flex; justify-content: space-between; font-size: .85rem; margin-top: 2px; }
.aform-foot-center { justify-content: center; color: var(--ink-soft); }

/* Animations */
@keyframes drop { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Responsive */
@media (max-width: 960px) {
  .wgrid { grid-template-columns: 1fr 1fr; }
  .widget:last-child { grid-column: 1 / -1; }
}

@media (max-width: 720px) {
  :root { --bar: 56px; }
  body { font-size: 16px; }
  .mainnav, .acct { display: none; }
  .burger { display: flex; }
  .mainnav.is-open { display: block; position: fixed; inset: var(--bar) 0 0 0; background: var(--surface); padding: 16px 24px; z-index: 999; overflow-y: auto; animation: drop .22s var(--ease); }
  .mainnav.is-open .nav-list { flex-direction: column; gap: 2px; }
  .mainnav.is-open .nav-link { padding: 15px 12px; font-size: 1.05rem; border-bottom: 1px solid var(--line-soft); border-radius: 0; }
  .read { padding: 28px 0 48px; }
  .cform-row { grid-template-columns: 1fr; }
  .wgrid { grid-template-columns: 1fr; }
  .widget:last-child { grid-column: auto; }
  .foot-inner { flex-direction: column; align-items: flex-start; gap: 22px; }
}

@media (max-width: 480px) {
  .shell { padding: 0 18px; }
  .story-share { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
