/* =========================================================================
   Portfolio stylesheet — "Warm Workshop"
   =========================================================================
   Direction, rationale, and re-theming guide: docs/DESIGN-DIRECTION.md

   Structure of this file:
     1. Design tokens (light + dark) — re-theme by editing ONLY this section
     2. Self-hosted fonts
     3. Base / reset
     4. Layout shell (header, nav, main, footer)
     5. Components (hero, cards, buttons, media, forms, notices, prose)
     6. Accessibility & motion

   Class names are a stable contract with the PHP templates — restyle them
   freely, but if you rename one, update it in the template too.
   ========================================================================= */

/* ----- 1. Design tokens ------------------------------------------------- */

:root {
    /* Color — light theme: "warm paper" */
    --color-bg:           #faf6f0;
    --color-surface:      #ffffff;  /* cards, form fields */
    --color-surface-alt:  #f3ece1;  /* tinted bands: currently strip, CTA, video facade */
    --color-border:       #e4dccd;
    --color-text:         #2a241d;
    --color-text-muted:   #6e6558;
    --color-accent:       #a4470e;  /* rust — links, primary buttons, highlights */
    --color-accent-hover: #823406;
    --color-accent-soft:  #f6e3d2;  /* accent tint — backgrounds only */
    --color-accent-text:  #ffffff;  /* text on top of accent */
    --color-success:      #22683f;
    --color-error:        #b3261e;

    /* Typography */
    --font-body:    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-heading: "Space Grotesk", var(--font-body);
    --font-mono:    ui-monospace, "Cascadia Code", Consolas, monospace;
    --text-base:    1.0625rem;
    --line-height:  1.65;

    /* Spacing & shape */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;
    --space-6: 4rem;
    --space-7: 6rem;
    --radius:    10px;
    --radius-lg: 16px;
    --content-max-width: 66rem;
    --prose-max-width:   44rem;
    --shadow-card:       0 1px 2px rgb(42 36 29 / 0.04);
    --shadow-card-hover: 0 8px 24px rgb(42 36 29 / 0.09);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Color — dark theme: "workshop at night" */
        --color-bg:           #201b15;
        --color-surface:      #2a241b;
        --color-surface-alt:  #272119;
        --color-border:       #3e3628;
        --color-text:         #ede5d8;
        --color-text-muted:   #a89c8b;
        --color-accent:       #e88a4a;
        --color-accent-hover: #f2a36c;
        --color-accent-soft:  #3a2b1c;
        --color-accent-text:  #201b15;
        --color-success:      #7ed09a;
        --color-error:        #f28b81;

        --shadow-card:        0 1px 2px rgb(0 0 0 / 0.25);
        --shadow-card-hover:  0 8px 24px rgb(0 0 0 / 0.4);
    }
}

/* ----- 2. Self-hosted fonts (26 KB total, latin subset) ------------------ */

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/space-grotesk-v22-latin-500.woff2") format("woff2");
}

@font-face {
    font-family: "Space Grotesk";
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url("../fonts/space-grotesk-v22-latin-700.woff2") format("woff2");
}

/* ----- 3. Base ----------------------------------------------------------- */

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

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--line-height);
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.015em;
    margin: 0 0 var(--space-3);
    text-wrap: balance;
}

h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }

img { max-width: 100%; height: auto; display: block; }

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

a:hover { color: var(--color-accent-hover); }

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

code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    background: var(--color-surface-alt);
    padding: 0.1em 0.35em;
    border-radius: calc(var(--radius) / 2);
}

/* Mono "// eyebrow" label above section titles — a signature detail */
.eyebrow {
    display: block;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: var(--space-2);
}

.eyebrow::before { content: "// "; opacity: 0.7; }

/* Inline arrow links ("All projects →") */
.arrow-link {
    font-family: var(--font-heading);
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.arrow-link::after {
    content: " \2192";
    display: inline-block;
    transition: transform 0.16s ease;
}

.arrow-link:hover::after { transform: translateX(3px); }

/* ----- 4. Layout shell ---------------------------------------------------- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 100;
    background: var(--color-accent);
    color: var(--color-accent-text);
    padding: var(--space-2) var(--space-3);
    border-radius: 0 0 var(--radius) var(--radius);
    text-decoration: none;
}

.skip-link:focus { left: var(--space-3); }

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

.site-header-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-2) var(--space-3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    min-height: 3.5rem;
}

.site-brand {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.015em;
    text-decoration: none;
    color: var(--color-text);
}

.site-brand-dot { color: var(--color-accent); }

.site-nav { display: flex; gap: var(--space-4); }

.site-nav a {
    position: relative;
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--color-text-muted);
    padding: var(--space-1) 0;
}

.site-nav a::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 1px;
    background: var(--color-accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.16s ease;
}

.site-nav a:hover,
.site-nav a[aria-current="page"] { color: var(--color-text); }

.site-nav a:hover::after,
.site-nav a[aria-current="page"]::after { transform: scaleX(1); }

/* Mobile nav toggle (hidden on wide screens; js/main.js flips .is-open) */
.nav-toggle {
    display: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-1) var(--space-3);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    color: var(--color-text);
    cursor: pointer;
}

.nav-toggle:hover { border-color: var(--color-accent); color: var(--color-accent); }

@media (max-width: 40rem) {
    .nav-toggle { display: block; }
    .site-nav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        gap: var(--space-2);
        padding: var(--space-2) 0 var(--space-3);
        border-top: 1px solid var(--color-border);
        margin-top: var(--space-2);
    }
    .site-nav.is-open { display: flex; }
    .site-nav a { align-self: flex-start; }
}

.site-main {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-5) var(--space-3) var(--space-7);
}

.page-section { margin-bottom: var(--space-6); }

.site-footer {
    border-top: 1px solid var(--color-border);
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.site-footer-inner {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: var(--space-5) var(--space-3);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: var(--space-4);
}

.site-footer-heading {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 0 0 var(--space-2);
}

.site-footer-text { margin: 0; }

.site-footer-nav,
.site-footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    align-items: flex-start;
}

.site-footer a { color: var(--color-text-muted); }
.site-footer a:hover { color: var(--color-accent); }

/* ----- 5. Components ------------------------------------------------------ */

/* Hero (landing page) — with a faint CSS "blueprint grid" backdrop */
.hero {
    position: relative;
    padding: var(--space-7) 0 0;
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(var(--color-border) 1px, transparent 1px),
        linear-gradient(90deg, var(--color-border) 1px, transparent 1px);
    background-size: 2.5rem 2.5rem;
    opacity: 0.4;
    -webkit-mask-image: radial-gradient(ellipse 100% 100% at 15% 0%, black, transparent 72%);
    mask-image: radial-gradient(ellipse 100% 100% at 15% 0%, black, transparent 72%);
    pointer-events: none;
}

.hero > * { position: relative; }

.hero-title {
    font-size: clamp(2.5rem, 7vw, 4rem);
    margin-bottom: var(--space-3);
}

.hero-tagline {
    font-size: clamp(1.1rem, 2.5vw, 1.3rem);
    color: var(--color-text-muted);
    max-width: 40rem;
    margin: 0 0 var(--space-4);
    text-wrap: pretty;
}

.hero-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* Section headers (title + optional side link) */
.section-title { font-size: clamp(1.4rem, 3vw, 1.75rem); }

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
}

.section-head .section-title { margin-bottom: 0; }

/* Buttons */
.button {
    display: inline-block;
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.16s ease, color 0.16s ease,
                background 0.16s ease, transform 0.16s ease;
}

.button:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    transform: translateY(-1px);
}

.button-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-text);
}

.button-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: var(--color-accent-text);
}

/* Project cards — text-first, numbered via CSS counters */
.project-grid {
    counter-reset: project;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
    gap: var(--space-4);
}

.project-card {
    counter-increment: project;
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.16s ease, border-color 0.16s ease,
                box-shadow 0.16s ease;
}

.project-card:hover,
.project-card:focus-within {
    transform: translateY(-3px);
    border-color: var(--color-accent);
    box-shadow: var(--shadow-card-hover);
}

.project-card-media img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }

.project-card-body {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    flex: 1;
}

/* The card index: 01, 02, 03 … */
.project-card-body::before {
    content: counter(project, decimal-leading-zero);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    color: var(--color-accent);
}

.project-card-title { font-size: 1.25rem; margin: 0; }

.project-card-title a { text-decoration: none; color: var(--color-text); }
.project-card-title a:hover { color: var(--color-accent); }

/* Make the whole card clickable through the title link */
.project-card-title a::after { content: ""; position: absolute; inset: 0; }

.project-card-summary {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    margin: 0;
    flex: 1;
}

.project-card-cta {
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--color-accent);
}

.project-card:hover .project-card-cta::after,
.project-card:focus-within .project-card-cta::after { transform: translateX(3px); }

.project-card-cta::after {
    content: " \2192";
    display: inline-block;
    transition: transform 0.16s ease;
}

/* Tech tag list (cards + project detail) */
.tech-tags {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: 0;
    margin: 0;
}

.tech-tags li {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 0.15rem var(--space-2);
    border-radius: 999px;
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

/* "Currently" strip (landing page) */
.currently {
    display: flex;
    align-items: baseline;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-alt);
}

.currently-label {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent);
    white-space: nowrap;
}

.currently-label::before {
    content: "";
    display: inline-block;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 999px;
    background: var(--color-accent);
    margin-right: var(--space-2);
    animation: currently-pulse 2.4s ease-in-out infinite;
}

@keyframes currently-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.35; }
}

.currently-text { margin: 0; flex: 1 1 20rem; color: var(--color-text); }

/* Contact CTA band (landing page) */
.cta-band {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-alt);
}

.cta-band .section-title { margin-bottom: var(--space-2); }

.cta-band p {
    color: var(--color-text-muted);
    max-width: 34rem;
    margin: 0 auto var(--space-4);
}

/* Project detail */
.back-link {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    text-decoration: none;
    color: var(--color-text-muted);
    margin-bottom: var(--space-4);
}

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

.project-detail-summary {
    color: var(--color-text-muted);
    font-size: clamp(1.05rem, 2vw, 1.2rem);
    max-width: var(--prose-max-width);
    text-wrap: pretty;
}

.project-detail-header .tech-tags { margin: var(--space-3) 0; }

.project-detail-links {
    display: flex;
    gap: var(--space-2);
    margin: var(--space-3) 0 var(--space-4);
    flex-wrap: wrap;
}

.project-detail-media { margin: var(--space-4) 0; }

.project-detail-media img {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

/* Click-to-load YouTube facade — see docs/DESIGN-DIRECTION.md §6.
   Default state shows the fallback link; js/main.js upgrades it. */
.video-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    margin: var(--space-4) 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--color-accent-soft), var(--color-surface-alt));
    overflow: hidden;
    display: grid;
    place-items: center;
}

.video-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-embed.is-ready > a { display: none; }

.video-embed-play {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    width: 100%;
    height: 100%;
    background: none;
    border: 0;
    font: inherit;
    cursor: pointer;
}

.video-embed-icon {
    display: grid;
    place-items: center;
    width: 4rem;
    height: 4rem;
    border-radius: 999px;
    background: var(--color-accent);
    transition: transform 0.16s ease;
}

.video-embed-icon::before {
    content: "";
    border-style: solid;
    border-width: 0.55rem 0 0.55rem 0.95rem;
    border-color: transparent transparent transparent var(--color-accent-text);
    margin-left: 0.2rem;
}

.video-embed-play:hover .video-embed-icon { transform: scale(1.08); }

.video-embed-label {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* Off-site photo gallery link (Google Drive etc.) — used inside body_html */
.gallery-link {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-4);
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 500;
    color: var(--color-text);
    transition: border-color 0.16s ease;
}

.gallery-link:hover { border-color: var(--color-accent); color: var(--color-accent); }

.gallery-link small {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Prose: long-form HTML from the database or static pages */
.prose { max-width: var(--prose-max-width); }

.prose h2 {
    font-size: 1.4rem;
    margin-top: var(--space-5);
}

.prose h2::before {
    content: "// ";
    color: var(--color-accent);
    font-family: var(--font-mono);
    font-size: 0.75em;
    opacity: 0.8;
}

.prose p, .prose ul, .prose ol { margin: 0 0 var(--space-3); }

.prose li { margin-bottom: var(--space-1); }

.prose blockquote {
    margin: 0 0 var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-left: 3px solid var(--color-accent);
    background: var(--color-surface-alt);
    border-radius: 0 var(--radius) var(--radius) 0;
    color: var(--color-text-muted);
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: var(--space-5) 0;
}

/* Forms */
.contact-form { max-width: 32rem; }

.form-field { margin-bottom: var(--space-3); }

.form-field label {
    display: block;
    margin-bottom: var(--space-1);
    font-family: var(--font-heading);
    font-weight: 500;
}

.form-field input,
.form-field textarea {
    width: 100%;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font: inherit;
    color: var(--color-text);
    transition: border-color 0.16s ease;
}

.form-field input:focus,
.form-field textarea:focus {
    border-color: var(--color-accent);
    outline: 2px solid var(--color-accent);
    outline-offset: 1px;
}

/* Honeypot anti-spam field: keep hidden. DO NOT remove this rule. */
.field-website {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Notices (form feedback) */
.notice {
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    padding: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
}

.notice ul { margin: 0; padding-left: 1.2rem; }

.notice-success { border-left-color: var(--color-success); }
.notice-error   { border-left-color: var(--color-error); }

/* 404 page */
.error-page { text-align: center; padding: var(--space-6) 0; }

.error-page-code {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    color: var(--color-accent);
    margin-bottom: var(--space-2);
}

.error-page p { color: var(--color-text-muted); }

.error-page .button { margin: var(--space-1); }

/* ----- 6. Accessibility & motion ------------------------------------------ */

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
