/* ═══════════════════════════════════════════════════════════════
   Base Styles — Narin Fazlalipour
   ═══════════════════════════════════════════════════════════════ */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: var(--t-body);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  font-feature-settings: "kern", "liga", "calt", "onum";
}

/* ── Decorative background ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 50% at 8% -5%, rgba(44, 90, 160, 0.06), transparent 60%),
    radial-gradient(ellipse 60% 45% at 95% 5%, rgba(184, 146, 74, 0.04), transparent 60%),
    var(--bg);
}

/* ── Paper grain overlay ── */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.035;
  mix-blend-mode: multiply;
  background-image:
    radial-gradient(var(--ink) 1px, transparent 1px),
    radial-gradient(var(--ink) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 3px;
}

/* ── Typography ── */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.15;
  color: var(--fg);
  margin: 0 0 0.5em;
}

h1 em, h2 em, h3 em { font-style: italic; font-weight: 400; color: var(--royal); }

p { margin: 0 0 0.9em; max-width: 68ch; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 600; color: var(--royal-dark); }
em { font-style: italic; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--border-accent);
  transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
a:hover {
  color: var(--accent-hover);
  border-color: var(--accent-hover);
}
a:focus-visible {
  outline: none;
  border-radius: 3px;
  box-shadow: var(--shadow-ring);
}

::selection { background: var(--royal-accent); color: var(--cream); }
::-moz-selection { background: var(--royal-accent); color: var(--cream); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--royal-soft);
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--royal-light); }

/* ── Wrap ── */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── Reading progress bar ── */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--royal-accent), var(--royal-light));
  z-index: 200;
  transition: width var(--xfast) linear, opacity var(--med) var(--ease);
  opacity: 0;
  pointer-events: none;
}
.read-progress.is-active { opacity: 1; }

/* ── Skip to content (a11y) ── */
.skip-link {
  position: absolute;
  left: -10000px;
  top: 0;
  background: var(--royal-deep);
  color: var(--cream);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
  font-family: var(--font-sans);
  font-size: var(--t-small);
  z-index: 999;
}
.skip-link:focus { left: 0; }
