/* ============================================================
   kohlagos.com — "State Paper"
   A modern government gazette: forest-ink on warm ivory, gold
   hairlines, oversized serif. Dignified, editorial, 2026.
   ============================================================ */

@layer reset, tokens, base, layout, components, motion, utilities;

/* ---------- reset ---------- */
@layer reset {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
  }
  html {
    -webkit-text-size-adjust: 100%;
  }
  body {
    min-height: 100dvh;
  }
  img,
  svg {
    display: block;
    max-width: 100%;
  }
  a {
    color: inherit;
    text-decoration: none;
  }
  button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
  }
  ul,
  ol {
    list-style: none;
    padding: 0;
  }
  h1,
  h2,
  h3 {
    font-weight: inherit;
    text-wrap: balance;
  }
}

/* ---------- tokens ---------- */
@layer tokens {
  :root {
    /* type */
    --display: "Fraunces", "Cormorant Garamond", Georgia, serif;
    --serif: "Newsreader", Georgia, "Times New Roman", serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    /* light palette (default) */
    --ink: oklch(0.26 0.045 160);
    --bg: oklch(0.975 0.012 95);
    --bg-2: oklch(0.95 0.016 92);
    --gold: oklch(0.66 0.09 82);
    --muted: oklch(0.5 0.02 160);
    --line: color-mix(in oklch, var(--ink) 15%, transparent);
    --line-strong: color-mix(in oklch, var(--ink) 30%, transparent);

    /* dark band (Connect / footer) is always deep forest */
    --forest: oklch(0.19 0.03 162);
    --forest-2: oklch(0.23 0.035 162);
    --gold-bright: oklch(0.78 0.1 85);
    --ivory: oklch(0.93 0.015 95);

    --maxw: 1180px;
    --gutter: clamp(1.5rem, 6vw, 5rem);

    --grain-blend: multiply;
    --grain-opacity: 0.055;
    color-scheme: light;
  }

  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --ink: oklch(0.93 0.015 95);
      --bg: oklch(0.19 0.03 162);
      --bg-2: oklch(0.23 0.035 162);
      --gold: oklch(0.78 0.1 85);
      --muted: oklch(0.68 0.02 150);
      --line: color-mix(in oklch, var(--ink) 16%, transparent);
      --line-strong: color-mix(in oklch, var(--ink) 32%, transparent);
      --grain-blend: screen;
      --grain-opacity: 0.05;
      color-scheme: dark;
    }
  }

  :root[data-theme="dark"] {
    --ink: oklch(0.93 0.015 95);
    --bg: oklch(0.19 0.03 162);
    --bg-2: oklch(0.23 0.035 162);
    --gold: oklch(0.78 0.1 85);
    --muted: oklch(0.68 0.02 150);
    --line: color-mix(in oklch, var(--ink) 16%, transparent);
    --line-strong: color-mix(in oklch, var(--ink) 32%, transparent);
    --grain-blend: screen;
    --grain-opacity: 0.05;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
@layer base {
  body {
    font-family: var(--serif);
    font-size: 1.075rem;
    line-height: 1.7;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background 0.4s ease, color 0.4s ease;
  }

  ::selection {
    background: color-mix(in oklch, var(--gold) 35%, transparent);
  }

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

  p {
    text-wrap: pretty;
  }

  /* paper grain */
  .grain {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    opacity: var(--grain-opacity);
    mix-blend-mode: var(--grain-blend);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  }

  .skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    z-index: 100;
    background: var(--ink);
    color: var(--bg);
    padding: 0.6rem 1rem;
    font-family: var(--sans);
    font-size: 0.85rem;
  }
  .skip-link:focus {
    left: 1rem;
    top: 1rem;
  }
}

/* ---------- layout ---------- */
@layer layout {
  .wrap {
    width: 100%;
    max-width: var(--maxw);
    margin-inline: auto;
    padding-inline: var(--gutter);
  }
  .measure {
    max-width: 66ch;
  }
  .center {
    text-align: center;
  }
  .center .measure,
  .measure.center {
    margin-inline: auto;
  }

  .band {
    position: relative;
    z-index: 2;
    padding-block: clamp(4rem, 10vw, 8rem);
    border-top: 1px solid var(--line);
  }
  .band-alt {
    background: var(--bg-2);
  }
}

/* ---------- components ---------- */
@layer components {
  /* rules */
  .rule {
    border: 0;
    height: 1px;
    background: var(--line-strong);
  }
  .rule-gold {
    height: 2px;
    background: linear-gradient(
      90deg,
      var(--gold),
      color-mix(in oklch, var(--gold) 20%, transparent)
    );
    margin-block: clamp(1.5rem, 3vw, 2.2rem);
    max-width: 8rem;
  }

  /* section marker: "01 / About" */
  .marker {
    font-family: var(--sans);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 1.4rem;
    display: flex;
    align-items: center;
    gap: 0.55rem;
  }
  .marker span {
    color: var(--gold);
    font-variant-numeric: tabular-nums;
  }

  /* headings */
  h2 {
    font-family: var(--display);
    font-optical-sizing: auto;
    font-weight: 560;
    font-size: clamp(2rem, 4.2vw, 3.2rem);
    line-height: 1.05;
    letter-spacing: -0.015em;
    max-width: 18ch;
    margin-bottom: 1.6rem;
  }

  /* ---- masthead ---- */
  .masthead {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in oklch, var(--bg) 82%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
  }
  .masthead-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    height: 76px;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
  }
  .brand-mark {
    font-family: var(--sans);
    font-weight: 600;
    font-size: 0.66rem;
    letter-spacing: 0.18em;
    color: var(--gold);
    border: 1px solid var(--gold);
    border-radius: 2px;
    padding: 0.32rem 0.44rem;
  }
  .brand-name {
    font-family: var(--display);
    font-size: 1.35rem;
    font-weight: 560;
    letter-spacing: 0.01em;
  }
  .nav {
    display: flex;
    gap: 2rem;
    margin-left: auto;
  }
  .nav a {
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    position: relative;
    padding-block: 0.4rem;
    transition: color 0.25s;
  }
  .nav-idx {
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    font-size: 0.72rem;
    margin-right: 0.15rem;
  }
  .nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }
  .nav a:hover {
    color: var(--ink);
  }
  .nav a:hover::after {
    transform: scaleX(1);
  }

  .theme-toggle {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--line-strong);
    border-radius: 2px;
    color: var(--ink);
    transition: border-color 0.25s, color 0.25s;
  }
  .theme-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
  }
  .theme-toggle svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .ic-moon {
    display: none;
  }
  /* show moon in dark */
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .ic-sun {
      display: none;
    }
    :root:not([data-theme="light"]) .ic-moon {
      display: block;
    }
  }
  :root[data-theme="dark"] .ic-sun {
    display: none;
  }
  :root[data-theme="dark"] .ic-moon {
    display: block;
  }
  :root[data-theme="light"] .ic-sun {
    display: block;
  }
  :root[data-theme="light"] .ic-moon {
    display: none;
  }

  /* ---- hero ---- */
  .hero {
    position: relative;
    z-index: 2;
    padding-block: clamp(3.5rem, 8vw, 7rem) clamp(3.5rem, 9vw, 7.5rem);
  }
  .hero-inner {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: clamp(2rem, 6vw, 5rem);
    align-items: center;
  }
  .doc-meta {
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
    margin-bottom: 1.6rem;
  }
  .doc-meta::before {
    content: "";
    width: 2rem;
    height: 1px;
    background: var(--gold);
  }
  .doc-meta .dot {
    color: var(--gold);
  }
  .hero-name {
    font-family: var(--display);
    font-optical-sizing: auto;
    font-weight: 600;
    font-size: clamp(2.9rem, 8vw, 6rem);
    line-height: 0.96;
    letter-spacing: -0.025em;
  }
  .hero-name .line {
    display: block;
    overflow: hidden;
  }
  .hero-name .line:last-child {
    color: var(--gold);
  }
  .lede {
    font-family: var(--serif);
    font-size: clamp(1.15rem, 2vw, 1.4rem);
    line-height: 1.55;
    color: color-mix(in oklch, var(--ink) 88%, var(--bg));
    max-width: 40ch;
  }
  .hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 2.2rem;
  }
  .btn {
    font-family: var(--sans);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 0.9rem 1.6rem;
    border-radius: 2px;
    transition: transform 0.18s ease, background 0.25s, color 0.25s,
      border-color 0.25s;
  }
  .btn:active {
    transform: translateY(1px);
  }
  .btn-primary {
    background: var(--ink);
    color: var(--bg);
  }
  .btn-primary:hover {
    background: color-mix(in oklch, var(--ink) 82%, var(--gold));
  }
  .btn-ghost {
    border: 1px solid var(--line-strong);
    color: var(--ink);
  }
  .btn-ghost:hover {
    border-color: var(--gold);
    color: var(--gold);
  }

  /* ---- portrait plate ---- */
  .portrait {
    justify-self: center;
    margin: 0;
    max-width: 340px;
    width: 100%;
  }
  .portrait-plate {
    position: relative;
    aspect-ratio: 4 / 5;
    background: var(--bg-2);
    border: 1px solid var(--line-strong);
    overflow: hidden;
    box-shadow: 0 20px 45px -28px color-mix(in oklch, var(--ink) 60%, transparent);
  }
  .portrait-photo {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 22%;
    filter: saturate(0.96) contrast(1.02);
  }
  .plate-tick {
    position: absolute;
    width: 12px;
    height: 12px;
    border: 1px solid var(--gold);
  }
  .plate-tick.tl {
    top: 10px;
    left: 10px;
    border-right: 0;
    border-bottom: 0;
  }
  .plate-tick.tr {
    top: 10px;
    right: 10px;
    border-left: 0;
    border-bottom: 0;
  }
  .plate-tick.bl {
    bottom: 10px;
    left: 10px;
    border-right: 0;
    border-top: 0;
  }
  .plate-tick.br {
    bottom: 10px;
    right: 10px;
    border-left: 0;
    border-top: 0;
  }
  .plate-caption {
    font-family: var(--sans);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    text-align: center;
    margin-top: 0.9rem;
  }

  /* ---- about ---- */
  .band p + p {
    margin-top: 1.2rem;
  }
  .dropcap::first-letter {
    font-family: var(--display);
    font-weight: 600;
    float: left;
    font-size: 3.6em;
    line-height: 0.82;
    padding-right: 0.1em;
    margin-top: 0.06em;
    color: var(--gold);
  }

  /* ---- ledger (journey) ---- */
  .ledger {
    position: relative;
    margin-top: 2.5rem;
    border-top: 1px solid var(--line);
  }
  .ledger::before {
    content: "";
    position: absolute;
    left: -1px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--gold);
  }
  .ledger li {
    display: grid;
    grid-template-columns: 7rem 1fr;
    gap: clamp(1rem, 4vw, 3rem);
    padding-block: clamp(1.4rem, 3vw, 2rem);
    padding-inline-start: clamp(1.25rem, 2.5vw, 2rem);
    border-bottom: 1px solid var(--line);
    align-items: baseline;
  }
  .ledger-year {
    font-family: var(--sans);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
    padding-top: 0.35rem;
  }
  .ledger-body h3 {
    font-family: var(--display);
    font-weight: 560;
    font-size: clamp(1.35rem, 2.4vw, 1.75rem);
    line-height: 1.15;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
  }
  .ledger-body p {
    color: var(--muted);
    font-size: 1.02rem;
    max-width: 52ch;
  }

  /* ---- credentials (education) ---- */
  .credentials {
    margin-top: 2.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
  }
  .credentials li {
    background: var(--bg);
    padding: clamp(1.4rem, 3vw, 2rem);
    display: grid;
    gap: 0.35rem;
  }
  .band-alt .credentials li {
    background: var(--bg-2);
  }
  .cred-year {
    font-family: var(--sans);
    font-size: 0.75rem;
    letter-spacing: 0.16em;
    color: var(--gold);
    font-variant-numeric: tabular-nums;
  }
  .credentials strong {
    font-family: var(--display);
    font-weight: 560;
    font-size: 1.3rem;
    line-height: 1.1;
  }
  .cred-detail {
    color: var(--ink);
  }
  .cred-place {
    font-family: var(--sans);
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 0.2rem;
  }

  /* ---- connect (dark band) ---- */
  .band-dark {
    background: linear-gradient(165deg, var(--forest), var(--forest-2));
    color: var(--ivory);
    border-top: 1px solid color-mix(in oklch, var(--gold-bright) 30%, transparent);
  }
  .band-dark .marker,
  .band-dark .marker span {
    color: color-mix(in oklch, var(--gold-bright) 90%, white);
  }
  .band-dark h2 {
    color: var(--ivory);
  }
  .band-dark .lede {
    color: color-mix(in oklch, var(--ivory) 80%, transparent);
    margin-inline: auto;
  }
  .plaques {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    max-width: 620px;
    margin: 2.5rem auto 0;
  }
  .plaque {
    position: relative;
    text-align: left;
    padding: 1.6rem 1.7rem;
    border: 1px solid color-mix(in oklch, var(--gold-bright) 35%, transparent);
    border-radius: 2px;
    display: grid;
    gap: 0.3rem;
    background: color-mix(in oklch, white 3%, transparent);
    transition: background 0.3s, border-color 0.3s, transform 0.3s;
  }
  .plaque:hover {
    background: color-mix(in oklch, var(--gold-bright) 12%, transparent);
    border-color: var(--gold-bright);
    transform: translateY(-2px);
  }
  .plaque-idx {
    font-family: var(--sans);
    font-size: 0.72rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: color-mix(in oklch, var(--gold-bright) 90%, white);
  }
  .plaque-title {
    font-family: var(--display);
    font-size: 1.6rem;
    font-weight: 560;
    color: var(--ivory);
  }
  .plaque-sub {
    font-family: var(--sans);
    font-size: 0.85rem;
    color: color-mix(in oklch, var(--ivory) 70%, transparent);
  }

  /* ---- colophon (footer) ---- */
  .colophon {
    position: relative;
    z-index: 2;
    background: var(--forest);
    color: color-mix(in oklch, var(--ivory) 72%, transparent);
    text-align: center;
    padding-block: 3rem;
  }
  .footer-name {
    font-family: var(--display);
    font-size: 1.4rem;
    font-weight: 560;
    color: var(--ivory);
    margin-bottom: 0.3rem;
  }
  .footer-meta {
    font-family: var(--sans);
    font-size: 0.9rem;
    letter-spacing: 0.02em;
    margin-bottom: 0.8rem;
  }
  .footer-copy {
    font-family: var(--sans);
    font-size: 0.78rem;
    color: color-mix(in oklch, var(--ivory) 45%, transparent);
  }
}

/* ---------- motion ---------- */
@layer motion {
  @media (prefers-reduced-motion: no-preference) {
    /* entrance reveals via scroll-driven timelines */
    @keyframes rise {
      from {
        opacity: 0;
        translate: 0 1.1rem;
      }
      to {
        opacity: 1;
        translate: 0 0;
      }
    }
    .reveal {
      animation: rise linear both;
      animation-timeline: view();
      animation-range: entry 0% cover 26%;
    }

    /* above-the-fold content animates on load, not on scroll position */
    .hero .reveal {
      animation-name: rise;
      animation-timeline: auto;
      animation-range: normal;
      animation-duration: 0.85s;
      animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
      animation-fill-mode: both;
    }
    .hero .lede.reveal {
      animation-delay: 0.35s;
    }
    .hero .hero-actions.reveal {
      animation-delay: 0.5s;
    }

    /* hero name unveils from a clip mask on load */
    @keyframes unveil {
      from {
        clip-path: inset(0 0 108% 0);
        translate: 0 0.4em;
      }
      to {
        clip-path: inset(0 0 -12% 0);
        translate: 0 0;
      }
    }
    .hero-name .line > span {
      display: inline-block;
      animation: unveil 0.9s cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    .hero-name .line:nth-child(1) > span {
      animation-delay: 0.05s;
    }
    .hero-name .line:nth-child(2) > span {
      animation-delay: 0.18s;
    }

    /* masthead condenses on scroll */
    @keyframes condense {
      to {
        height: 62px;
      }
    }
    .masthead-inner {
      animation: condense linear both;
      animation-timeline: scroll(root);
      animation-range: 0 140px;
    }

    /* whisper of parallax on the portrait */
    @keyframes drift {
      from {
        translate: 0 1.4rem;
      }
      to {
        translate: 0 -1.4rem;
      }
    }
    .portrait-plate {
      animation: drift linear both;
      animation-timeline: view();
      animation-range: cover 0% cover 100%;
    }
  }

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

/* ---------- utilities / responsive ---------- */
@layer utilities {
  @media (max-width: 860px) {
    .hero-inner {
      grid-template-columns: 1fr;
    }
    .hero-text {
      order: 2;
    }
    .portrait {
      order: 1;
      max-width: 280px;
    }
    .nav {
      display: none;
    }
    .hero-name {
      font-size: clamp(2.8rem, 13vw, 4.4rem);
    }
  }

  @media (max-width: 480px) {
    .ledger li {
      grid-template-columns: 1fr;
      gap: 0.4rem;
    }
    .ledger-year {
      padding-top: 0;
    }
  }
}
