/* =============================================================
   CCATTL.com — Cosmic Cattle Auxiliary Tracking & Telemetry League
   Colors: #E63946 Pop Red / #00B4A6 HUD Teal / #1A1A1A Ink Black
           #F2E8D5 Foxed Paper / #D4C5A3 Aged Manila / #FFFFFF Bubble White
   Fonts:  Cormorant Garamond (display) / EB Garamond (body/labels)
   ============================================================= */

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

:root {
    --pop-red:       #E63946;
    --hud-teal:      #00B4A6;
    --ink-black:     #1A1A1A;
    --foxed-paper:   #F2E8D5;
    --aged-manila:   #D4C5A3;
    --bubble-white:  #FFFFFF;
    --coffee-brown:  #8B6F47;
    --bezel-size:    24px;
    --bezel-sm:      12px;
}

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--foxed-paper);
    color: var(--ink-black);
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 19px;
    line-height: 1.65;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ── Paper Texture & Aging ────────────────────────────────── */
#paper-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

#noise-layer {
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    opacity: 0.06;
    mix-blend-mode: multiply;
    pointer-events: none;
}

/* Coffee ring stains at fixed coordinates */
.coffee-ring {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: multiply;
}

#ring-1 {
    width: 320px;
    height: 320px;
    top: 15vh;
    left: -60px;
    background: radial-gradient(circle at center,
        transparent 40%,
        rgba(139, 111, 71, 0.04) 50%,
        rgba(139, 111, 71, 0.06) 55%,
        rgba(139, 111, 71, 0.03) 62%,
        transparent 70%);
}

#ring-2 {
    width: 260px;
    height: 260px;
    top: 55vh;
    right: 8vw;
    background: radial-gradient(circle at center,
        transparent 38%,
        rgba(139, 111, 71, 0.04) 48%,
        rgba(139, 111, 71, 0.06) 54%,
        rgba(139, 111, 71, 0.03) 60%,
        transparent 68%);
}

#ring-3 {
    width: 200px;
    height: 200px;
    top: 80vh;
    left: 30vw;
    background: radial-gradient(circle at center,
        transparent 35%,
        rgba(139, 111, 71, 0.03) 46%,
        rgba(139, 111, 71, 0.05) 52%,
        rgba(139, 111, 71, 0.02) 58%,
        transparent 66%);
}

/* Vignette */
#vignette {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center,
        transparent 60%,
        rgba(26, 26, 26, 0.08) 100%);
    pointer-events: none;
    z-index: 1;
}

/* ── HUD Bezel Frame ──────────────────────────────────────── */
#hud-bezel {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
}

.bezel-corner {
    position: absolute;
    width: 40px;
    height: 40px;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.bezel-corner.active {
    opacity: 1;
}

.corner-tl { top: 8px; left: 8px; }
.corner-tr { top: 8px; right: 8px; }
.corner-bl { bottom: 8px; left: 8px; }
.corner-br { bottom: 8px; right: 8px; }

#bezel-readout {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--aged-manila);
    border-bottom: 2px solid var(--hud-teal);
    border-left: 2px solid var(--hud-teal);
    border-right: 2px solid var(--hud-teal);
    padding: 4px 24px 6px;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.08em;
    color: var(--hud-teal);
    text-shadow: 0 0 8px rgba(0, 180, 166, 0.4);
    cursor: pointer;
    pointer-events: all;
    white-space: nowrap;
    min-width: 340px;
    text-align: center;
}

#bezel-readout:hover {
    background-color: var(--hud-teal);
    color: var(--foxed-paper);
    text-shadow: none;
}

.readout-sep {
    color: var(--aged-manila);
    opacity: 0.6;
}

#bezel-readout:hover .readout-sep {
    color: var(--foxed-paper);
}

/* ── Halftone Patterns ────────────────────────────────────── */
.halftone-zone {
    background-image: radial-gradient(circle, var(--ink-black) 1px, transparent 1.5px);
    background-size: 8px 8px;
    opacity: 0.05;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.headline-halftone {
    opacity: 0.07;
    background-size: 4px 4px;
    inset: unset;
    top: 0;
    left: 0;
    width: 45%;
    height: 55%;
}

.halftone-dark {
    background-image: radial-gradient(circle, var(--foxed-paper) 1px, transparent 1.5px);
    background-size: 4px 4px;
    opacity: 0.08;
}

/* ── Main Content & Panels ────────────────────────────────── */
#main-content {
    position: relative;
    z-index: 10;
    padding-top: var(--bezel-size);
    padding-bottom: var(--bezel-size);
}

.panel {
    position: relative;
    min-height: 100vh;
    padding: 6vh 8vw;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 0;
    overflow: hidden;
    border-bottom: 1px solid var(--aged-manila);
}

.panel-dark {
    background-color: var(--ink-black);
    color: var(--foxed-paper);
    border-bottom: 1px solid rgba(212, 197, 163, 0.2);
}

/* ── Z-Pattern Zones ──────────────────────────────────────── */
.z-upper-left {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    padding: 40px 0 30px 0;
    align-self: start;
}

.z-upper-right {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 40px 0 30px 0;
    align-self: start;
}

.z-diagonal {
    grid-column: 1 / 3;
    grid-row: 2;
    height: 100px;
    position: relative;
    overflow: visible;
}

.diag-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.z-lower-left {
    grid-column: 1;
    grid-row: 3;
    padding: 20px 0 40px 0;
    max-width: 560px;
}

.z-lower-right {
    grid-column: 2;
    grid-row: 3;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 20px 0 40px 0;
}

/* ── Panel Labels ─────────────────────────────────────────── */
.panel-label {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 13px;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.12em;
    color: var(--ink-black);
    opacity: 0.55;
    text-transform: uppercase;
    margin-bottom: 12px;
}

.panel-label-dark {
    color: var(--aged-manila);
    opacity: 0.7;
}

/* ── Display Headlines ────────────────────────────────────── */
.display-headline {
    position: relative;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 700;
    font-size: clamp(52px, 7vw, 96px);
    line-height: 0.95;
    text-transform: uppercase;
    letter-spacing: -0.01em;
    display: block;
}

.headline-ghost,
.headline-main {
    display: block;
}

/* Ghost layer — teal offset for screen-print misregistration */
.headline-ghost {
    color: var(--hud-teal);
    position: absolute;
    top: 0;
    left: 3px;
    pointer-events: none;
    z-index: 1;
    opacity: 0.85;
}

/* Main red layer sits on top */
.headline-main {
    color: var(--pop-red);
    position: relative;
    z-index: 2;
    text-shadow:
        3px 0 0 rgba(0, 180, 166, 0.35),
        -1px 0 0 rgba(0, 180, 166, 0.15);
}

/* Dark panel overrides */
.headline-dark .headline-main.headline-main-dark {
    color: var(--foxed-paper);
    text-shadow: 3px 0 0 rgba(0, 180, 166, 0.4);
}

.headline-dark .headline-ghost.headline-ghost-dark {
    color: var(--hud-teal);
    opacity: 0.7;
}

/* ── Reticle Frames ───────────────────────────────────────── */
.reticle-frame {
    position: relative;
    width: 200px;
    height: 200px;
    border: 1px solid var(--hud-teal);
    background-color: rgba(242, 232, 213, 0.4);
    padding: 0;
    backdrop-filter: blur(0px);
}

.reticle-dark {
    background-color: rgba(26, 26, 26, 0.8);
    border-color: var(--hud-teal);
}

.reticle-svg {
    width: 100%;
    height: 100%;
    display: block;
}

.reticle-label {
    position: absolute;
    bottom: -22px;
    left: 0;
    right: 0;
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 10px;
    font-weight: 600;
    font-style: italic;
    letter-spacing: 0.1em;
    color: var(--hud-teal);
    text-align: center;
    text-transform: uppercase;
    white-space: nowrap;
}

.reticle-label-dark {
    color: var(--hud-teal);
}

/* ── Body Copy ────────────────────────────────────────────── */
.body-copy {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 19px;
    line-height: 1.65;
    text-align: justify;
    hanging-punctuation: first last;
    color: var(--ink-black);
    position: relative;
}

.body-copy-dark {
    color: var(--foxed-paper);
}

.body-copy-secondary {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 18px;
    line-height: 1.65;
    text-align: justify;
    color: var(--ink-black);
    opacity: 0.8;
    margin-top: 16px;
}

.body-copy-dark-secondary {
    color: var(--foxed-paper);
    opacity: 0.75;
}

/* Drop-cap */
.drop-cap {
    float: left;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 5em;
    font-weight: 700;
    line-height: 0.75;
    color: var(--pop-red);
    margin-right: 8px;
    margin-top: 4px;
    margin-bottom: -8px;
}

.drop-cap-dark {
    color: var(--hud-teal);
}

/* ── Speech Bubbles ───────────────────────────────────────── */
.speech-bubble {
    position: relative;
    width: 240px;
    display: inline-block;
    transform: rotate(-4deg);
    transform-origin: center bottom;
    transition: transform 0.2s ease;
}

.speech-bubble:hover {
    transform: rotate(0deg);
}

.bubble-svg {
    width: 100%;
    height: auto;
    display: block;
}

.bubble-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 18px;
    font-weight: 700;
    font-style: italic;
    color: var(--ink-black);
    text-align: center;
    width: 85%;
    line-height: 1.2;
    pointer-events: none;
}

.bubble-text-dark {
    color: var(--foxed-paper);
}

#bubble-2 { transform: rotate(5deg); }
#bubble-3 { transform: rotate(-6deg); }
#bubble-4 { transform: rotate(3deg); }
#bubble-5 { transform: rotate(-5deg); }

#bubble-2:hover,
#bubble-3:hover,
#bubble-4:hover,
#bubble-5:hover {
    transform: rotate(0deg);
}

.speech-bubble-dark .bubble-svg path {
    fill: var(--ink-black);
    stroke: var(--foxed-paper);
}

/* ── Listening Post Input ─────────────────────────────────── */
.listening-post-input {
    margin-top: 28px;
}

.hud-bracket-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.input-bracket {
    flex-shrink: 0;
    opacity: 0.8;
}

.typewriter-input {
    flex: 1;
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--ink-black);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.06em;
    color: var(--ink-black);
    padding: 6px 8px;
    outline: none;
    text-transform: uppercase;
}

.typewriter-input::placeholder {
    color: var(--aged-manila);
    font-style: italic;
    font-size: 13px;
    letter-spacing: 0.04em;
}

.typewriter-input:focus {
    border-bottom-color: var(--pop-red);
}

.marker-btn {
    display: block;
    background: transparent;
    border: 2px solid var(--pop-red);
    color: var(--pop-red);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 8px 24px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background-color 0.2s, color 0.2s;
}

.marker-btn:hover {
    background: var(--pop-red);
    color: var(--foxed-paper);
}

/* ── Marker Confirmation ──────────────────────────────────── */
#marker-confirm {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--hud-teal);
    color: var(--foxed-paper);
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 14px;
    letter-spacing: 0.1em;
    padding: 12px 32px;
    border: 2px solid var(--foxed-paper);
    z-index: 200;
    text-align: center;
    transition: opacity 0.4s;
}

#marker-confirm.hidden {
    display: none;
}

.confirm-label {
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.2em;
    opacity: 0.8;
    margin-bottom: 4px;
}

.confirm-code {
    font-size: 15px;
    font-weight: 500;
}

/* ── Footer ───────────────────────────────────────────────── */
#site-footer {
    grid-column: 1 / 3;
    padding: 24px 0 8px;
    border-top: 1px solid var(--aged-manila);
    margin-top: 24px;
}

.footer-inner {
    font-family: 'EB Garamond', Georgia, serif;
    font-size: 13px;
    font-style: italic;
    color: var(--aged-manila);
    letter-spacing: 0.06em;
    text-align: center;
}

.footer-brand {
    font-weight: 700;
    font-style: normal;
    font-family: 'Cormorant Garamond', Georgia, serif;
    color: var(--ink-black);
    font-size: 15px;
    letter-spacing: 0.1em;
}

.footer-sep {
    opacity: 0.5;
}

/* ── Pulse-Attention Animation ────────────────────────────── */
@keyframes pulse-idle {
    0%   { transform: scale(1)    brightness(1); }
    50%  { transform: scale(1.04) brightness(1.08); }
    100% { transform: scale(1)    brightness(1); }
}

@keyframes pulse-idle-bubble {
    0%   { filter: brightness(1); }
    50%  { filter: brightness(1.06); }
    100% { filter: brightness(1); }
}

@keyframes pulse-readout {
    0%   { box-shadow: 0 0 0px rgba(0, 180, 166, 0); }
    50%  { box-shadow: 0 0 12px rgba(0, 180, 166, 0.35); }
    100% { box-shadow: 0 0 0px rgba(0, 180, 166, 0); }
}

@keyframes radio-pulse-a {
    0%   { r: 20; opacity: 0.8; }
    50%  { r: 28; opacity: 0.4; }
    100% { r: 20; opacity: 0.8; }
}
@keyframes radio-pulse-b {
    0%   { r: 35; opacity: 0.5; }
    50%  { r: 43; opacity: 0.2; }
    100% { r: 35; opacity: 0.5; }
}
@keyframes radio-pulse-c {
    0%   { r: 50; opacity: 0.3; }
    50%  { r: 58; opacity: 0.1; }
    100% { r: 50; opacity: 0.3; }
}

.radio-ring.ring-a { animation: radio-pulse-a 2s ease-in-out infinite; }
.radio-ring.ring-b { animation: radio-pulse-b 2s ease-in-out infinite 0.4s; }
.radio-ring.ring-c { animation: radio-pulse-c 2s ease-in-out infinite 0.8s; }

.pulse-element {
    animation: pulse-idle-bubble 4s ease-in-out infinite;
}

.pulse-element:hover {
    animation: pulse-idle-bubble 1s ease-in-out infinite;
    filter: hue-rotate(10deg) brightness(1.1);
}

#bezel-readout {
    animation: pulse-readout 4s ease-in-out infinite;
}

/* ── Tick-march animation for Z-rules ─────────────────────── */
@keyframes tick-march {
    0%   { stroke-dashoffset: 20; }
    100% { stroke-dashoffset: 0; }
}

/* ── Reticle scroll-rotation (applied via JS) ─────────────── */
.range-ring {
    transform-origin: 100px 100px;
    transform-box: fill-box;
    transition: transform 0.1s linear;
}

/* ── Cow glyphs on charts ─────────────────────────────────── */
.cow-glyph {
    font-style: normal;
}

/* ── Responsive (< 720px) ─────────────────────────────────── */
@media (max-width: 720px) {
    :root {
        --bezel-size: var(--bezel-sm);
    }

    .panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto auto;
        padding: 4vh 6vw;
    }

    .z-upper-left  { grid-column: 1; grid-row: 1; }
    .z-upper-right {
        grid-column: 1;
        grid-row: 2;
        align-items: center;
        justify-content: center;
        padding: 20px 0;
    }
    .z-diagonal    { grid-column: 1; grid-row: 3; }
    .z-lower-left  { grid-column: 1; grid-row: 4; max-width: 100%; }
    .z-lower-right { grid-column: 1; grid-row: 5; justify-content: center; padding: 20px 0; }

    #site-footer   { grid-column: 1; }

    .display-headline {
        font-size: clamp(38px, 10vw, 64px);
    }

    .reticle-frame {
        width: 35vw;
        height: 35vw;
        max-width: 200px;
        max-height: 200px;
    }

    #bezel-readout {
        font-size: 11px;
        min-width: 0;
        padding: 4px 12px 5px;
    }

    .speech-bubble {
        width: 200px;
    }
}

/* ── Panel entry animations ───────────────────────────────── */
.panel {
    opacity: 1;
}

.z-upper-left,
.z-upper-right,
.z-lower-left,
.z-lower-right {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.panel.in-view .z-upper-left  { opacity: 1; transform: translateY(0); transition-delay: 0.05s; }
.panel.in-view .z-upper-right { opacity: 1; transform: translateY(0); transition-delay: 0.15s; }
.panel.in-view .z-lower-left  { opacity: 1; transform: translateY(0); transition-delay: 0.35s; }
.panel.in-view .z-lower-right { opacity: 1; transform: translateY(0); transition-delay: 0.45s; }

/* Make sure panel 1 elements show on load after bezel animation */
#panel-1 .z-upper-left,
#panel-1 .z-upper-right,
#panel-1 .z-lower-left,
#panel-1 .z-lower-right {
    transition-delay: 0s;
}
