/* =========================================
   GLOBAL CONFIG / VARIABLES - DARK THEME
========================================= */
:root {
    /* Dark Theme Palette */
    --bg: #111111;
    --bg-elevated: #1a1a1a;
    --text: #f0f0f0;
    --text-muted: #a0a0a0;
    --accent: #ffffff;
    --link: #e5e5e5;
    --brand-red: #de0000;
    --header-h: 80px;

    --container: min(1200px, 92vw);

    --tile-radius: 10px;
    --tile-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
    --hover-scale: 1.03;

    --border-color: #333333;
    --card-bg: #1a1a1a;
    --card-caption-bg: #222222;
    --header-bg: rgba(17, 17, 17, 0.92);

    /* Legacy Aliases (Portrait Home Support) */
    --bg-primary: var(--bg);
    --text-primary: var(--text);
    --text-secondary: var(--text-muted);
    --border-light: var(--border-color);
}

/* =========================================
   RESET & BASE
========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: #111111;
    /* Prevent white flash before CSS vars load */
}

html,
body {
    height: 100vh;
    font-family: "Jost", system-ui, -apple-system, Segoe UI, Roboto, Helvetica,
        Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    line-height: 1.45;
}

a,
a:visited {
    color: inherit;
    text-decoration: none;
}

a:focus-visible {
    outline: 2px solid #007acc;
    outline-offset: 2px;
}

/* =========================================
   VISITED LINK STYLES (prevent purple links)
========================================= */

/* Navigation Links */
.nav-link,
.nav-link:visited {
    color: var(--link);
    opacity: 0.85;
}

.nav-link:hover,
.nav-link:visited:hover {
    opacity: 1;
    color: var(--link);
}

.nav-link.active,
.nav-link.active:visited {
    color: var(--link);
    opacity: 1;
}

/* Footer Links */
.footer-nav a,
.footer-nav a:visited {
    color: var(--text);
    opacity: 0.8;
}

.footer-nav a:hover,
.footer-nav a:visited:hover {
    opacity: 1;
    color: var(--text);
}

/* Card Links */
.card,
.card:visited {
    color: inherit;
}

.tile,
.tile:visited {
    color: inherit;
}

/* Button Links */
.btn,
.btn:visited {
    color: inherit;
}

.btn-primary,
.btn-primary:visited {
    color: var(--bg);
}

.btn-outline,
.btn-outline:visited {
    color: var(--text-primary, #333);
}

.btn-secondary,
.btn-secondary:visited {
    color: inherit;
}

/* Contact & Content Links */
.contact-method a,
.contact-method a:visited {
    color: var(--accent);
}

.contact-method a:hover,
.contact-method a:visited:hover {
    text-decoration: underline;
}

/* Social Links */
.social-link,
.social-link:visited {
    color: var(--text-primary, #333);
}

/* Back Links & Breadcrumbs */
.back-link,
.back-link:visited {
    color: var(--text);
}

.back-link:hover,
.back-link:visited:hover {
    text-decoration: underline;
}

/* Category Navigation */
.category-nav a,
.category-nav a:visited {
    color: #333;
}

.category-nav a:hover,
.category-nav a:visited:hover,
.category-nav a.active,
.category-nav a.active:visited {
    color: #333;
    text-decoration: underline;
    text-decoration-color: var(--brand-red, #de0000);
}

/* General Content Links */
.legal-content a,
.legal-content a:visited,
.about-story a:not(.btn),
.about-story a:visited:not(.btn),
.gallery-text a,
.gallery-text a:visited {
    color: var(--accent);
}

.legal-content a:hover,
.legal-content a:visited:hover,
.about-story a:hover,
.about-story a:visited:hover,
.gallery-text a:hover,
.gallery-text a:visited:hover {
    text-decoration: underline;
}

/* Thank You Page Links */
.thank-you-actions a:not(.btn),
.thank-you-actions a:visited:not(.btn) {
    color: inherit;
}

/* CTA Button Links */
.cta-button,
.cta-button:visited {
    color: inherit;
}

.cta-primary,
.cta-primary:visited {
    color: #333;
}

.cta-secondary,
.cta-secondary:visited {
    color: white;
}

/* Brand Link */
.brand,
.brand:visited {
    color: var(--text);
}

/* Help Links */
.help-links a,
.help-links a:visited {
    color: var(--accent);
}

.help-links a:hover,
.help-links a:visited:hover {
    text-decoration: underline;
}

.page-root {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1 0 auto;
}

main>section:first-child {
    padding-top: 16px;
}

/* Utilities */
.hidden {
    display: none !important;
}

.honeypot {
    display: none !important;
}

.container {
    width: var(--container);
    margin: 0 auto;
    padding: 0 12px;
}

/* =========================================
   HEADER & NAV
========================================= */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    /* Chrome prefers simple rgba over complex backgrounds for backdrop-filter */
    background: rgba(17, 17, 17, 0.8);
    backdrop-filter: saturate(140%) blur(6px);
    -webkit-backdrop-filter: saturate(140%) blur(6px);
    border-bottom: 1px solid var(--border-color);
    /* Force Hardware Acceleration */
    transform: translateZ(0);
}

.header-inner {
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: var(--container);
    margin: 0 auto;
    padding: 0 12px;
}

.brand-wrap {
    display: inline-flex;
    align-items: baseline;
    gap: 10px;
}

.brand {
    font-weight: 600;
    letter-spacing: 0.18em;
    text-decoration: none;
    color: var(--text);
    font-size: 1rem;
    white-space: nowrap;
}

.context-label {
    white-space: nowrap;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-size: 0.72rem;
    color: var(--muted);
    opacity: 0.9;
}

.main-nav {
    display: flex;
    gap: 15px;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--link);
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.82rem;
    opacity: 0.85;
    padding: 10px 8px;
    transition: opacity 180ms ease, color 180ms ease;
    text-underline-offset: 4px;
}

.nav-link.active {
    color: var(--link);
    opacity: 1;
    text-decoration: underline;
    text-decoration-color: var(--brand-red);
}

.nav-link:visited {
    color: var(--link);
    opacity: 0.85;
}

.nav-link:hover,
.nav-link:visited:hover {
    opacity: 1;
    color: var(--link);
}

.nav-link.active:visited {
    color: var(--link);
    opacity: 1;
}

.nav-toggle {
    display: none;
    border: 0;
    background: transparent;
    width: 36px;
    height: 28px;
    position: relative;
    cursor: pointer;
}

.nav-toggle span {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--text);
    transition: transform 200ms ease, opacity 200ms ease;
}

.nav-toggle span:nth-child(1) {
    top: 4px;
}

.nav-toggle span:nth-child(2) {
    top: 13px;
}

.nav-toggle span:nth-child(3) {
    top: 22px;
}

/* =========================================
   FOOTER
========================================= */
.site-footer {
    position: relative;
    border-top: 1px solid var(--border-color);
    margin-top: 24px;
    flex-shrink: 0;
    overflow: hidden;
    padding: 72px 0 0;
}

.footer-inner {
    width: var(--container);
    margin: 0 auto;
    padding: 0 12px 100px;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.footer-meta {
    font-size: 0.82rem;
    opacity: 0.7;
}

.footer-attribution {
    text-align: center;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.footer-attribution a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.footer-attribution svg {
    width: 14px;
    height: 14px;
    color: var(--brand-red, #de0000);
    transition: transform 200ms ease;
}

.footer-attribution a:hover svg {
    transform: scale(1.15) translateY(-1px);
}

/* Rainbow text effect */
.rainbow-text {
    background-image: linear-gradient(to right,
            #ff0000,
            #ff7f00,
            #ffff00,
            #00ff00,
            #0000ff,
            #4b0082,
            #8b00ff,
            #ff0000);
    background-size: 200% auto;
    color: transparent;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: rainbow-flow 4s linear infinite;
    position: relative;
}

.rainbow-text::after {
    content: '';
    position: absolute;
    width: 100%;
    transform: scaleX(0);
    height: 1px;
    bottom: -2px;
    left: 0;
    background: linear-gradient(to right, #ff0000, #ff7f00, #ffff00, #00ff00, #0000ff, #4b0082, #8b00ff);
    transform-origin: bottom right;
    transition: transform 0.3s ease-out;
}

.rainbow-text:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

@keyframes rainbow-flow {
    to {
        background-position: 200% center;
    }
}

/* Footer social – centered row */
.footer-social {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
}

.footer-social a {
    display: flex;
    align-items: center;
    color: var(--text-muted);
    opacity: 0.7;
    transition: opacity 180ms ease, color 180ms ease;
}

.footer-social a:hover {
    opacity: 1;
    color: var(--text);
}

.footer-social a:visited {
    color: var(--text-muted);
}

.footer-social svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Footer nav – single centered row */
.footer-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px 24px;
}

.footer-nav a {
    text-decoration: none;
    color: var(--text);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.74rem;
    opacity: 0.8;
}

.footer-nav a:hover {
    opacity: 1;
    text-decoration: underline;
    text-decoration-color: var(--brand-red, #de0000);
}

.footer-nav a:visited {
    color: var(--text);
    opacity: 0.8;
}

.footer-nav a:visited:hover {
    opacity: 1;
    color: var(--text);
}

/* Watermark name */
.footer-watermark {
    width: 100%;
    text-align: center;
    font-size: clamp(10rem, 15vw, 17rem);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text);
    opacity: 0.04;
    line-height: 0.85;
    user-select: none;
    pointer-events: none;
    white-space: nowrap;
    /* Partially crop the bottom */
    margin-bottom: -0.25em;
}

/* =========================================
   CARDS (global pattern for Portfolio/Projects)
========================================= */
.card-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 18px;
}

.card {
    grid-column: span 4;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--tile-shadow);
    background: var(--card-bg);
    isolation: isolate;
    display: grid;
    grid-template-rows: 1fr auto;
    transition: transform 200ms ease, box-shadow 200ms ease;
}

.card:visited {
    color: inherit;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.1);
}

.card-media {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scale(1.01);
    transition: transform 260ms ease, filter 260ms ease;
    filter: contrast(1.02);
}

.card:hover .card-media img {
    transform: scale(1.02);
    filter: contrast(1.04);
}

.card-caption {
    background: var(--card-caption-bg);
    display: grid;
    place-items: center;
    padding: 14px 10px;
}

.card-caption h3 {
    margin: 0;
    font-size: 0.92rem;
    letter-spacing: 0.16em;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
}

/* =========================================
   WORK HOMEPAGE GRID (7-up tiles)
========================================= */
.hero-grid {
    padding: 24px 0 40px;
}

.grid {
    width: var(--container);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    /* now 7-up */
    gap: 12px;
    align-items: center;
}

.tile {
    display: grid;
    grid-template-rows: 1fr auto;
    border-radius: var(--tile-radius);
    overflow: hidden;
    text-decoration: none;
    box-shadow: var(--tile-shadow);
    background: var(--card-bg);
    isolation: isolate;
}

.tile:visited {
    color: inherit;
}

.tile-media {
    position: relative;
    aspect-ratio: 1 / 3.55;
    overflow: hidden;
}

.tile-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: grayscale(30%) contrast(1.05);
    transform: scale(1.02);
    transition: filter 300ms ease, transform 300ms ease;
}

.tile:hover .tile-media img {
    filter: grayscale(0%) contrast(1.0);
    transform: scale(var(--hover-scale));
}

.tile-caption {
    display: grid;
    place-items: center;
    padding: 16px 10px;
    background: var(--card-caption-bg);
}

.tile-caption h2 {
    margin: 0;
    font-size: 0.94rem;
    letter-spacing: 0.18em;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
}

.hero-cta {
    width: var(--container);
    margin: 28px auto 0;
    display: grid;
    place-items: center;
}

/* =========================================
   BUTTONS (global style, reused CTA across pages)
========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 22px;
    border-radius: 999px;
    text-decoration: none;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    font-weight: 600;
    font-size: 0.82rem;
    transition: transform 200ms ease, box-shadow 200ms ease, opacity 200ms ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
    opacity: 0.95;
}

.btn:visited,
.btn-primary:visited {
    color: var(--bg);
}

.btn-outline:visited {
    color: var(--text-primary, #333);
}

.btn-secondary:visited {
    color: inherit;
}

/* =========================================
   RESPONSIVE
========================================= */
@media (max-width: 1320px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
        /* 3-up sooner than 7 */
    }

}

@media (max-width: 980px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2-up on tablets */
    }
}

@media (max-width: 720px) {
    .grid {
        grid-template-columns: 1fr;
        /* single column */
    }

    .tile-media {
        aspect-ratio: 3 / 4;
    }
}

@media (max-width: 980px) {
    .card {
        grid-column: span 6;
    }
}

@media (max-width: 720px) {
    .card {
        grid-column: span 12;
    }
}

@media (max-width: 900px) {
    .brand-wrap {
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
    }

    .nav-toggle {
        display: inline-block;
        z-index: 101;
        flex-shrink: 0;
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(1) {
        transform: translateY(9px) rotate(45deg);
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(2) {
        opacity: 0;
    }

    .nav-toggle[aria-expanded="true"] span:nth-child(3) {
        transform: translateY(-9px) rotate(-45deg);
    }

    .main-nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;

        background: rgba(17, 17, 17, 0.8);
        backdrop-filter: saturate(140%) blur(6px);
        -webkit-backdrop-filter: saturate(140%) blur(6px);
        /* Force Hardware Acceleration */
        transform: translateZ(0);

        display: none;

        padding: 100px 24px 24px;
        flex-direction: column;
        align-items: center;
        gap: 18px;
        z-index: 100;

        transform: translateY(-100%);
        transition: transform 350ms ease-in-out;
    }

    .main-nav.open {
        display: flex;
        transform: translateY(0);
    }

    .main-nav .nav-link {
        font-size: 1.1rem;
        letter-spacing: 0.14em;
        padding: 14px 8px;
    }
}