/* ── Reset & Base ────────────────────────────────────────────────── */
/* Zero out browser default margins/padding on every element and its
   ::before / ::after pseudo-elements. box-sizing:border-box makes padding
   and borders count INSIDE the declared width/height, which avoids
   the classic 'element is wider than expected' bug. */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ── Design tokens — a single source of truth for the colour palette ──
   Changing one value here updates every rule that references the variable.
   --bg / --surface: near-black page and card backgrounds
   --border:         very dark rule colour (just enough separation)
   --text / --muted: body copy and dimmer secondary text
   --accent:         warm gold — used for the logo, links, and hover effects
   --font-serif:     used for the logo and card titles (old-world feel)
   --font-sans:      used for all body copy and UI text
*/
:root {
    --bg:        #08080d;
    --surface:   #0f0f17;
    --surface-hover: #151520;
    --border:    #1a1a2a;
    --text:      #d0d0e0;
    --muted:     #8888a0;
    --accent:    #c4a86a;
    --accent-glow: rgba(196, 168, 106, 0.15);
    --header-bg: rgba(8, 8, 13, 0.88);
    --tag-bg:    rgba(255,255,255,0.02);
    --tag-border: rgba(255,255,255,0.06);
    --font-serif: 'Georgia', 'Times New Roman', serif;
    --font-sans:  system-ui, -apple-system, 'Segoe UI', sans-serif;
    --radius:    10px;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.4);
    --card-shadow-hover: 0 8px 32px rgba(0,0,0,0.6), 0 0 20px var(--accent-glow);
    --card-title: #eae2d2;
    color-scheme: dark;
}

/* ── Light theme ─────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg:        #f4f2ee;
    --surface:   #ffffff;
    --surface-hover: #faf9f6;
    --border:    #e0ddd6;
    --text:      #2a2a30;
    --muted:     #5e5e6e;
    --accent:    #8a7340;
    --accent-glow: rgba(138, 115, 64, 0.12);
    --header-bg: rgba(244, 242, 238, 0.9);
    --tag-bg:    rgba(0,0,0,0.03);
    --tag-border: rgba(0,0,0,0.08);
    --card-shadow: 0 1px 6px rgba(0,0,0,0.08);
    --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.12), 0 0 16px var(--accent-glow);
    --card-title: #2a2520;
    color-scheme: light;
}

/* Auto-detect system preference when no manual override */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg:        #f4f2ee;
        --surface:   #ffffff;
        --surface-hover: #faf9f6;
        --border:    #e0ddd6;
        --text:      #2a2a30;
        --muted:     #5e5e6e;
        --accent:    #8a7340;
        --accent-glow: rgba(138, 115, 64, 0.12);
        --header-bg: rgba(244, 242, 238, 0.9);
        --tag-bg:    rgba(0,0,0,0.03);
        --tag-border: rgba(0,0,0,0.08);
        --card-shadow: 0 1px 6px rgba(0,0,0,0.08);
        --card-shadow-hover: 0 6px 24px rgba(0,0,0,0.12), 0 0 16px var(--accent-glow);
        --card-title: #2a2520;
        color-scheme: light;
    }
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background 0.3s ease, color 0.3s ease;
}

/* ── Skip-to-content link (shared by index and project pages) ────── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: var(--accent, #c4a86a);
    color: #000;
    font-weight: 700;
    border-radius: 0 0 4px 4px;
    text-decoration: none;
    transition: top 0.1s;
}
.skip-link:focus { top: 0; }

/* ── Screen-reader only ──────────────────────────────────────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

/* ── Keyboard focus styles ───────────────────────────────────────── */
/* Visible focus ring only when navigating by keyboard (not mouse). */
:focus-visible {
    outline: 2px solid var(--accent, #c4a86a);
    outline-offset: 3px;
    border-radius: 3px;
}

/* ── Theme toggle ────────────────────────────────────────────────── */
.theme-toggle {
    position: absolute;
    top: 50%;
    right: 1.2rem;
    transform: translateY(-50%);
    background: none;
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: var(--muted);
    transition: color 0.3s, border-color 0.3s;
    padding: 0;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
}
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { display: none; }

/* Dark mode: show sun icon (to switch to light) */
:root:not([data-theme]) .theme-toggle .icon-sun { display: inline; }
:root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) .theme-toggle .icon-sun { display: none; }
    :root:not([data-theme]) .theme-toggle .icon-moon { display: inline; }
}

/* ── Header ──────────────────────────────────────────────────────── */
/* position:sticky keeps the header attached to the top of the viewport
   while the user scrolls the project grid.
   backdrop-filter:blur() creates the frosted-glass effect — it blurs
   whatever is behind the semi-transparent background. The -webkit- prefix
   is needed for Safari. z-index:100 puts it above everything else
   including the cards' hover transform (which defaults to ~z-index:1). */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
}

.header-inner {
    max-width: 760px;
    margin: 0 auto;
    position: relative;
}

/* clamp(min, preferred, max) lets the font size scale fluidly with the
   viewport width (6vw) but never go below 2rem on phones or above 3.5rem
   on large screens — a simpler alternative to writing multiple @media queries. */
.logo {
    font-family: var(--font-serif);
    font-size: clamp(1.8rem, 5vw, 2.8rem);
    font-weight: normal;
    letter-spacing: 0.14em;
    color: var(--accent);
    text-transform: uppercase;
    margin-bottom: 0.4rem;
    text-shadow: 0 0 30px var(--accent-glow);
}

.tagline {
    font-size: 0.88rem;
    color: var(--muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 400;
}

/* ── Main ────────────────────────────────────────────────────────── */
main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 3.5rem 2rem;
    width: 100%;
}

/* ── Intro ───────────────────────────────────────────────────────── */
.intro {
    max-width: 600px;
    margin: 0 auto 3rem;
    text-align: center;
}

.intro p {
    font-size: 1.02rem;
    color: var(--muted);
    line-height: 1.85;
    font-weight: 400;
}

.intro a {
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}
.intro a:hover {
    color: var(--accent);
    text-decoration: none;
    border-color: var(--accent);
}

/* ── Filter Bar ──────────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    max-width: 800px;
    margin: 0 auto 2.5rem;
}

.filter-btn {
    font-family: var(--font-sans);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--tag-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.3rem 0.9rem;
    cursor: pointer;
    transition: all 0.25s ease;
}

.filter-btn:hover {
    color: var(--text);
    border-color: var(--muted);
    background: var(--tag-bg);
}

.filter-btn.active {
    color: var(--bg);
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Project Grid ────────────────────────────────────────────────── */
/* repeat(auto-fill, minmax(320px, 1fr)) means:
   - fill as many columns as fit, each being at least 320px wide
   - any remaining space is distributed evenly (1fr = 1 fraction of free space)
   On a 375px phone this gives one column; on a 700px tablet two columns;  
   on a 1100px desktop three columns — all with zero JavaScript. */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
    gap: 1.5rem;
}

/* ── Card ────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: color-mix(in srgb, var(--accent) 50%, transparent);
    transform: translateY(-4px);
    box-shadow: var(--card-shadow-hover);
    background: var(--surface-hover);
}

.card-link {
    display: flex;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
    height: 100%;
    -webkit-tap-highlight-color: transparent;
}
.card-link:hover { text-decoration: none; }

/* ── Card Preview (thumbnail area) ──────────────────────────────── */
/* color-mix() blends the card's --accent colour (15%) into the page background.
   It acts as a tinted fallback colour visible behind the gradient overlay. */
.card-preview {
    height: 160px;
    background: color-mix(in srgb, var(--accent, #333) 10%, var(--bg));
    position: relative;
    overflow: hidden;
}

/* The inner div holds the decorative gradient 'scene preview'.
   background-size:200%×200% makes the gradient larger than the element so
   the @keyframes shimmer animation can shift background-position and create
   a slow panning / breathing effect. */
.card-preview-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.75;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 0;
}

.card:hover .card-preview-img {
    opacity: 0.9;
    transform: scale(1.05);
}

.card-preview-inner {
    position: absolute;
    inset: 0;
    background-size: 200% 200%;
    animation: shimmer 8s ease infinite;
    opacity: 0.6;
    transition: opacity 0.4s ease, transform 0.4s ease;
    z-index: 1;
}

.card:hover .card-preview-inner {
    opacity: 0.85;
    transform: scale(1.05);
}

.war-preview {
    background-image: radial-gradient(ellipse at 30% 70%, #8a2a00 0%, transparent 60%),
                      radial-gradient(ellipse at 70% 40%, #4a1a00 0%, transparent 50%),
                      radial-gradient(ellipse at 50% 90%, #cc4400 0%, transparent 40%);
}

.gha-preview {
    background-image: radial-gradient(ellipse at 40% 60%, #001a3a 0%, transparent 60%),
                      radial-gradient(ellipse at 70% 30%, #0a1a30 0%, transparent 50%),
                      radial-gradient(ellipse at 20% 80%, #001428 0%, transparent 40%);
}

.psychedelic-preview {
    background-image: radial-gradient(ellipse at 50% 50%, #3a006a 0%, transparent 55%),
                      radial-gradient(ellipse at 20% 30%, #00606a 0%, transparent 45%),
                      radial-gradient(ellipse at 80% 70%, #6a003a 0%, transparent 40%),
                      radial-gradient(ellipse at 60% 20%, #006a20 0%, transparent 35%);
}

.dayearth-preview {
    background-image: radial-gradient(ellipse at 50% 60%, #1a4a8a 0%, transparent 55%),
                      radial-gradient(ellipse at 30% 30%, #0a2a50 0%, transparent 50%),
                      radial-gradient(ellipse at 70% 80%, #0a3060 0%, transparent 40%);
}

.mazerunner-preview {
    background-image: radial-gradient(ellipse at 40% 50%, #1a6a3a 0%, transparent 55%),
                      radial-gradient(ellipse at 70% 30%, #0a3a1a 0%, transparent 50%),
                      radial-gradient(ellipse at 30% 80%, #2a8a4a 0%, transparent 40%);
}

.estateagency-preview {
    background-image: radial-gradient(ellipse at 50% 60%, #1a5a3a 0%, transparent 55%),
                      radial-gradient(ellipse at 30% 30%, #0a3a1a 0%, transparent 50%),
                      radial-gradient(ellipse at 70% 80%, #2a6a4a 0%, transparent 40%);
}

.thejoog-preview {
    background-image: radial-gradient(ellipse at 50% 50%, #0a3a5a 0%, transparent 55%),
                      radial-gradient(ellipse at 30% 30%, #002a4a 0%, transparent 50%),
                      radial-gradient(ellipse at 70% 70%, #0088bb 0%, transparent 40%);
}

@keyframes shimmer {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Scan-line overlay on preview — uses ::after pseudo-element so no extra HTML element is needed.
   repeating-linear-gradient creates an infinite pattern of 1px dark lines every 4px,
   simulating the look of a CRT monitor or surveillance screen.
   pointer-events:none ensures the overlay doesn't block hover/click on the card link. */
.card-preview::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 2;
    background:
        linear-gradient(180deg, transparent 60%, var(--surface) 100%),
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 3px,
            rgba(0,0,0,0.08) 3px,
            rgba(0,0,0,0.08) 4px
        );
    pointer-events: none;
}

/* ── Card Body ───────────────────────────────────────────────────── */
.card-body {
    padding: 1.1rem 1.3rem 1.2rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.card-title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: normal;
    color: var(--card-title);
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
    transition: color 0.3s;
}

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

.card-desc {
    font-size: 0.88rem;
    color: var(--muted);
    line-height: 1.65;
    margin-bottom: 0.8rem;
}

/* ── Tags ────────────────────────────────────────────────────────── */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.8rem;
}

.tag {
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border: 1px solid var(--tag-border);
    color: var(--muted);
    padding: 3px 9px;
    border-radius: 4px;
    background: var(--tag-bg);
    transition: border-color 0.3s, color 0.3s;
}

.card:hover .tag {
    border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    color: var(--text);
}

/* ── CTA ─────────────────────────────────────────────────────────── */
/* "Enter →" arrow — hidden by default (opacity:0), fades in only when the
   whole .card is hovered. This is done with the child selector (.card:hover .card-cta)
   rather than :hover on the element itself, so moving the mouse anywhere
   over the card triggers it. transition:opacity keeps the fade smooth. */
.card-cta {
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent);
    opacity: 0;
    transform: translateX(-6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: block;
    margin-top: auto;
}

.card:hover .card-cta {
    opacity: 1;
    transform: translateX(0);
}

/* ── Footer ──────────────────────────────────────────────────────── */
footer {
    border-top: 1px solid var(--border);
    text-align: center;
    padding: 2.5rem 2rem;
    font-size: 0.82rem;
    color: var(--muted);
    letter-spacing: 0.04em;
    font-weight: 400;
}

footer a {
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 1px;
}
footer a:hover {
    color: var(--accent);
    border-color: var(--accent);
    text-decoration: none;
}

/* ── Contact Section ─────────────────────────────────────────────── */
.contact-section {
    max-width: 540px;
    margin: 3.5rem auto 0;
    padding-top: 3rem;
    border-top: 1px solid var(--border);
}

.contact-heading {
    font-family: var(--font-serif);
    font-size: clamp(1.3rem, 3vw, 1.8rem);
    font-weight: normal;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 0.6rem;
}

.contact-intro {
    font-size: 0.92rem;
    color: var(--muted);
    text-align: center;
    line-height: 1.7;
    margin-bottom: 2rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-label {
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 400;
}

.form-input {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.7rem 1rem;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
    outline: none;
    width: 100%;
}

.form-input::placeholder {
    color: var(--muted);
    opacity: 0.5;
}

.form-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input:invalid:not(:placeholder-shown):not(:focus) {
    border-color: #a04040;
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.65;
}

.form-submit {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--bg);
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    padding: 0.8rem 2rem;
    cursor: pointer;
    transition: opacity 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    align-self: flex-start;
}

.form-submit:hover {
    opacity: 0.9;
    box-shadow: 0 0 16px var(--accent-glow);
    transform: translateY(-1px);
}

.form-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.form-status {
    font-size: 0.85rem;
    min-height: 1.4em;
}

.form-status--success {
    color: #5cb85c;
}

.form-status--error {
    color: #d9534f;
}

/* ── Responsive — small screens ──────────────────────────────────── */
@media (max-width: 600px) {
    header { padding: 1.6rem 1rem 1.3rem; }

    .theme-toggle { right: 0.6rem; }

    main { padding: 2rem 1rem; }

    .intro { margin-bottom: 2rem; }

    .filter-bar {
        gap: 0.3rem;
        margin-bottom: 1.8rem;
    }

    .filter-btn {
        font-size: 0.7rem;
        padding: 0.35rem 0.75rem;
        min-height: 32px;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 1.2rem;
    }

    .card-preview { height: 130px; }

    .card-body { padding: 0.9rem 1.1rem 1rem; }

    .card-desc { font-size: 0.85rem; }

    .card-cta { opacity: 1; transform: none; }

    footer { padding: 2rem 1rem; }

    .contact-section { margin-top: 2.5rem; padding-top: 2rem; }
    .form-submit { align-self: stretch; }
}

/* ── Responsive — medium screens ─────────────────────────────────── */
@media (min-width: 601px) and (max-width: 900px) {
    main { padding: 2.5rem 1.5rem; }

    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ── Reduced motion ──────────────────────────────────────────────── */
@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;
    }
}

/* ── Print ───────────────────────────────────────────────────────── */
@media print {
    header { position: static; backdrop-filter: none; }
    .theme-toggle,
    .filter-bar,
    .card-preview,
    .card-cta,
    .contact-form { display: none; }
    .card { break-inside: avoid; box-shadow: none; border: 1px solid #ccc; }
    body { background: #fff; color: #000; }
}

/* ── Safe-area insets (notched/Dynamic Island phones) ────────────── */
@supports (padding: env(safe-area-inset-bottom)) {
    body {
        padding-left:   env(safe-area-inset-left);
        padding-right:  env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
    footer {
        padding-bottom: calc(1.8rem + env(safe-area-inset-bottom));
    }
}

/* ── Narrow phones (≤400px) ──────────────────────────────────────── */
@media (max-width: 400px) {
    .logo { letter-spacing: 0.06em; }
    .intro p { font-size: 0.95rem; }
}
