/* mostly.media — hand-rolled stylesheet (v2: refined) */

@font-face {
  font-family: "Bai Jamjuree";
  src: url("/fonts/bai-jamjuree-400.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Bai Jamjuree";
  src: url("/fonts/bai-jamjuree-500.woff2") format("woff2");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Bai Jamjuree";
  src: url("/fonts/bai-jamjuree-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --bg: #0d0f13;
  --bg-soft: #12151c;
  --fg: #e8eaf0;
  --fg-muted: #9aa1b0;
  --accent: #6a9bff;
  --accent-dim: #3b62b8;
  --border: #22262f;
  --card: #151923;
  --ok: #3ecf8e;
  --radius: 14px;
  --font: "Bai Jamjuree", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  background: radial-gradient(1200px 800px at 80% -10%, #16203a 0%, var(--bg) 45%) fixed var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header / nav ---------- */
.site-header { border-bottom: 1px solid var(--border); background: rgba(13,15,19,.75); backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20; }
.nav { max-width: 900px; margin: 0 auto; padding: .9rem 1.5rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.12rem; letter-spacing: -.01em; text-decoration: none; color: var(--fg); }
.brand-accent { color: var(--accent); }
.brand::after { content: ""; display: block; width: 0; height: 2px; margin-top: 2px; background: var(--accent); transition: width .25s ease; }
.brand:hover::after { width: 100%; }
.nav-links { list-style: none; display: flex; gap: .3rem; flex-wrap: wrap; }
.nav-links a { color: var(--fg-muted); text-decoration: none; font-size: .94rem; padding: .4rem .7rem; border-radius: 8px; transition: background .15s,color .15s; }
.nav-links a:hover { background: rgba(255,255,255,.05); color: var(--fg); }
.nav-links a.active { color: var(--accent); background: rgba(106,155,255,.08); }

/* ---------- Hero ---------- */
.hero { flex: 1; max-width: 900px; margin: 0 auto; padding: 5.5rem 1.5rem 4rem; }
.eyebrow { color: var(--accent); font-family: var(--mono); font-size: .8rem; letter-spacing: .18em; text-transform: uppercase; margin-bottom: 1rem; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.05; margin-bottom: 1.2rem; }
.lede { font-size: clamp(1.05rem, 2vw, 1.25rem); color: var(--fg-muted); max-width: 52ch; margin-bottom: 2rem; }
.buttons { display: flex; gap: .8rem; flex-wrap: wrap; }
.btn { display: inline-block; background: var(--accent); color: #0a0c10; padding: .65rem 1.3rem; border-radius: 12px; text-decoration: none; font-weight: 700; font-size: .95rem; box-shadow: 0 4px 18px rgba(106,155,255,.22); transition: transform .12s, box-shadow .2s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(106,155,255,.35); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); box-shadow: none; }
.btn-ghost:hover { background: rgba(106,155,255,.08); box-shadow: none; }

/* ---------- Content pages ---------- */
.content { flex: 1; max-width: 900px; margin: 0 auto; padding: 3.5rem 1.5rem 3rem; width: 100%; }
.content h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.2rem; }
.content h2 { font-size: 1.45rem; font-weight: 700; margin: 2rem 0 .8rem; letter-spacing: -.01em; }
.content h2::before { content: ""; display: inline-block; width: .5rem; height: 1.1rem; background: var(--accent); border-radius: 2px; margin-right: .6rem; vertical-align: text-bottom; }
.content p { color: var(--fg-muted); margin-bottom: 1rem; }
.content a { color: var(--accent); text-decoration: none; }
.content a:hover { text-decoration: underline; }

/* Cards */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.4rem; text-decoration: none; color: var(--fg); display: flex; flex-direction: column; gap: .4rem; transition: border-color .15s, transform .12s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.card:hover { border-color: var(--accent-dim); transform: translateY(-2px); }
.card h3 { font-size: 1.12rem; font-weight: 700; }
.card .card-date { font-family: var(--mono); font-size: .78rem; color: var(--fg-muted); }
.card p { font-size: .9rem; color: var(--fg-muted); margin-bottom: 0; }
.card .tag { align-self: flex-start; font-size: .72rem; font-family: var(--mono); color: var(--accent); background: rgba(106,155,255,.1); padding: .15rem .5rem; border-radius: 20px; }

/* List rows (blog posts) */
.post-list { list-style: none; margin-top: 1.5rem; display: flex; flex-direction: column; gap: .4rem; }
.post-list a { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .9rem .3rem; border-bottom: 1px solid var(--border); color: var(--fg); }
.post-list a:hover { color: var(--accent); text-decoration: none; }
.post-list .date { font-family: var(--mono); font-size: .8rem; color: var(--fg-muted); white-space: nowrap; }
.post-list .status { align-self: flex-start; font-size: .72rem; font-family: var(--mono); color: var(--fg-muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 1.4rem 1.5rem; text-align: center; color: var(--fg-muted); font-size: .82rem; font-family: var(--mono); }

/* Placeholder for content not yet written */
.placeholder { color: var(--fg-muted); font-style: italic; font-family: var(--mono); font-size: .9rem; max-width: 55ch; }
.placeholder::before { content: "// "; color: var(--accent-dim); }

/* Small screens */
@media (max-width: 560px) {
  .nav { flex-direction: column; align-items: flex-start; gap: .4rem; }
  .hero { padding-top: 3.5rem; }
  .post-list a { flex-direction: column; gap: .2rem; }
}

/* ---------- Polish pass (v2.1) ---------- */
::selection { background: rgba(106,155,255,.32); color: #fff; }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

.content { max-width: 68ch; }
.content h1 { line-height: 1.1; }
.content p { max-width: 65ch; }
.content p + p { margin-top: .2rem; }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 2.2rem 0; }
.content blockquote {
  border-left: 3px solid var(--accent-dim);
  padding: .4rem 0 .4rem 1rem;
  margin: 1.4rem 0;
  color: var(--fg);
}
.content blockquote p { margin-bottom: .4rem; }
.content code {
  font-family: var(--mono);
  font-size: .86em;
  background: rgba(255,255,255,.06);
  padding: .12rem .38rem;
  border-radius: 6px;
}
.content pre {
  font-family: var(--mono);
  font-size: .85rem;
  line-height: 1.6;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.4rem 0;
}
.content pre code { background: none; padding: 0; }
.content img { max-width: 100%; height: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.content ul, .content ol { color: var(--fg-muted); padding-left: 1.4rem; margin-bottom: 1rem; }
.content li + li { margin-top: .3rem; }

.hero h1 { text-wrap: balance; }
.lede { text-wrap: pretty; }

.card p { flex: 1; }
.card:hover h3 { color: var(--accent); }
.card h3 { transition: color .15s; }

.post-list a { border-radius: 8px; transition: background .15s, padding .15s; }
.post-list a:hover { background: rgba(106,155,255,.06); padding-left: .7rem; padding-right: .7rem; }

.site-footer p { max-width: 900px; margin: 0 auto; }

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

/* ---------- v4: robust pass ---------- */
.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--accent); color: #0a0c10;
  padding: .6rem 1rem; border-radius: 0 0 8px 0;
  font-weight: 700; font-size: .9rem; z-index: 50;
}
.skip:focus { left: 0; }

.eyebrow a { color: var(--accent); text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }

.home-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem; margin-top: 3rem; text-align: left;
}
.home-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.3rem 1.4rem;
  display: flex; flex-direction: column; gap: .5rem;
}
.home-card h2 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.01em; }
.home-card p { font-size: .9rem; color: var(--fg-muted); flex: 1; }
.more { color: var(--accent); text-decoration: none; font-size: .9rem; font-weight: 600; }
.more:hover { text-decoration: underline; }

.post-meta { font-family: var(--mono); font-size: .82rem; color: var(--fg-muted); margin: -.6rem 0 1.4rem; }
.post .lede { font-size: 1.15rem; color: var(--fg); border-left: 3px solid var(--accent-dim); padding-left: 1rem; margin-bottom: 1.8rem; }
.post-dek { font-size: .88rem !important; margin: .2rem 0 0 !important; }

/* ---------- v8: reading experience ---------- */
.toc { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1.1rem; margin: 0 0 1.8rem; font-size: .9rem; }
.toc ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .3rem; }
.toc a { color: var(--fg-muted); text-decoration: none; }
.toc a:hover { color: var(--accent); }
.toc a::before { content: "§ "; color: var(--accent-dim); }

@media print {
  .site-header, .site-footer, .progress, .buttons, .keep-reading, .skip { display: none !important; }
  body { background: #fff; color: #111; }
  .content p, .content li, .post .lede { color: #222; }
  .hero h1 em { background: none; color: #111; }
  .content a { color: #111; }
  .content { max-width: 100%; }
}

/* ---------- v9: header search expander ---------- */
.nav-search { display: flex; align-items: center; }
.nav-search button { background: none; border: 0; cursor: pointer; color: var(--fg-muted);
  padding: .4rem .55rem; border-radius: 8px; display: flex;
  transition: background .15s, color .15s; }
.nav-search button:hover { background: rgba(255,255,255,.05); color: var(--fg); }
.nav-search button[aria-expanded="true"] { color: var(--accent); background: rgba(106,155,255,.08); }
.nav-search svg { width: 18px; height: 18px; }
.search-panel { border-bottom: 1px solid var(--border); background: rgba(13,15,19,.95); }
.search-panel[hidden] { display: none; }
.search-inner { max-width: 900px; margin: 0 auto; padding: .9rem 1.5rem 1.1rem; }
.search-inner input { width: 100%; font: inherit; color: var(--fg); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem 1rem; }
.search-inner input:focus { outline: 2px solid var(--accent); outline-offset: 2px; border-color: var(--accent); }
.search-panel .post-list { margin-top: .6rem; }
.search-more { display: inline-block; margin-top: .6rem; font-size: .88rem; }
.search-more[hidden] { display: none; }

/* ---------- v10: big-screen reading ---------- */
@media (min-width: 1400px) {
  .nav { max-width: 1180px; }
  .hero { max-width: 1180px; padding-top: 7rem; }
  .hero h1 { font-size: clamp(3rem, 5vw, 4.6rem); }
  .lede { font-size: 1.3rem; max-width: 56ch; }
  .content { max-width: 76ch; font-size: 1.08rem; }
  .home-grid { grid-template-columns: repeat(3, 1fr); }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .search-inner { max-width: 1180px; }
}

.site-footer a { color: var(--fg-muted); }
.site-footer a:hover { color: var(--accent); }

@media (max-width: 640px) {
  .home-grid { margin-top: 2rem; }
}

/* ---------- v6: visual identity core ---------- */
:root {
  --bg-raise: #171c27;
  --accent-soft: rgba(106,155,255,.12);
  --accent-ink: #bcd0ff;
  --step--1: clamp(.82rem, .78rem + .2vw, .88rem);
  --step-0: clamp(1rem, .96rem + .3vw, 1.12rem);
  --step-1: clamp(1.35rem, 1.2rem + .8vw, 1.7rem);
  --step-2: clamp(2rem, 1.7rem + 1.6vw, 2.6rem);
  --space: clamp(1rem, .8rem + 1vw, 1.6rem);
}

body { font-size: var(--step-0); }

/* scroll progress (JS fills #progressBar width) */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; background: transparent; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-dim), var(--accent)); }

/* hero: eyebrow rule + gradient voice */
.eyebrow { display: flex; align-items: center; gap: .7rem; }
.eyebrow::after { content: ""; height: 1px; width: 120px; background: var(--border); }
.hero { text-align: left; }
.hero h1 em {
  font-style: normal;
  background: linear-gradient(100deg, var(--accent) 20%, #b388ff 90%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* editorial post details */
.dropcap::first-letter {
  font-size: 3.1em; float: left; line-height: .88;
  padding-right: .12em; font-weight: 800; color: var(--fg);
}
.pullquote {
  font-size: var(--step-1); line-height: 1.4; font-weight: 600;
  letter-spacing: -.01em; color: var(--fg);
  border-left: 3px solid var(--accent); padding-left: 1rem; margin: 1.8rem 0;
}
