/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 17px;
    line-height: 1.6;
    min-height: 100vh;
}

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

a { color: inherit; }

button {
    background: none;
    border: 0;
    color: inherit;
    cursor: pointer;
    font: inherit;
}

/* ===== Tokens ===== */
:root {
    --bg: #f5f1ea;
    --bg-card: #fbf8f1;
    --ink: #1a1815;
    --ink-soft: #3a342c;
    --ink-mute: #8b7d65;
    --rule: #d9d2c4;
    --rule-soft: #e8e1d2;

    --font-body: 'Iowan Old Style', Georgia, 'Times New Roman', serif;
    --font-display: 'Arial Black', 'Arial Bold', sans-serif;
    --font-meta: 'Helvetica Neue', Arial, sans-serif;
    --font-product: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;

    --max-content: 720px;
    --max-wide: 1100px;

    --space-xs: 0.5rem;
    --space-sm: 1rem;
    --space-md: 1.5rem;
    --space-lg: 2.5rem;
    --space-xl: 4rem;
    --space-xxl: 6rem;
}

/* ===== Top meta bar ===== */
.top-meta {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 2rem;
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--ink-mute);
    z-index: 100;
    background: linear-gradient(to bottom, rgba(245, 241, 234, 0.95), rgba(245, 241, 234, 0));
    pointer-events: none;
}

.top-meta a {
    color: var(--ink-mute);
    text-decoration: none;
    pointer-events: auto;
    transition: color 0.2s;
}

.top-meta a:hover { color: var(--ink); }

.top-meta .nav { display: flex; gap: 1.75rem; }

.top-meta .brand { display: inline-flex; align-items: baseline; }
.top-meta .page-number { margin-left: 0.7em; color: var(--ink-mute); pointer-events: none; }
.top-meta .page-number:empty { display: none; }
.top-meta .page-number:not(:empty)::before {
    content: '·';
    margin-right: 0.5em;
}

/* ===== Table of Contents page ===== */
.toc-page { max-width: var(--max-wide); }

.toc-issue {
    font-family: var(--font-meta);
    font-size: 0.75rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-top: -1rem;
    margin-bottom: 2.5rem;
}

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

.toc-entry { border-bottom: 1px solid var(--rule-soft); }

.toc-row {
    display: grid;
    grid-template-columns: 2.5em minmax(min-content, max-content) 1fr auto auto;
    column-gap: 1.25rem;
    align-items: baseline;
    padding: 1.4rem 0.5rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s, padding-left 0.2s;
}

.toc-row:hover { background: var(--bg-card); padding-left: 1rem; }

.toc-num {
    font-family: var(--font-meta);
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    color: var(--ink-mute);
}

.toc-name {
    font-family: var(--font-product);
    font-weight: 600;
    font-size: 1.5rem;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.toc-row:hover .toc-name { text-decoration: underline; text-underline-offset: 4px; }

.toc-leader {
    border-bottom: 1px dotted var(--rule);
    height: 0.55em;
    margin: 0 0.4rem;
    align-self: end;
    transform: translateY(-0.2em);
}

.toc-meta {
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
    white-space: nowrap;
}

.toc-year {
    font-family: var(--font-meta);
    font-size: 0.78rem;
    color: var(--ink-mute);
    letter-spacing: 0.05em;
    min-width: 4.5em;
    text-align: right;
}

.toc-foot {
    margin-top: 2.5rem;
    font-size: 0.85rem;
    color: var(--ink-mute);
}

@media (max-width: 720px) {
    .toc-row {
        grid-template-columns: 2em 1fr auto;
        grid-template-rows: auto auto;
        column-gap: 1rem;
        row-gap: 0.25rem;
    }
    .toc-leader { display: none; }
    .toc-name { font-size: 1.25rem; }
    .toc-num { grid-row: 1 / 3; }
    .toc-meta { grid-column: 2; grid-row: 2; }
    .toc-year { grid-column: 3; grid-row: 1 / 3; align-self: center; }
}

/* ===== Hero ===== */
.hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0 2rem;
    position: relative;
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 900;
    font-size: clamp(2.5rem, 9vw, 7rem);
    letter-spacing: 0.08em;
    color: var(--ink);
    user-select: none;
    line-height: 1;
    display: flex;
}

.wordmark .letter {
    display: inline-block;
    transition: transform 0.15s ease-out;
    will-change: transform;
}

.tagline {
    margin-top: 2.5rem;
    font-family: var(--font-product);
    font-style: italic;
    font-size: clamp(1.05rem, 1.6vw, 1.35rem);
    color: var(--ink-soft);
    font-weight: 400;
}

.scroll-cue {
    position: absolute;
    bottom: 3rem;
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    color: var(--ink-mute);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    transition: color 0.2s, transform 0.3s;
}

.scroll-cue:hover { color: var(--ink); transform: translateY(2px); }

.scroll-cue .arrow {
    font-size: 0.9rem;
    display: inline-block;
    transition: transform 0.15s ease-out;
}

/* ===== Work section (toggle, instant reveal) ===== */
.work-section {
    display: none;
    scroll-margin-top: 70px;
}

.work-section.open { display: block; }

.work-inner {
    max-width: var(--max-wide);
    margin: 0 auto;
    padding: var(--space-xl) 2rem var(--space-xxl);
}

.work-header {
    border-bottom: 1px solid var(--rule);
    padding-bottom: 1rem;
    margin-bottom: 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
}

.work-header .label {
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-mute);
}

.work-header h2 {
    font-family: var(--font-product);
    font-size: 2rem;
    font-weight: 600;
    font-style: italic;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.proj-card {
    background: var(--bg-card);
    border: 1px solid var(--rule-soft);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, transform 0.2s;
}

.proj-card:hover {
    border-color: var(--ink);
    transform: translateY(-2px);
}

.proj-card .logo-slot {
    width: 56px;
    height: 56px;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    background: var(--rule-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.proj-card .logo-slot img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.proj-card .name {
    font-family: var(--font-product);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

.proj-card .meta {
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 1rem;
}

.proj-card .desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--ink-soft);
    flex-grow: 1;
}

.proj-card .url {
    margin-top: 1.25rem;
    font-family: var(--font-meta);
    font-size: 0.75rem;
    color: var(--ink-mute);
    letter-spacing: 0.05em;
}

.proj-card:hover .url { color: var(--ink); }

/* ===== Editorial pages (about, contact, privacy, etc.) ===== */
.page {
    max-width: var(--max-content);
    margin: 0 auto;
    padding: 6rem 2rem 4rem;
}

.page-title {
    font-family: var(--font-product);
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3rem);
    margin-bottom: 0.5rem;
    letter-spacing: -0.01em;
}

.page-rule {
    width: 48px;
    height: 2px;
    background: var(--ink);
    margin: 1.5rem 0 2.5rem;
}

.page p {
    margin-bottom: 1rem;
    color: var(--ink-soft);
}

.page p a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--ink);
    transition: background 0.2s, color 0.2s;
}

.page p a:hover {
    background: var(--ink);
    color: var(--bg);
    border-bottom-color: transparent;
}

.page h2 {
    font-family: var(--font-product);
    font-weight: 600;
    font-size: 1.4rem;
    margin: 2rem 0 0.75rem;
}

.page ul {
    margin-left: 1.25rem;
    margin-bottom: 1rem;
    color: var(--ink-soft);
}

.page ul li { margin-bottom: 0.35rem; }

/* About page specifics */
.about-hero {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.about-photo {
    width: 180px;
    height: 180px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--rule-soft);
}

.about-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.about-intro p {
    margin-bottom: 0.75rem;
}

.about-section .label {
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--rule);
    padding-bottom: 0.5rem;
}

.about-section { margin-top: 2.5rem; }

.about-section .resume-link {
    display: inline-block;
    margin-top: 0.5rem;
    font-family: var(--font-meta);
    font-size: 0.85rem;
    letter-spacing: 0.05em;
}

@media (max-width: 600px) {
    .about-hero { flex-direction: column; }
    .about-photo { width: 140px; height: 140px; }
}

/* ===== Forms (login / signup) ===== */
.auth-card {
    max-width: 380px;
    margin: 6rem auto 4rem;
    padding: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--rule);
}

.auth-card h1 {
    font-family: var(--font-product);
    font-weight: 600;
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-form .field {
    margin-bottom: 1rem;
}

.auth-form label {
    display: block;
    font-family: var(--font-meta);
    font-size: 0.7rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-mute);
    margin-bottom: 0.4rem;
}

.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--rule);
    background: var(--bg);
    color: var(--ink);
    font: inherit;
    transition: border-color 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--ink);
}

.auth-form .btn-primary {
    width: 100%;
    padding: 0.75rem;
    background: var(--ink);
    color: var(--bg);
    font-family: var(--font-meta);
    font-size: 0.8rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 0.5rem;
}

.auth-form .btn-primary:hover { background: var(--ink-soft); }

.auth-card .auth-alt {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.auth-card .auth-alt a {
    color: var(--ink);
    text-decoration: none;
    border-bottom: 1px solid var(--ink);
}

.auth-card .alert {
    background: #f8e0dc;
    border: 1px solid #d4756b;
    color: #6a2218;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ===== Footer ===== */
.site-footer {
    border-top: 1px solid var(--rule);
    padding: 2rem;
    text-align: center;
    font-family: var(--font-meta);
    font-size: 0.75rem;
    color: var(--ink-mute);
    letter-spacing: 0.05em;
}

.site-footer a {
    color: var(--ink-mute);
    text-decoration: none;
    margin: 0 0.6rem;
    transition: color 0.2s;
}

.site-footer a:hover { color: var(--ink); }

.site-footer .copyright {
    margin-top: 0.5rem;
    color: var(--ink-mute);
    opacity: 0.8;
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
    .wordmark .letter { transition: none; }
    .scroll-cue { transition: none; }
    .proj-card { transition: none; }
    .proj-card:hover { transform: none; }
}
