/* -----------------------------------------------------------------------------
   style.css
   Single stylesheet for the whole site. Theming is done with CSS custom
   properties. Three sources of truth, in ascending specificity order:

   1. :root                          — light palette (default)
   2. @media (prefers-color-scheme)  — OS dark palette
   3. :root:has(#dark-mode:target)   — user forced dark  (fragment in URL)
      :root:has(#light-mode:target)  — user forced light (fragment in URL)

   The :has(:target) selectors carry a higher specificity than the media-query
   :root block, so they always win when a fragment is set. No JavaScript.

   To retheme: edit the variables in the :root and the dark-mode blocks.
   Avoid hard-coding colors anywhere else.
   -------------------------------------------------------------------------- */

:root {
    /* Palette - light */
    --bg: #fbfaf6; /* warm off-white */
    --bg-elevated: #ffffff;
    --text: #1c1b1f;
    --text-muted: #5e5c66;
    --border: #e8e4dc;
    --accent: #5b3df5; /* indigo - the one bit of color we use */
    --accent-soft: #ece9ff; /* tinted background for stack pills, etc. */

    /* Typography */
    --font-sans:
        ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto,
        "Helvetica Neue", Arial, sans-serif;
    --font-mono:
        ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
        "Liberation Mono", monospace;

    /* Layout */
    --max-width: 720px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131318;
        --bg-elevated: #1c1c24;
        --text: #ececec;
        --text-muted: #9a98a8;
        --border: #2a2a35;
        --accent: #a394ff;
        --accent-soft: #2a2547;
    }
}

/* Manual theme overrides — triggered by URL fragments #dark-mode / #light-mode.
   :root:has(#id:target) specificity = :root (0,1,0) + :has(#id:target) (1,1,0)
   = (1,2,0), which beats the media-query :root (0,1,0) above. */

:root:has(#dark-mode:target) {
    --bg: #131318;
    --bg-elevated: #1c1c24;
    --text: #ececec;
    --text-muted: #9a98a8;
    --border: #2a2a35;
    --accent: #a394ff;
    --accent-soft: #2a2547;
    color-scheme: dark;
}

:root:has(#light-mode:target) {
    --bg: #fbfaf6;
    --bg-elevated: #ffffff;
    --text: #1c1b1f;
    --text-muted: #5e5c66;
    --border: #e8e4dc;
    --accent: #5b3df5;
    --accent-soft: #ece9ff;
    color-scheme: light;
}

/* ---------- cross-document view transitions ----------

   Opts every same-origin navigation into the View Transitions API so the
   browser cross-fades the old and new documents instead of flashing white.
   Elements that share a view-transition-name across both pages animate
   from their old box to their new one, making them look "preserved" even
   though the document was fully re-parsed. */

@view-transition {
    navigation: auto;
}

.site-header {
    view-transition-name: site-header;
}

.site-footer {
    view-transition-name: site-footer;
}

/* ---------- base reset ---------- */

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

html {
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration: none;
}

h1,
h2,
h3 {
    letter-spacing: -0.02em;
    line-height: 1.15;
}

/* ---------- layout ---------- */

.container {
    max-width: var(--max-width);
    margin-inline: auto;
    padding-inline: 1.5rem;
}

/* ---------- header ---------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in oklab, var(--bg) 85%, transparent);
    backdrop-filter: saturate(140%) blur(8px);
    -webkit-backdrop-filter: saturate(140%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding-block: 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.brand {
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text);
    text-decoration: none;
}

.brand::before {
    content: "▌ ";
    color: var(--accent);
}

.site-nav {
    display: flex;
    gap: 1.5rem;
}

.site-nav a {
    position: relative;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-decoration: none;
    padding-block: 0.25rem;
}

.site-nav a:hover {
    color: var(--text);
}

.site-nav a.active {
    color: var(--text);
}

.site-nav a.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1.05rem;
    height: 2px;
    background: var(--accent);
}

/* ---------- nav link variants ----------

   Each nav destination is emitted three times in the HTML:
     .nav-default  — plain href  (shown when following OS preference)
     .nav-dark     — href#dark-mode  (shown while dark override is active)
     .nav-light    — href#light-mode (shown while light override is active)

   Only one set is visible at a time; the hidden ones are display:none so
   they are removed from the accessibility tree entirely. */

.nav-dark,
.nav-light {
    display: none;
}

:root:has(#dark-mode:target) .nav-default {
    display: none;
}
:root:has(#dark-mode:target) .nav-dark {
    display: revert;
}

:root:has(#light-mode:target) .nav-default {
    display: none;
}
:root:has(#light-mode:target) .nav-light {
    display: revert;
}

/* ---------- theme toggle links ----------

   Four <a> links are emitted; CSS shows exactly one depending on the
   combination of active fragment and OS colour preference:

   go-dark-to-fragment  🌙  OS light + no override  → click adds #dark-mode
   go-light-to-fragment ☀️  OS dark  + no override  → click adds #light-mode
   go-light-to-default  ☀️  #dark-mode active        → click removes fragment
   go-dark-to-default   🌙  #light-mode active       → click removes fragment */

.go-dark-to-fragment,
.go-light-to-fragment,
.go-light-to-default,
.go-dark-to-default {
    display: none;
}

/* Default (no fragment): show the link that leads to the opposite scheme. */
@media (prefers-color-scheme: light) {
    .go-dark-to-fragment {
        display: flex;
    }
}
@media (prefers-color-scheme: dark) {
    .go-light-to-fragment {
        display: flex;
    }
}

/* Fragment active: hide the default-state links, show the escape link.
   The :root:has() selectors have specificity (1,2,0) and beat the
   media-query rules above (0,1,0), so no !important is needed. */
:root:has(#dark-mode:target) .go-dark-to-fragment {
    display: none;
}
:root:has(#dark-mode:target) .go-light-to-fragment {
    display: none;
}
:root:has(#dark-mode:target) .go-light-to-default {
    display: flex;
}

:root:has(#light-mode:target) .go-dark-to-fragment {
    display: none;
}
:root:has(#light-mode:target) .go-light-to-fragment {
    display: none;
}
:root:has(#light-mode:target) .go-dark-to-default {
    display: flex;
}

/* Shared toggle link appearance */
.theme-toggle {
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.25rem 0.4rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    transition:
        border-color 150ms ease,
        background 150ms ease;
}

.theme-toggle:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- hero (home page) ---------- */

.hero {
    padding-block: 6rem 4rem;
}

.eyebrow {
    margin: 0 0 0.5rem;
    color: var(--accent);
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.02em;
}

.hero h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(2.5rem, 7vw, 4rem);
    font-weight: 700;
}

.hero .role {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.hero .tagline {
    max-width: 34rem;
    margin: 0 0 2rem;
    font-size: 1.1rem;
}

.cta-row {
    margin-top: 2.5rem;
}

.cta {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid currentColor;
    padding-bottom: 2px;
    transition: opacity 150ms ease;
}

.cta:hover {
    opacity: 0.7;
}

/* ---------- about page ---------- */

.about {
    padding-block: 5rem 2.5rem;
}

.about h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(2rem, 5vw, 2.75rem);
    font-weight: 700;
}

.profile {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.7;
    max-width: 36rem;
}

.experience,
.links {
    padding-block: 2.5rem;
    border-top: 1px solid var(--border);
}

.experience h2,
.links h2 {
    margin: 0 0 1.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---------- job entries ---------- */

.job {
    position: relative;
    margin: 0 0 2.5rem;
    padding-left: 1.25rem;
    border-left: 2px solid var(--accent-soft);
}

.job:last-of-type {
    margin-bottom: 1.5rem;
}

.job-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.job-header .job-at {
    color: var(--text-muted);
    margin-inline: 0.15rem;
}
.job-header .company {
    font-weight: 500;
}

.job-header .meta {
    margin: 0.25rem 0 0.75rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.job-header .meta-sep {
    margin-inline: 0.4rem;
}

.job-header .period {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.description {
    margin: 0.5rem 0 0.75rem;
}

.stack {
    display: inline-block;
    margin: 0.5rem 0 0;
    padding: 0.35rem 0.7rem;
    background: var(--accent-soft);
    border-radius: 6px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--text);
}

.stack-label {
    margin-right: 0.45rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: lowercase;
}

.more-note {
    margin: 1.5rem 0 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-style: italic;
}

/* ---------- links list ---------- */

.link-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.link-list a {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    transition:
        border-color 150ms ease,
        color 150ms ease,
        background 150ms ease;
}

.link-list a:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

/* ---------- footer ---------- */

.site-footer {
    margin-top: 4rem;
    padding-block: 2rem;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.85rem;
}

.site-footer p {
    margin: 0;
}

/* ---------- focus / a11y ---------- */

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

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