/* ==========================================================================
   William McIlleron — portfolio
   Editorial layout: warm paper, one accent, type doing most of the work.
   ========================================================================== */

/* --- Tokens --------------------------------------------------------------- */

:root {
    --paper:        #f4f1ea;
    --surface:      #faf8f3;
    --ink:          #15140f;
    --ink-muted:    #5d5a51;
    --rule:         #ddd6c7;
    --accent:       #b23c17;
    --accent-ink:   #ffffff;
    --accent-wash:  rgba(178, 60, 23, 0.07);

    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body:    ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono:    'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --wrap:         72rem;
    --gutter:       clamp(1.25rem, 5vw, 4rem);
    --header-h:     4.5rem;

    --ease:         cubic-bezier(0.22, 0.61, 0.36, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) {
        --paper:       #14130f;
        --surface:     #1c1a15;
        --ink:         #f0ece2;
        --ink-muted:   #a19c8f;
        --rule:        #322e26;
        --accent:      #e0673b;
        --accent-ink:  #14130f;
        --accent-wash: rgba(224, 103, 59, 0.10);
    }
}

:root[data-theme='dark'] {
    --paper:       #14130f;
    --surface:     #1c1a15;
    --ink:         #f0ece2;
    --ink-muted:   #a19c8f;
    --rule:        #322e26;
    --accent:      #e0673b;
    --accent-ink:  #14130f;
    --accent-wash: rgba(224, 103, 59, 0.10);
}

/* --- Base ----------------------------------------------------------------- */

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

* { margin: 0; }

html {
    scroll-behavior: smooth;
    /* Keeps anchored sections clear of the fixed masthead. */
    scroll-padding-top: calc(var(--header-h) + 1.5rem);
    -webkit-text-size-adjust: 100%;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: clamp(1rem, 0.97rem + 0.15vw, 1.0625rem);
    line-height: 1.65;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

a { color: inherit; }

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

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

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
}

.skip-link {
    position: absolute;
    left: 50%;
    top: 0;
    translate: -50% -150%;
    z-index: 200;
    padding: 0.75rem 1.25rem;
    background: var(--accent);
    color: var(--accent-ink);
    font: 500 0.8125rem/1 var(--font-mono);
    text-decoration: none;
    border-radius: 0 0 6px 6px;
    transition: translate 0.2s var(--ease);
}

.skip-link:focus-visible { translate: -50% 0; }

/* --- Shared type ---------------------------------------------------------- */

.eyebrow,
.section__label,
.group-label,
.work__idx,
.work__meta,
.status,
.capability dt,
.footer {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.eyebrow {
    color: var(--accent);
    margin-bottom: 1.75rem;
}

/* --- Masthead ------------------------------------------------------------- */

.masthead {
    position: sticky;
    top: 0;
    z-index: 100;
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(12px);
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s var(--ease);
}

.masthead.is-stuck { border-bottom-color: var(--rule); }

.masthead__inner {
    height: var(--header-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.wordmark {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-decoration: none;
    white-space: nowrap;
}

.wordmark__dot { color: var(--accent); }

.nav__list {
    display: flex;
    gap: 2rem;
    list-style: none;
    padding: 0;
}

.nav__list a {
    position: relative;
    display: inline-block;
    padding: 0.25rem 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink-muted);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.nav__list a::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 1px;
    background: currentColor;
    scale: 0 1;
    transform-origin: left;
    transition: scale 0.3s var(--ease);
}

.nav__list a:hover,
.nav__list a[aria-current='true'] { color: var(--ink); }

.nav__list a:hover::after,
.nav__list a[aria-current='true']::after { scale: 1 1; }

.nav__list a[aria-current='true'] { color: var(--accent); }

.masthead__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: none;
    border: 1px solid transparent;
    border-radius: 50%;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.icon-btn:hover {
    background: var(--accent-wash);
    border-color: var(--rule);
}

.icon-btn svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Show the icon for the theme you'd switch *to*. */
.icon-moon { display: none; }
:root[data-theme='dark'] .icon-sun { display: none; }
:root[data-theme='dark'] .icon-moon { display: block; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme='light']) .icon-sun  { display: none; }
    :root:not([data-theme='light']) .icon-moon { display: block; }
}

.nav-toggle { display: none; flex-direction: column; gap: 5px; }

.nav-toggle__bar {
    width: 18px;
    height: 1.5px;
    background: currentColor;
    transition: translate 0.25s var(--ease), rotate 0.25s var(--ease), opacity 0.2s;
}

.nav-toggle[aria-expanded='true'] .nav-toggle__bar:first-child {
    translate: 0 3.25px;
    rotate: 45deg;
}

.nav-toggle[aria-expanded='true'] .nav-toggle__bar:last-child {
    translate: 0 -3.25px;
    rotate: -45deg;
}

/* --- Hero ----------------------------------------------------------------- */

.hero {
    padding-block: clamp(5rem, 16vh, 10rem) clamp(4rem, 12vh, 8rem);
}

.hero__title {
    font-family: var(--font-display);
    font-size: clamp(2.75rem, 1.2rem + 6.4vw, 6rem);
    font-weight: 600;
    font-variation-settings: 'opsz' 120, 'SOFT' 20;
    line-height: 1.02;
    letter-spacing: -0.025em;
    text-wrap: balance;
    max-width: 18ch;
}

.hero__title em {
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
}

.hero__lede {
    margin-top: 2rem;
    max-width: 50ch;
    font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
    color: var(--ink-muted);
    text-wrap: pretty;
}

.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem;
    margin-top: 2.75rem;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-top: 3.5rem;
    color: var(--ink-muted);
}

.status__dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 0 var(--accent);
    animation: pulse 2.6s ease-out infinite;
}

@keyframes pulse {
    0%        { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
    70%, 100% { box-shadow: 0 0 0 8px transparent; }
}

/* --- Buttons -------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.6rem;
    border: 1px solid var(--ink);
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.25s var(--ease), color 0.25s var(--ease),
                border-color 0.25s var(--ease), translate 0.25s var(--ease);
}

.btn--solid {
    background: var(--ink);
    color: var(--paper);
}

.btn--solid:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
    translate: 0 -2px;
}

.btn--ghost {
    background: transparent;
    color: var(--ink);
    border-color: var(--rule);
}

.btn--ghost:hover {
    border-color: var(--accent);
    color: var(--accent);
    translate: 0 -2px;
}

.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    translate: none;
}

/* --- Section scaffold ----------------------------------------------------- */

.section { padding-block: clamp(4rem, 10vh, 7rem); }

.section--rule .section__grid { border-top: 1px solid var(--rule); padding-top: clamp(3.5rem, 8vh, 6rem); }

.section__grid {
    display: grid;
    grid-template-columns: 10rem minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 5rem);
}

.section__aside { grid-column: 1; }

.section__label {
    position: sticky;
    top: calc(var(--header-h) + 2rem);
    color: var(--ink-muted);
}

.section__title {
    font-family: var(--font-display);
    font-size: clamp(1.875rem, 1.3rem + 2.2vw, 3rem);
    font-weight: 600;
    font-variation-settings: 'opsz' 90;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 2.5rem;
}

.group-label {
    color: var(--ink-muted);
    margin-bottom: 0.75rem;
}

.group-label + .work-list { margin-bottom: 3rem; }

/* --- Work list ------------------------------------------------------------ */

.work-list {
    list-style: none;
    padding: 0;
    border-top: 1px solid var(--rule);
}

.work-list li { border-bottom: 1px solid var(--rule); }

.work {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr) auto 1.5rem;
    align-items: baseline;
    gap: 1.5rem;
    padding: 1.75rem 0.75rem;
    text-decoration: none;
    transition: background-color 0.3s var(--ease), padding-inline 0.3s var(--ease);
}

.work:hover,
.work:focus-visible {
    background: var(--accent-wash);
    padding-inline: 1.25rem 0.25rem;
}

/* Rows for things that aren't shipped yet, so there's nowhere to link. */
.work--static { cursor: default; }
.work--static:hover { background: none; padding-inline: 0.75rem; }

.work__status {
    display: inline-block;
    margin-left: 0.6rem;
    padding: 0.15rem 0.6rem;
    border: 1px solid var(--rule);
    border-radius: 100px;
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
    vertical-align: middle;
    white-space: nowrap;
}

.work__idx { color: var(--ink-muted); }

.work__main { display: block; min-width: 0; }

.work__title {
    display: block;
    font-family: var(--font-display);
    font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
    font-weight: 600;
    font-variation-settings: 'opsz' 40;
    line-height: 1.2;
    letter-spacing: -0.01em;
    transition: color 0.25s var(--ease);
}

.work:hover .work__title,
.work:focus-visible .work__title { color: var(--accent); }

.work__desc {
    display: block;
    margin-top: 0.4rem;
    max-width: 52ch;
    font-size: 0.9375rem;
    line-height: 1.55;
    color: var(--ink-muted);
}

.work__meta {
    color: var(--ink-muted);
    white-space: nowrap;
}

.work__arrow {
    justify-self: end;
    font-size: 1.125rem;
    color: var(--ink-muted);
    transition: translate 0.25s var(--ease), color 0.25s var(--ease);
}

.work:hover .work__arrow,
.work:focus-visible .work__arrow {
    translate: 3px -3px;
    color: var(--accent);
}

/* --- Prose & capabilities ------------------------------------------------- */

.prose {
    max-width: 58ch;
    font-size: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
    color: var(--ink-muted);
    text-wrap: pretty;
}

.prose p + p { margin-top: 1.25rem; }

.capabilities {
    margin-top: 3.5rem;
    display: grid;
    gap: 0;
    border-top: 1px solid var(--rule);
}

.capability {
    display: grid;
    grid-template-columns: 8rem minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1.125rem 0;
    border-bottom: 1px solid var(--rule);
}

.capability dt { color: var(--accent); }

.capability dd {
    margin: 0;
    font-size: 0.9375rem;
    color: var(--ink-muted);
}

/* --- Contact -------------------------------------------------------------- */

.contact-links {
    list-style: none;
    padding: 0;
    margin-top: 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 2rem;
}

.contact-links a {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    text-decoration: none;
    /* Underline that grows on hover, without shifting layout. */
    background-image: linear-gradient(var(--accent), var(--accent));
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0 1px;
    padding-bottom: 2px;
    transition: background-size 0.3s var(--ease), color 0.2s var(--ease);
}

.contact-links a:hover,
.text-link:hover {
    color: var(--accent);
    background-size: 100% 1px;
}

.text-link {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    text-decoration: none;
    background-image: linear-gradient(var(--accent), var(--accent));
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0 1px;
    padding-bottom: 2px;
    transition: background-size 0.3s var(--ease), color 0.2s var(--ease);
}

/* --- Form ----------------------------------------------------------------- */

.form {
    margin-top: 3.5rem;
    max-width: 34rem;
    display: grid;
    gap: 1.5rem;
}

.field { display: grid; gap: 0.5rem; }

.field label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.field input,
.field textarea,
.field select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: 4px;
    color: var(--ink);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.field textarea { resize: vertical; min-height: 8rem; }

.field select {
    appearance: none;
    cursor: pointer;
    padding-right: 2.75rem;
    /* Chevron drawn in CSS so there's no extra request and it follows the theme. */
    background-image:
        linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position: calc(100% - 1.35rem) 55%, calc(100% - 1rem) 55%;
    background-size: 6px 6px, 6px 6px;
    background-repeat: no-repeat;
}

.field select:invalid { color: var(--ink-muted); }

.field input:hover,
.field textarea:hover,
.field select:hover { border-color: var(--ink-muted); }

.field input:focus,
.field textarea:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--paper);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

/* :user-invalid only bites after the visitor has actually interacted. */
.field input:user-invalid,
.field textarea:user-invalid,
.field select:user-invalid { border-color: var(--accent); }

.form .btn { justify-self: start; }

.hp {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.form__status {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--ink-muted);
    min-height: 1.25rem;
}

.form__status.is-error { color: var(--accent); }

/* --- Writing -------------------------------------------------------------- */

.post {
    padding-block: clamp(3rem, 8vh, 5rem) clamp(4rem, 10vh, 7rem);
}

.post__back {
    display: inline-block;
    margin-bottom: 3rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--ink-muted);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}

.post__back:hover { color: var(--accent); }

.post__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-bottom: 1.5rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.post__title {
    max-width: 20ch;
    font-family: var(--font-display);
    font-size: clamp(2rem, 1.3rem + 2.8vw, 3.5rem);
    font-weight: 600;
    font-variation-settings: 'opsz' 100;
    line-height: 1.06;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.post__standfirst {
    margin-top: 1.75rem;
    max-width: 46ch;
    font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
    line-height: 1.55;
    color: var(--ink-muted);
    text-wrap: pretty;
}

.post__body {
    margin-top: 3.5rem;
    max-width: 62ch;
    font-size: clamp(1.0625rem, 1rem + 0.2vw, 1.1875rem);
    line-height: 1.7;
    text-wrap: pretty;
}

.post__body > * + * { margin-top: 1.5rem; }

.post__body h2 {
    margin-top: 3.25rem;
    font-family: var(--font-display);
    font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
    font-weight: 600;
    font-variation-settings: 'opsz' 40;
    line-height: 1.2;
    letter-spacing: -0.015em;
}

.post__body ul,
.post__body ol { padding-left: 1.25rem; }

.post__body li + li { margin-top: 0.6rem; }

.post__body a {
    color: var(--accent);
    text-underline-offset: 3px;
}

.post__body strong { font-weight: 600; }

.post__body blockquote {
    padding-left: 1.5rem;
    border-left: 2px solid var(--accent);
    font-family: var(--font-display);
    font-size: 1.25em;
    font-style: italic;
    line-height: 1.4;
    color: var(--ink);
}

.post__body hr {
    margin-block: 3rem;
    border: 0;
    border-top: 1px solid var(--rule);
}

.post__foot {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--rule);
    max-width: 62ch;
    font-size: 0.9375rem;
    color: var(--ink-muted);
}

.post__foot a { color: var(--accent); }

/* --- Footer --------------------------------------------------------------- */

.footer {
    border-top: 1px solid var(--rule);
    padding-block: 2.5rem;
    color: var(--ink-muted);
}

.footer__inner {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.75rem 2rem;
}

/* --- Scroll reveal -------------------------------------------------------- */

/* Guarded by .js so the page is fully readable if the script never runs. */
.js .reveal {
    opacity: 0;
    translate: 0 1.25rem;
    transition: opacity 0.7s var(--ease), translate 0.7s var(--ease);
}

.js .reveal.is-visible {
    opacity: 1;
    translate: none;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 60rem) {
    .section__grid { grid-template-columns: 1fr; gap: 1.5rem; }
    .section__label { position: static; }

    .work {
        grid-template-columns: 2.25rem minmax(0, 1fr) 1.25rem;
        gap: 1rem;
        row-gap: 0.5rem;
    }

    .work__meta { grid-column: 2; white-space: normal; }
    .work__arrow { grid-row: 1; grid-column: 3; }
}

@media (max-width: 46rem) {
    .nav-toggle { display: flex; }

    .nav {
        position: absolute;
        inset: var(--header-h) 0 auto 0;
        background: var(--paper);
        border-bottom: 1px solid var(--rule);
        display: grid;
        grid-template-rows: 0fr;
        visibility: hidden;
        transition: grid-template-rows 0.3s var(--ease), visibility 0.3s;
    }

    .nav.is-open {
        grid-template-rows: 1fr;
        visibility: visible;
    }

    .nav__list {
        overflow: hidden;
        flex-direction: column;
        gap: 0;
        padding-inline: var(--gutter);
    }

    .nav__list li + li { border-top: 1px solid var(--rule); }

    .nav__list a {
        display: block;
        padding: 1rem 0;
        font-size: 0.9375rem;
    }

    .nav__list a::after { display: none; }

    .capability { grid-template-columns: 1fr; gap: 0.25rem; }
    .footer__inner { flex-direction: column; }
}

/* --- Motion & print ------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }

    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .js .reveal { opacity: 1; translate: none; }
}

@media print {
    .masthead, .skip-link, .form, .hero__actions { display: none; }
    body { background: #fff; color: #000; }
    .work::after { content: ' (' attr(href) ')'; font-size: 0.75rem; }
}
