/* ============================================================
   Danson Lim — shared stylesheet
   One file, no build step. Loaded by every page.
   ============================================================ */

/* ---------- Tokens ---------- */
:root {
  --bg: #0b0c10;                /* near-black, ink undertone */
  --bg-raised: #14161d;         /* one step lighter */
  --paper: #f4efe5;             /* warm ivory — reading surface */
  --ink: #16140f;               /* near-black text on paper */
  --ink-soft: #3d3a33;
  --text: #ece7db;              /* warm ivory text on dark */
  --text-muted: #a39d90;
  --accent: #c2622d;            /* burnt orange */
  --accent-bright: #d98a4f;
  --accent-ghost: rgba(194, 98, 45, 0.16);
  --hairline: rgba(236, 231, 219, 0.12);
  --hairline-ink: rgba(22, 20, 15, 0.14);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --measure: 65ch;
  --space-section: clamp(6rem, 12vw, 10rem);
  --pad-x: clamp(1.25rem, 5vw, 3rem);
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 1.0625rem;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; }

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.2em; }

:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 3px; border-radius: 1px; }

::selection { background: var(--accent); color: var(--bg); }

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: var(--bg);
  padding: 0.6rem 1rem; z-index: 200;
}
.skip-link:focus { left: 0; }

/* ---------- Scroll reveal ---------- */
.reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .reveal { opacity: 1; transform: none; transition: none; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation: none !important; }
}

/* ---------- Nav ---------- */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem var(--pad-x);
  transition: box-shadow 0.35s ease;
}
.site-nav::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: rgba(11, 12, 16, 0.86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  opacity: 0; transition: opacity 0.35s ease;
}
.site-nav.is-scrolled { box-shadow: 0 1px 0 var(--hairline); }
.site-nav.is-scrolled::before { opacity: 1; }

/* solid nav variant for pages without a dark hero behind it */
.site-nav.nav-solid::before { opacity: 1; }
.site-nav.nav-solid { box-shadow: 0 1px 0 var(--hairline); }

.nav-mark { font-family: var(--serif); font-size: 1.25rem; color: var(--text); letter-spacing: 0.02em; }
.nav-mark:hover { text-decoration: none; color: var(--accent-bright); }

.nav-links { display: flex; gap: 2.2rem; list-style: none; }
.nav-links a {
  color: var(--text-muted); font-size: 0.8rem; font-weight: 400;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.nav-links a:hover { color: var(--text); text-decoration: none; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; padding: 0.5rem; z-index: 110; }
.nav-toggle span { display: block; width: 24px; height: 1.5px; background: var(--text); margin: 6px 0; transition: transform 0.3s ease, opacity 0.3s ease; }

@media (max-width: 720px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed; inset: 0; flex-direction: column; align-items: center; justify-content: center;
    gap: 2.4rem; background: rgba(11, 12, 16, 0.97);
    opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .nav-links a { font-size: 1rem; }
  .site-nav.is-open .nav-links { opacity: 1; visibility: visible; }
  .site-nav.is-open .nav-toggle span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
  .site-nav.is-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .site-nav.is-open .nav-toggle span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }
}

/* ---------- Section bones ---------- */
section { padding: var(--space-section) var(--pad-x); }
.section-inner { max-width: 1100px; margin: 0 auto; }
.section-label {
  font-size: 0.78rem; font-weight: 500; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--accent-bright); margin-bottom: 2.8rem;
}

/* ---------- Hero ---------- */
.hero {
  min-height: 100svh; display: flex; flex-direction: column;
  justify-content: center; align-items: center; text-align: center;
  background: radial-gradient(ellipse 90% 65% at 50% 38%, #11141d 0%, var(--bg) 70%);
  padding-top: 8rem; padding-bottom: 6rem;
}
.hero h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(3rem, 8.5vw, 5.75rem); line-height: 1.05;
  letter-spacing: 0.01em; color: var(--text);
}
.hero-rule { width: 76px; height: 2px; background: var(--accent); border: none; margin: 2.2rem auto; }
.hero-tagline { font-size: clamp(1rem, 2.4vw, 1.3rem); font-weight: 400; letter-spacing: 0.07em; color: var(--text); margin-bottom: 2.6rem; }
.hero-intro { max-width: 36em; color: var(--text-muted); margin-bottom: 3.2rem; }

.cta {
  display: inline-block; font-size: 0.82rem; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--text);
  border: 1px solid rgba(236, 231, 219, 0.35); padding: 0.95rem 2.4rem;
  transition: border-color 0.3s ease, color 0.3s ease, background 0.3s ease;
}
.cta:hover { text-decoration: none; border-color: var(--accent); color: var(--accent-bright); }

/* ---------- About (single column, no photo) ---------- */
.about .section-inner { max-width: 760px; }
.about .section-label { margin-bottom: 2rem; }
.about-open { font-family: var(--serif); font-weight: 400; font-size: clamp(1.4rem, 3vw, 1.95rem); line-height: 1.45; color: var(--text); margin-bottom: 1.8rem; }
.about p:not(.about-open):not(.section-label) { color: var(--text-muted); margin-bottom: 1.4rem; max-width: var(--measure); }
.about p:last-child { margin-bottom: 0; }
.about strong { font-weight: 500; color: var(--text); }

/* ---------- What I work on ---------- */
.work { background: var(--bg-raised); }
.work .section-inner { max-width: 980px; }
.work .section-label { margin-bottom: 1.2rem; }
.work-lead { color: var(--text-muted); max-width: 56ch; margin-bottom: clamp(2.6rem, 5vw, 3.6rem); }
.work-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: clamp(2rem, 4vw, 3.2rem) clamp(2.5rem, 5vw, 4rem); }
.work-item h3 { font-family: var(--sans); font-size: 1.05rem; font-weight: 500; letter-spacing: 0.02em; color: var(--text); margin-bottom: 0.7rem; }
.work-item h3 .num { font-family: var(--serif); font-style: italic; color: var(--accent-bright); font-size: 0.95rem; margin-right: 0.55rem; }
.work-item p { color: var(--text-muted); font-size: 0.99rem; }
@media (max-width: 680px) { .work-grid { grid-template-columns: 1fr; } }

/* ---------- Writing teaser (home) ---------- */
.writing { background: var(--bg-raised); }
.writing-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-bottom: 2.6rem; }
.writing-head .section-label { margin-bottom: 0; }
.label-bracket { text-transform: none; letter-spacing: 0.01em; font-style: italic; font-weight: 500; color: var(--accent-bright); }
.writing-gloss { font-family: var(--serif); font-style: italic; color: var(--text-muted); font-size: 1.05rem; }
.writing-all { font-size: 0.8rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent-bright); }

.entry-list { list-style: none; }
.entry { padding: clamp(1.6rem, 3vw, 2.2rem) 0; border-top: 1px solid var(--hairline); }
.entry:last-child { border-bottom: 1px solid var(--hairline); }
.entry a { display: block; color: inherit; text-decoration: none; }
.entry a:hover { text-decoration: none; }
.entry a:hover .entry-title { color: var(--accent-bright); }
.entry-meta { font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.7rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.entry-meta .tag { color: var(--accent-bright); }
.entry-title { font-family: var(--serif); font-weight: 500; font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.2; color: var(--text); transition: color 0.25s ease; }
.entry-dek { color: var(--text-muted); margin-top: 0.6rem; max-width: 60ch; }

/* ---------- Diary index page ---------- */
.diary-hero { padding-top: clamp(8rem, 14vw, 11rem); padding-bottom: clamp(2rem, 4vw, 3rem); }
.diary-hero .section-inner { max-width: 760px; }
.diary-title { font-family: var(--serif); font-weight: 600; font-size: clamp(2.4rem, 6vw, 4rem); line-height: 1.08; color: var(--text); }
.diary-bracket { display: block; font-size: 0.5em; font-weight: 500; font-style: italic; color: var(--accent-bright); letter-spacing: 0.01em; margin-top: 0.5rem; }
.diary-expand { font-size: 0.92rem; letter-spacing: 0.04em; color: var(--text-muted); margin-top: 1rem; }
.diary-intro { color: var(--text-muted); margin-top: 1.6rem; max-width: 52ch; }
.diary-list-section { padding-top: clamp(2rem, 4vw, 3rem); }
.diary-list-section .section-inner { max-width: 760px; }

/* ---------- Article (reading) page ---------- */
body.reading { background: var(--paper); color: var(--ink); }
body.reading ::selection { background: var(--accent); color: var(--paper); }
body.reading a { color: var(--accent); }

.read-nav { position: sticky; top: 0; z-index: 100; background: rgba(244, 239, 229, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--hairline-ink); }
.read-nav-inner { max-width: var(--measure); margin: 0 auto; padding: 0.9rem var(--pad-x); display: flex; align-items: center; justify-content: space-between; }
.read-nav a { color: var(--ink-soft); font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; }
.read-nav a:hover { color: var(--accent); text-decoration: none; }
.read-back::before { content: "\2190\00a0\00a0"; }

.article { max-width: var(--measure); margin: 0 auto; padding: clamp(3.5rem, 8vw, 6rem) var(--pad-x) clamp(4rem, 9vw, 7rem); }
.article-meta { font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: 1.4rem; display: flex; gap: 1rem; flex-wrap: wrap; }
.article-meta .date { color: var(--ink-soft); }
.article h1 { font-family: var(--serif); font-weight: 600; font-size: clamp(1.9rem, 5vw, 2.9rem); line-height: 1.2; color: var(--ink); margin-bottom: 1.8rem; }
.article-rule { width: 56px; height: 2px; background: var(--accent); border: none; margin-bottom: 2.2rem; }
.article p { color: var(--ink-soft); font-size: 1.06rem; line-height: 1.85; margin-bottom: 1.4rem; }
.article p:last-of-type { margin-bottom: 0; }
.article p .lede, .article .lede { color: var(--ink); }
.article em { font-style: italic; }
.article strong { font-weight: 600; color: var(--ink); }

.article-foot { max-width: var(--measure); margin: 0 auto; padding: 0 var(--pad-x) clamp(4rem, 9vw, 6rem); border-top: 1px solid var(--hairline-ink); }
.article-foot-inner { padding-top: 2rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; font-size: 0.9rem; }
.article-foot a { color: var(--accent); }

/* ---------- Contact ---------- */
.contact {
  background: radial-gradient(ellipse 90% 70% at 50% 60%, #11141d 0%, var(--bg) 72%);
  text-align: center; padding-top: clamp(7rem, 14vw, 12rem); padding-bottom: clamp(5rem, 10vw, 8rem);
}
.contact-invite { font-family: var(--serif); font-weight: 400; font-size: clamp(1.5rem, 3.6vw, 2.35rem); line-height: 1.4; max-width: 24em; margin: 0 auto 2.4rem; color: var(--text); }
.contact-rule { width: 76px; height: 2px; background: var(--accent); border: none; margin: 0 auto 2.6rem; }
.contact-details { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.8rem 2.6rem; font-size: 0.95rem; color: var(--text-muted); }
.contact-details a { color: var(--text); }
.contact-details a:hover { color: var(--accent-bright); }

/* ---------- Footer ---------- */
footer { padding: 2rem var(--pad-x) 2.6rem; text-align: center; font-size: 0.78rem; letter-spacing: 0.08em; color: rgba(163, 157, 144, 0.55); }
body.reading footer { color: rgba(61, 58, 51, 0.6); }
