/*
  Design system for chnkukoolwal.vc (sandbox).

  Shares its DNA with the Avvyun homepage (https://new.avvyun.vc) — same
  serif+sans pairing, same warm bronze/oxblood colour family, same
  restraint, same motion philosophy. But the hierarchy is deliberately
  inverted: Avvyun is the institution (cream canvas, oxblood type, dark
  CTA). This is the person (oxblood/espresso canvas, cream type, light
  CTA) — same colour family, reciprocal roles. Not a copy, and not dark
  mode: a considered emotional inversion. Structurally it remains its
  own thing — a persistent editorial sidebar, mask-reveal typography,
  alternating editorial rows — none of it borrowed from Avvyun's
  component vocabulary.
*/

/* ---------- Tokens ---------- */
:root {
  /* Canvas — deep espresso/oxblood, the inversion of Avvyun's cream. */
  --c-bg: #241209;
  --c-bg-raised: #33190e;
  --c-bg-deep: #170a03;

  /* Type — warm cream primary, muted taupe secondary. */
  --c-text: #f4ebe0;
  --c-text-soft: #c2a891;
  --c-text-faint: rgba(244, 235, 224, 0.52);

  /* Accent — bronze/rose-gold, same family as Avvyun's tan, brightened
     so it still sings against a dark canvas. */
  --c-accent: #cc9f6d;
  --c-accent-strong: #e2b688;

  /* Hairlines on dark. */
  --c-border: rgba(244, 235, 224, 0.14);
  --c-border-strong: rgba(244, 235, 224, 0.28);

  /* CTA — light bronze fill + dark text: the reciprocal of Avvyun's
     dark-oxblood-fill + white text. */
  --c-cta-bg: var(--c-accent);
  --c-cta-bg-hover: var(--c-accent-strong);
  --c-cta-text: var(--c-bg-deep);

  --c-selection: rgba(204, 159, 109, 0.28);
  --c-focus: var(--c-accent);

  --font-serif: "Fraunces", "Merriweather", Georgia, serif;
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;

  --rail-w: 17rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --content-max: 40rem;

  --ease-reveal: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-quick: 220ms;
  --dur-reveal: 850ms;
  --dur-photo: 1200ms;

  color-scheme: dark;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100svh;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, picture, svg { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; padding: 0; }
button, input, textarea { font: inherit; color: inherit; background: none; border: 0; }
button { cursor: pointer; }

::selection { background: var(--c-selection); color: var(--c-text); }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 3px; }

.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--c-accent);
  color: var(--c-bg-deep);
  padding: 0.75rem 1.25rem;
  z-index: 200;
  font-size: 0.875rem;
}
.skip-link:focus { top: var(--space-2); }

/* ---------- Frame: persistent editorial sidebar + main column ---------- */
.frame { display: flex; align-items: stretch; min-height: 100svh; }

.rail {
  width: var(--rail-w);
  flex: none;
  position: sticky;
  top: 0;
  height: 100svh;
  padding: var(--space-6) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--c-border);
}

.rail__word {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 500;
  font-size: 1.25rem;
  color: var(--c-text);
}

.rail__nav { display: flex; flex-direction: column; gap: var(--space-4); margin-top: var(--space-9); }
.rail__nav a {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--c-text-soft);
  transition: color var(--dur-quick) var(--ease-soft);
}
.rail__nav a::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: transparent;
  transition: background var(--dur-quick) var(--ease-soft);
  flex: none;
}
.rail__nav a:hover, .rail__nav a[aria-current="page"] { color: var(--c-text); }
.rail__nav a:hover::before, .rail__nav a[aria-current="page"]::before { background: var(--c-accent); }

.rail__foot { display: flex; flex-direction: column; gap: var(--space-4); }
.rail__avvyun {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--c-cta-text);
  background: var(--c-cta-bg);
  padding: 0.75em 1.1em;
  border-radius: 2px;
  text-align: center;
  transition: background-color var(--dur-quick) ease;
}
.rail__avvyun:hover { background: var(--c-cta-bg-hover); }
.rail__note { font-size: 0.75rem; color: var(--c-text-faint); line-height: 1.5; }

.utility-links { display: flex; gap: var(--space-4); }
.utility-links a {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--c-text-soft);
  transition: color var(--dur-quick) var(--ease-soft);
}
.utility-links a:hover { color: var(--c-text); }

.frame__main { flex: 1; min-width: 0; }

/* Mobile top bar — hidden on desktop, replaces the rail below the breakpoint. */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 80;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--gutter);
  background: rgba(36, 18, 9, 0.92);
  border-bottom: 1px solid transparent;
  transition: border-color var(--dur-quick) ease;
}
.mobile-bar[data-scrolled="true"] { border-bottom-color: var(--c-border); }
.mobile-bar__word { font-family: var(--font-serif); font-style: italic; font-weight: 500; font-size: 1.1rem; color: var(--c-text); }

.drawer-toggle { display: flex; flex-direction: column; gap: 5px; padding: var(--space-2); }
.drawer-toggle span { width: 20px; height: 1px; background: var(--c-text); transition: transform var(--dur-quick) ease, opacity var(--dur-quick) ease; }

@media (max-width: 900px) {
  .rail { display: none; }
  .mobile-bar { display: flex; }
}

/* Mobile drawer — a partial-width panel from the right, not a full-screen
   centred overlay. Sibling of everything else so it's never affected by
   an ancestor's backdrop-filter / transform. */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}
.drawer__scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity var(--dur-reveal) var(--ease-soft);
}
.drawer__panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(20rem, 84vw);
  background: var(--c-bg-raised);
  padding: var(--space-8) var(--space-6) var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transform: translateX(100%);
  transition: transform var(--dur-reveal) var(--ease-reveal);
}
.drawer[data-open="true"] { pointer-events: auto; }
.drawer[data-open="true"] .drawer__scrim { opacity: 1; }
.drawer[data-open="true"] .drawer__panel { transform: translateX(0); }

.drawer__list { display: flex; flex-direction: column; gap: var(--space-5); }
.drawer__list a { font-family: var(--font-serif); font-weight: 480; font-size: 1.6rem; color: var(--c-text); }
.drawer__foot { display: flex; flex-direction: column; gap: var(--space-4); }

@media (min-width: 901px) {
  .drawer { display: none; }
}

/* ---------- Content primitives ---------- */
.wrap { max-width: 68rem; margin-inline: auto; padding-inline: var(--gutter); }
.content { max-width: var(--content-max); }
.block { padding-block: var(--space-8); }
.block + .block { border-top: 1px solid var(--c-border); }
.block-raised { background: var(--c-bg-raised); }

@media (max-width: 720px) {
  .block { padding-block: var(--space-7); }
}

/* ---------- Type ---------- */
.caption {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: var(--c-text-faint);
}

.signature-tagline {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 460;
  font-size: clamp(2.1rem, 1.7rem + 2.1vw, 3.6rem);
  line-height: 1.18;
  letter-spacing: -0.005em;
  color: var(--c-text);
  max-width: 16ch;
}
.signature-tagline .accent { color: var(--c-accent); }

h1, h2, .h2 {
  font-family: var(--font-serif);
  font-weight: 520;
  font-size: clamp(1.6rem, 1.35rem + 1.1vw, 2.4rem);
  line-height: 1.18;
  letter-spacing: -0.008em;
  color: var(--c-text);
}

h3, .h3 {
  font-family: var(--font-serif);
  font-weight: 520;
  font-size: clamp(1.2rem, 1.1rem + 0.4vw, 1.45rem);
  line-height: 1.28;
  color: var(--c-text);
}

.lede {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.1rem);
  line-height: 1.7;
  color: var(--c-text-soft);
}

p { max-width: 38em; }
.prose-body p {
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: 1.03rem;
  line-height: 1.8;
  color: var(--c-text-soft);
}
.prose-body p + p { margin-top: var(--space-4); }
.prose-body a { border-bottom: 1px solid var(--c-border-strong); }
.prose-body a:hover { border-color: var(--c-text); }

.meta { font-family: var(--font-sans); font-weight: 500; font-size: 0.8125rem; color: var(--c-text-soft); }
.text-muted { color: var(--c-text-faint); }

/* ---------- Links ---------- */
.text-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  color: var(--c-text);
  border-bottom: 1px solid var(--c-border-strong);
  padding-bottom: 0.05em;
  transition: color var(--dur-quick) var(--ease-soft), border-color var(--dur-quick) var(--ease-soft);
}
.text-link:hover { color: var(--c-accent); border-color: var(--c-accent); }
.text-link .arrow { transition: transform var(--dur-quick) var(--ease-soft); }
.text-link:hover .arrow { transform: translateX(0.15em); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 0.9375rem;
  padding: 0.85em 1.5em;
  border-radius: 2px;
  transition: transform var(--dur-quick) var(--ease-soft), background-color var(--dur-quick) ease;
}
.btn-primary { background: var(--c-cta-bg); color: var(--c-cta-text); }
.btn-primary:hover { background: var(--c-cta-bg-hover); transform: translateY(-1px); }

/* ---------- Mask reveal — the site's own signature motion. Text/blocks
   are revealed by widening a clip-path, like a shutter opening, rather
   than fading up (Avvyun's language) or blurring in. ---------- */
.mask-reveal {
  clip-path: inset(0 100% -20% 0);
  transition: clip-path var(--dur-reveal) var(--ease-reveal);
}
.mask-reveal.is-visible { clip-path: inset(0 0 -20% 0); }

.fade-in {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--dur-reveal) var(--ease-soft), transform var(--dur-reveal) var(--ease-soft);
}
.fade-in.is-visible { opacity: 1; transform: none; }

/* Photos emerge from the canvas itself, not from a light sheet — a dark
   panel recedes as the image settles from a slight zoom. */
.photo-reveal {
  position: relative;
  overflow: hidden;
  background: var(--c-bg-deep);
}
.photo-reveal img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.08);
  transition: transform var(--dur-photo) var(--ease-reveal);
}
.photo-reveal::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--c-bg);
  transform-origin: top;
  transition: transform var(--dur-photo) var(--ease-reveal);
}
.photo-reveal.is-visible img { transform: scale(1); }
.photo-reveal.is-visible::after { transform: scaleY(0); }

@media (prefers-reduced-motion: reduce) {
  .mask-reveal, .fade-in { clip-path: none !important; opacity: 1 !important; transform: none !important; transition: none !important; }
  .photo-reveal img { transform: none !important; transition: none !important; }
  .photo-reveal::after { transform: scaleY(0) !important; transition: none !important; }
  .drawer__panel, .drawer__scrim { transition: none !important; }
}

/* ---------- Masthead (home) ---------- */
.masthead__grid {
  display: grid;
  gap: var(--space-7);
  align-items: end;
}
@media (min-width: 760px) {
  .masthead__grid { grid-template-columns: 1.3fr 0.9fr; }
}

.masthead__role { margin-top: var(--space-5); max-width: 32ch; }

.masthead__photo { aspect-ratio: 4 / 5; max-width: 22rem; margin-left: auto; }
@media (min-width: 760px) {
  .masthead__photo { margin-top: var(--space-8); }
}

/* ---------- Editorial focus rows (current focus / building) ---------- */
.focus-primary {
  padding-top: var(--space-6);
  border-top: 1px solid var(--c-border);
  display: grid;
  gap: var(--space-4);
}
@media (min-width: 700px) {
  .focus-primary { grid-template-columns: 9rem 1fr; gap: var(--gutter); }
}
.focus-primary__title { margin-top: 0.4rem; }
.focus-primary__title a:hover { color: var(--c-accent); }

.focus-secondary {
  display: grid;
  gap: var(--space-6);
  margin-top: var(--space-7);
}
@media (min-width: 700px) {
  .focus-secondary { grid-template-columns: repeat(2, 1fr); }
}
.focus-secondary > div { padding-top: var(--space-4); border-top: 1px solid var(--c-border); }
.focus-secondary h3 { margin-top: 0.35rem; }
.focus-secondary h3 a:hover { color: var(--c-accent); }

/* ---------- Rows (timeline / now / writing index / contact) ---------- */
.row-list { display: grid; }
.row {
  display: grid;
  gap: var(--space-2) var(--gutter);
  padding-block: var(--space-4);
  border-top: 1px solid var(--c-border);
}
.row-list > :last-child { border-bottom: 1px solid var(--c-border); }
@media (min-width: 620px) {
  .row { grid-template-columns: 8rem 1fr; align-items: baseline; }
}
.row__title { font-family: var(--font-serif); font-weight: 500; font-size: 1.08rem; }
a.row { transition: color var(--dur-quick) ease; }
a.row:hover .row__title { color: var(--c-accent); }

.row--split { grid-template-columns: 1fr auto; align-items: baseline; }

/* ---------- About page two-column background/timeline split ---------- */
.about-cols { display: grid; gap: var(--space-7); }
@media (min-width: 760px) {
  .about-cols { grid-template-columns: 1.1fr 0.9fr; }
}

/* ---------- Theme list (writing themes / what I care about) ---------- */
.theme-list { margin-top: var(--space-4); display: grid; gap: 0.65rem; }
.theme-list li { padding-left: 1.3em; position: relative; color: var(--c-text-soft); }
.theme-list li::before { content: "·"; position: absolute; left: 0.2em; color: var(--c-accent); font-size: 1.4em; line-height: 0.7; }

/* ---------- Footer (minimal — the rail already carries navigation) ---------- */
.site-footer {
  padding-block: var(--space-6);
  border-top: 1px solid var(--c-border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-6);
  align-items: center;
  justify-content: space-between;
}
.site-footer .meta { display: flex; gap: var(--space-5); }
.site-footer a:hover { color: var(--c-accent); }

/* ---------- 404 ---------- */
.not-found {
  min-height: 80svh;
  display: flex;
  align-items: center;
  padding-block: var(--space-9);
}
.not-found p.lede { margin-top: var(--space-3); }
