/* ==========================================================================
   1. CUSTOM PROPERTIES
   ========================================================================== */

:root {
    --offset-cyan: 0px;
    --offset-magenta: 0px;
    --offset-yellow: 0px;

    /* Midpoint defaults — JS overwrites these on load/resize via halftone.js */
    --dot-spacing-cyan:    11px;
    --dot-spacing-magenta: 11px;
    --dot-spacing-yellow:  11px;

    --stroke-width: clamp(1.5px, 0.37vw, 3px);
}

/* ==========================================================================
   2. GLOBAL / RESET
   ========================================================================== */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    background: #f9f4eb;
    color: #1c1c1c;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.7;
    font-size: 1.1rem;
    position: relative;
    overflow-x: hidden;
}

/* Retro Ben-Day dots halftone overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 25% 25%, #000 1px, transparent 1px),
        radial-gradient(circle at 75% 75%, #000 1px, transparent 1px);
    background-size: 28px 28px;
    pointer-events: none;
    opacity: 0.035;
    z-index: -1;
    mix-blend-mode: multiply;
}

/* ==========================================================================
   3. LAYOUT
   ========================================================================== */

.container {
    max-width: 860px;
    margin: 0 auto;
    min-height: 200dvh;
}

.challenge {
    margin-left: 20px;
    margin-right: 20px;
    min-height: 50vh;
}

.challenge:empty {
    min-height: 0;
}

#trophy-container {
    display: flex;
    height: 100%;
    align-items: stretch;
    flex-wrap: wrap;
}

#trophy {
    flex: 1 0 300px;
    position: relative;
    min-height: 300px;
}

#trophy-owner {
    flex: 1 0 300px;
}

/* ==========================================================================
   4. HERO & HALFTONE TEXT LAYERS
   ========================================================================== */

.hero {
    position: relative;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin-bottom: 4rem;
    overflow: visible;
}

.layers-container {
    position: relative;
    width: 100%;
    max-width: 1150px;
    padding: 0 3rem;
}

.text-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(3rem, 9.5vw, 7.8rem);
    font-weight: 900;
    line-height: 0.85;
    text-transform: uppercase;
    letter-spacing: -0.06em;
    margin: 0;
    white-space: nowrap;
    pointer-events: none;
    user-select: none;
    z-index: 1;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    background-repeat: repeat;
}

#black-layer {
    z-index: 10;
    color: transparent;
    -webkit-text-stroke: var(--stroke-width) #1c1c1c;
    text-stroke: var(--stroke-width) #1c1c1c;
    background-image: none;
    background: none;
    paint-order: stroke fill;
}

#cyan-layer {
    mix-blend-mode: multiply;
    transform: translate(-50%, -50%) translateY(var(--offset-cyan));
    z-index: 2;
    background-size: var(--dot-spacing-cyan) var(--dot-spacing-cyan);
}

#magenta-layer {
    mix-blend-mode: multiply;
    transform: translate(-50%, -50%) translateY(var(--offset-magenta));
    z-index: 3;
    background-size: var(--dot-spacing-magenta) var(--dot-spacing-magenta);
}

#yellow-layer {
    mix-blend-mode: multiply;
    transform: translate(-50%, -50%) translateY(var(--offset-yellow));
    z-index: 4;
    background-size: var(--dot-spacing-yellow) var(--dot-spacing-yellow);
}

/* ==========================================================================
   5. TYPOGRAPHY & LINKS
   ========================================================================== */

h2 {
    font-weight: 900;
    font-size: 2.4rem;
    margin-top: 3rem;
}

p {
    max-width: 68ch;
}

a {
    color: #0066cc;
    text-decoration: underline;
    font-weight: 600;
}

a:hover {
    color: #ff0088;
}

/* ==========================================================================
   6. COMPONENTS
   ========================================================================== */

.comic-panel {
    border: 12px solid #1c1c1c;
    padding: 1.5rem;
    background: white;
    box-shadow: 8px 8px 0 #000;
    margin: 3rem 0;
}

img {
    max-width: 100%;
    height: auto;
}

.caption {
    font-size: 0.95rem;
    text-align: center;
    margin-top: 0.8rem;
    font-style: italic;
    color: #444;
}

footer {
    text-align: center;
    padding: 4rem 0 2rem;
    font-size: 0.95rem;
    opacity: 0.7;
}

#countdown {
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   ARCHIVE ACCORDION
   ========================================================================== */

#archive-section {
    min-height: auto;
}

.archive-row {
    border-bottom: 1px solid #ddd;
}

.archive-row:first-of-type {
    border-top: 1px solid #ddd;
}

.archive-row summary {
    display: grid;
    grid-template-columns: 1.2em 5.5em auto 1fr auto;
    gap: 0 1rem;
    align-items: baseline;
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    list-style: none;
    font-size: 1rem;
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.archive-row summary::-webkit-details-marker {
    display: none;
}

.archive-row summary:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.archive-row summary::before {
    content: '▸';
    flex-shrink: 0;
    transition: transform 0.2s ease;
    font-size: 0.85em;
}

.archive-row[open] summary::before {
    transform: rotate(90deg);
}

.archive-date {
    font-weight: 700;
}

.archive-winner {
    font-weight: 600;
}

.archive-prize {
    color: #444;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.archive-score {
    color: #666;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.archive-no-winner {
    grid-column: 3 / -1;
    color: #888;
    font-style: italic;
}

/* Animated accordion content */
.archive-content {
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.archive-content-inner {
    padding: 0.5rem 0 1.5rem 2rem;
}

/* ==========================================================================
   ACTIVE CHALLENGE — side-by-side layout (text + evidence)
   ========================================================================== */

.active-challenge-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.active-challenge-text {
    flex: 1 1 0;
    min-width: 0;
}

.active-challenge-evidence {
    flex: 0 0 40%;
    max-width: 400px;
}

.active-challenge-evidence img,
.active-challenge-evidence iframe,
.active-challenge-evidence blockquote {
    width: 100%;
    height: auto;
    border-radius: 6px;
}

/* ==========================================================================
   SUBMISSION ROWS (live challenge)
   ========================================================================== */

.submission-row summary {
    grid-template-columns: 1.2em auto 1fr auto;
}

/* ==========================================================================
   7. UTILITIES
   ========================================================================== */

.halftone-mask {
    visibility: hidden;
}

.trophy-img {
    height: 95%;
    position: absolute;
    bottom: 0;
    left: 0;
}

.embed-borderless {
    border: 0;
}

.embed-rounded {
    border-radius: 10px;
}

.embed-rounded-full {
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
}

.footer-img {
    height: 20vh;
}

/* ==========================================================================
   8. RESPONSIVE
   ========================================================================== */

@media (max-width: 640px) {
    .layers-container {
        padding: 0 1.5rem;
    }
    .text-layer {
        font-size: clamp(2.6rem, 10vw, 5.5rem);
    }
    .archive-row summary {
        grid-template-columns: 1.2em 5em 1fr;
        gap: 0.2rem 0.5rem;
    }
    .archive-prize,
    .archive-score {
        grid-column: 3;
        font-size: 0.9em;
    }
    .archive-no-winner {
        grid-column: 3 / -1;
    }
    .submission-row summary {
        grid-template-columns: 1.2em 1fr;
        gap: 0.2rem 0.5rem;
    }
    .submission-row .archive-prize,
    .submission-row .archive-score {
        grid-column: 2;
    }
    .active-challenge-layout {
        flex-direction: column;
    }
    .active-challenge-evidence {
        flex: none;
        max-width: 100%;
        width: 100%;
    }
}
