/* ==========================================================================
   a6c.quest — Retro-Industrial Dashboard Broadsheet
   ========================================================================== */

/* CSS Custom Properties */
:root {
    --bg-primary: #f4ece0;
    --bg-alt: #ede3d3;
    --bg-highlight: #e8dcc8;
    --bg-marble: #d8c8b0;
    --text-primary: #2c1e10;
    --text-secondary: #5c4a3a;
    --accent-primary: #b8860b;
    --accent-warm: #a0522d;
    --border-rule: #7a6a5a;
    --highlight-alert: #8b0000;
    --dark-rule: #3d2e1f;
    --light-rule: #a8937e;
    --font-headline: 'Roboto Slab', serif;
    --font-body: 'Source Serif 4', Georgia, serif;
    --font-accent: 'Space Mono', monospace;
}

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

/* Body & Paper Texture */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: clamp(1rem, 1.1vw, 1.15rem);
    line-height: 1.72;
    position: relative;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Paper grain overlay via SVG */
.paper-grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 0.5;
}

/* ==========================================================================
   MASTHEAD
   ========================================================================== */

.masthead {
    position: relative;
    padding: 40px 0 0 0;
    margin-bottom: 0;
}

.masthead-inner {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    align-items: baseline;
}

.masthead-title {
    grid-column: 2 / 6;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3.6rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.masthead-title.visible {
    opacity: 1;
}

.masthead-date {
    grid-column: 9 / 12;
    font-family: var(--font-accent);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-align: right;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.masthead-date.visible {
    opacity: 1;
}

.masthead-rule {
    display: block;
    width: 100%;
    max-width: 1200px;
    height: 2px;
    margin: 20px auto 0;
    overflow: visible;
}

.masthead-rule line {
    stroke-dasharray: 1200;
    stroke-dashoffset: 1200;
    transition: none;
}

.masthead-rule.animated line {
    animation: draw-line 1.2s ease-out forwards;
}

@keyframes draw-line {
    to {
        stroke-dashoffset: 0;
    }
}

/* Marble veining on masthead area */
.masthead::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 50%, var(--bg-alt) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 30%, var(--bg-highlight) 0%, transparent 40%),
        radial-gradient(ellipse at 50% 80%, var(--bg-marble) 0%, transparent 60%);
    background-blend-mode: multiply;
    transform: skewY(-1deg);
    opacity: 0.4;
    z-index: -1;
    pointer-events: none;
}

/* ==========================================================================
   SPINE RULE (Left gutter vertical line)
   ========================================================================== */

.spine-rule {
    position: fixed;
    top: 0;
    left: calc((100vw - 1200px) / 2 + 80px);
    width: 1px;
    height: 100vh;
    background-color: var(--text-secondary);
    z-index: 10;
    pointer-events: none;
}

@media (max-width: 1240px) {
    .spine-rule {
        left: 80px;
    }
}

/* ==========================================================================
   CONTENT GRID
   ========================================================================== */

.content-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Dateline Bar */
.dateline-bar {
    width: 100%;
    height: 24px;
    background-color: var(--bg-highlight);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 40px 0 24px;
    position: relative;
}

.dateline-bar span {
    font-family: var(--font-headline);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    color: var(--text-secondary);
}

/* Double rule motif before dateline */
.dateline-bar::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--dark-rule);
}

.dateline-bar::after {
    content: '';
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--light-rule);
}

/* Chapter Grid */
.chapter {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    padding: 16px 0;
}

/* ==========================================================================
   TILES
   ========================================================================== */

.tile {
    background-color: var(--bg-primary);
    border: 2px solid var(--border-rule);
    padding: 20px;
    position: relative;
    box-shadow: inset 0 0 4px rgba(44, 30, 16, 0.06), 0 2px 4px rgba(44, 30, 16, 0.08);
    transition:
        transform 280ms ease-out,
        border-color 280ms ease-out,
        box-shadow 280ms ease-out;
    cursor: default;
}

.tile:hover {
    transform: translateY(-6px);
    border-color: var(--accent-primary);
    box-shadow: inset 0 0 4px rgba(44, 30, 16, 0.06), 0 8px 24px rgba(44, 30, 16, 0.15);
    transition:
        transform 280ms ease-out,
        border-color 280ms ease-out,
        box-shadow 280ms ease-out;
}

/* Hover-out: slower return */
.tile:not(:hover) {
    transition:
        transform 360ms ease-in-out,
        border-color 360ms ease-in-out,
        box-shadow 360ms ease-in-out;
}

/* Tile Header */
.tile-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.tile-icon {
    flex-shrink: 0;
}

.tile-label {
    font-family: var(--font-accent);
    font-size: 12px;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.tile-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: clamp(1.6rem, 4vw, 3.2rem);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.15;
}

/* Scale down tile titles within tiles */
.tile .tile-title {
    font-size: clamp(1.1rem, 2vw, 1.6rem);
}

.tile-body {
    font-family: var(--font-body);
    font-size: clamp(0.95rem, 1.1vw, 1.1rem);
    line-height: 1.72;
    color: var(--text-primary);
}

/* Corner Ornaments */
.tile-corner {
    position: absolute;
    opacity: 0.6;
    line-height: 0;
}

.tile-corner.tl { top: 4px; left: 4px; }
.tile-corner.tr { top: 4px; right: 4px; transform: scaleX(-1); }
.tile-corner.bl { bottom: 4px; left: 4px; transform: scaleY(-1); }
.tile-corner.br { bottom: 4px; right: 4px; transform: scale(-1, -1); }

/* Drop Cap */
.drop-cap {
    float: left;
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 4.5em;
    line-height: 0.8;
    margin-right: 8px;
    margin-top: 4px;
    color: var(--highlight-alert);
}

/* ==========================================================================
   CHAPTER 1 — Tile placement
   ========================================================================== */

.chapter-1 .tile:nth-child(1) {
    grid-column: 2 / 8;
}
.chapter-1 .tile:nth-child(2) {
    grid-column: 8 / 12;
}
.chapter-1 .tile:nth-child(3) {
    grid-column: 2 / 5;
}
.chapter-1 .tile:nth-child(4) {
    grid-column: 5 / 9;
}
.chapter-1 .tile:nth-child(5) {
    grid-column: 9 / 12;
}

/* ==========================================================================
   CHAPTER 2 — Different tile arrangement
   ========================================================================== */

.chapter-2 .tile:nth-child(1) {
    grid-column: 2 / 6;
}
.chapter-2 .tile:nth-child(2) {
    grid-column: 6 / 12;
}
.chapter-2 .tile:nth-child(3) {
    grid-column: 2 / 8;
}
.chapter-2 .tile:nth-child(4) {
    grid-column: 8 / 12;
}

/* ==========================================================================
   CHAPTER 3 — Another unique arrangement
   ========================================================================== */

.chapter-3 .tile:nth-child(1) {
    grid-column: 2 / 5;
}
.chapter-3 .tile:nth-child(2) {
    grid-column: 5 / 9;
}
.chapter-3 .tile:nth-child(3) {
    grid-column: 9 / 12;
}
.chapter-3 .tile:nth-child(4) {
    grid-column: 2 / 8;
}
.chapter-3 .tile:nth-child(5) {
    grid-column: 8 / 12;
}

/* ==========================================================================
   CHAPTER 4 — Final arrangement
   ========================================================================== */

.chapter-4 .tile:nth-child(1) {
    grid-column: 2 / 6;
}
.chapter-4 .tile:nth-child(2) {
    grid-column: 6 / 12;
}
.chapter-4 .tile:nth-child(3) {
    grid-column: 2 / 6;
}
.chapter-4 .tile:nth-child(4) {
    grid-column: 6 / 9;
}
.chapter-4 .tile:nth-child(5) {
    grid-column: 9 / 12;
}

/* ==========================================================================
   BUST DIVIDER
   ========================================================================== */

.bust-divider {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 0 40px;
}

.bust-silhouette {
    filter: contrast(0.8) brightness(1.1);
    opacity: 0.7;
}

/* ==========================================================================
   DOUBLE RULE
   ========================================================================== */

.double-rule {
    position: relative;
    height: 8px;
    margin: 0 0 0;
}

.double-rule::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--dark-rule);
}

.double-rule::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--light-rule);
}

/* ==========================================================================
   COLOPHON / FOOTER
   ========================================================================== */

.colophon {
    background-color: var(--text-primary);
    color: var(--bg-alt);
    padding: 60px 20px;
    text-align: center;
}

.colophon-inner {
    max-width: 600px;
    margin: 0 auto;
}

.colophon-title {
    font-family: var(--font-headline);
    font-weight: 700;
    font-size: 1.4rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
    color: var(--bg-alt);
}

.colophon-year {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--border-rule);
    margin-bottom: 16px;
}

.colophon-statement {
    font-family: var(--font-accent);
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--border-rule);
    line-height: 1.6;
}

/* ==========================================================================
   MOBILE ADAPTATION
   ========================================================================== */

@media (max-width: 768px) {
    .spine-rule {
        display: none;
    }

    .masthead-inner {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .masthead-title {
        text-align: left;
    }

    .masthead-date {
        text-align: left;
    }

    .chapter {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .tile {
        border: none;
        border-top: 1px solid var(--text-secondary);
        padding: 24px 16px;
    }

    .tile:nth-child(odd) {
        background-color: var(--bg-primary);
    }

    .tile:nth-child(even) {
        background-color: var(--bg-alt);
    }

    .tile:hover {
        transform: none;
        box-shadow: inset 0 0 4px rgba(44, 30, 16, 0.06);
    }

    .tile-corner {
        display: none;
    }

    .dateline-bar {
        margin: 24px 0 16px;
    }

    .content-grid {
        padding: 0 16px;
    }

    .bust-divider {
        padding: 40px 0 24px;
    }

    .bust-silhouette {
        width: 80px;
        height: auto;
    }

    .drop-cap {
        font-size: 3em;
    }
}

/* Medium screens */
@media (min-width: 769px) and (max-width: 1024px) {
    .chapter {
        grid-template-columns: repeat(10, 1fr);
    }

    .chapter .tile {
        grid-column: 1 / -1 !important;
    }

    /* Override to make 2-column on tablet */
    .chapter .tile:nth-child(odd) {
        grid-column: 1 / 6 !important;
    }

    .chapter .tile:nth-child(even) {
        grid-column: 6 / 11 !important;
    }

    .spine-rule {
        left: 40px;
    }
}

/* ==========================================================================
   SELECTION STYLES
   ========================================================================== */

::selection {
    background-color: var(--accent-primary);
    color: var(--bg-primary);
}

/* ==========================================================================
   LINKS (if any)
   ========================================================================== */

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 200ms ease;
}

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

/* ==========================================================================
   SCROLLBAR (subtle customization)
   ========================================================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-alt);
}

::-webkit-scrollbar-thumb {
    background-color: var(--border-rule);
    border-radius: 0;
}
