/* ============================================================
   Design tokens — the only place raw values (colors, spacing,
   widths) should appear. Everything else references these
   custom properties, never hardcodes a hex/px value directly.
   ============================================================ */

:root {
    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Layout */
    --container: 1200px;
    --reading-width: 720px;
    --grid-columns: 12;
    --grid-gap: var(--space-6);

    /* Color — warm neutral base, restrained dark ink, one muted accent.
       Photography supplies most of the color on the page. */
    --ink: #1f1f1d;
    --ink-soft: #57564f;
    --paper: #f5f3ef;
    --paper-raised: #ffffff;
    --line: #d8d4cd;
    --accent: #8a6f4e; /* muted warm brown — use sparingly (links, active states) */

    /* Typography */
    --font-display: Georgia, 'Times New Roman', serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-body: 1rem;
    --line-height-body: 1.6;

    /* Motion — minimal by design; honored only when the visitor allows it */
    --transition-fast: 150ms ease;
}

@media (prefers-reduced-motion: reduce) {
    :root {
        --transition-fast: 0ms;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: var(--font-size-body);
    line-height: var(--line-height-body);
}

h1, h2, h3 {
    font-family: var(--font-display);
    line-height: 1.2;
    margin: 0 0 var(--space-4);
}

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

/* ============================================================
   Layout primitives
   ============================================================ */

.site-header {
    border-bottom: 1px solid var(--line);
    padding: var(--space-4) var(--space-6);
}

.container {
    max-width: var(--container);
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* ============================================================
   Hero module
   ============================================================ */

.hero {
    position: relative;
}

.hero__media img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.hero__content {
    padding: var(--space-8) var(--space-4);
    max-width: var(--reading-width);
    margin: 0 auto;
}

/* ============================================================
   Article / rich text
   ============================================================ */

.article {
    max-width: var(--reading-width);
    margin: 0 auto;
}

.article__body p {
    margin: 0 0 var(--space-4);
}

.article__section {
    margin-bottom: var(--space-12);
}

/* ============================================================
   Cards (used sparingly per "no card-heavy layouts" — Section 9)
   ============================================================ */

.project-card,
.firm-card,
.entity-card {
    border: none;
    border-top: 1px solid var(--line);
    padding: var(--space-4) 0;
}

/* ============================================================
   Gallery
   ============================================================ */

.gallery {
    display: grid;
    grid-template-columns: repeat(var(--grid-columns), 1fr);
    gap: var(--grid-gap);
}

.gallery--masonry {
    column-count: 3;
    column-gap: var(--grid-gap);
}

.gallery--masonry > * {
    break-inside: avoid;
    margin-bottom: var(--grid-gap);
}

.gallery--feature img {
    grid-column: span 12;
    width: 100%;
}

/* ============================================================
   Comparison table
   ============================================================ */

.compare-table {
    width: 100%;
    border-collapse: collapse;
}

.compare-table th,
.compare-table td {
    border-bottom: 1px solid var(--line);
    padding: var(--space-3) var(--space-4);
    text-align: left;
}

/* ============================================================
   Callout / related content
   ============================================================ */

.callout {
    border-left: 2px solid var(--accent);
    padding: var(--space-4) var(--space-6);
    background: var(--paper-raised);
}

.related-content {
    border-top: 1px solid var(--line);
    padding-top: var(--space-6);
    margin-top: var(--space-12);
}

/* ============================================================
   Responsive grid collapse — 12 / 6 / 4 / 2 (Section 9)
   ============================================================ */

@media (max-width: 1024px) {
    .gallery { grid-template-columns: repeat(6, 1fr); }
    .gallery--masonry { column-count: 2; }
}

@media (max-width: 720px) {
    .gallery { grid-template-columns: repeat(2, 1fr); }
    .gallery--masonry { column-count: 2; column-gap: var(--space-4); }
    .hero__content { padding: var(--space-6) var(--space-4); }
}

/* ============================================================
   Mobile/desktop presentation differences — CSS only, never a
   separate server-rendered template. Same markup, same URL,
   same content for crawlers and users alike; only the *arrangement*
   and interaction pattern change. See ARCHITECTURE.md for the
   reasoning (device detection is unreliable, duplicate templates
   are 2x the maintenance, and it works against the SEO goals in
   Section 11).

   Use `order` on a flex/grid container's children to change
   sequence per breakpoint, e.g.:
     .some-section { display: flex; flex-direction: column; }
     .some-section .facts   { order: 1; }
     .some-section .gallery { order: 2; }
     @media (min-width: 721px) {
       .some-section .gallery { order: 1; }
       .some-section .facts   { order: 2; }
     }
   ============================================================ */

/* Gallery as a swipeable strip on touch/narrow viewports, masonry
   grid on pointer/wide ones — one markup, two presentations. */
@media (max-width: 720px), (pointer: coarse) {
    .gallery--masonry {
        display: flex;
        column-count: unset;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        gap: var(--space-4);
        padding-bottom: var(--space-2);
        -webkit-overflow-scrolling: touch;
    }
    .gallery--masonry > * {
        flex: 0 0 85%;
        scroll-snap-align: start;
        margin-bottom: 0;
    }
}

/* ============================================================
   CSS-only lightbox (T5 image detail — Section 14). No JS: the
   trigger is a same-page anchor link, :target shows the overlay,
   and the close link clears the URL fragment. Works with
   JavaScript off, per Section 18.
   ============================================================ */

.lightbox {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 31, 29, 0.92);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
}

.lightbox:target {
    display: flex;
}

.lightbox__panel {
    background: var(--paper-raised);
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 1fr;
}

.lightbox__panel img {
    width: 100%;
    height: auto;
    display: block;
}

.lightbox__meta {
    padding: var(--space-6);
}

.lightbox__close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    color: var(--paper);
    text-decoration: none;
    font-size: 1.5rem;
    line-height: 1;
}

@media (min-width: 721px) {
    .lightbox__panel {
        grid-template-columns: 2fr 1fr;
    }
}
