/* ============================================================
   bada.news — Victorian Telegraph Newsroom
   Palette: Honeyed Neutral
   ============================================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Courier Prime', monospace;
    background-color: #0E0B08;
    color: #D4C4A0;
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Grain overlay */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.06;
    mix-blend-mode: soft-light;
    background-image: 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.7' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

/* Copperplate hatching background texture */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    background: repeating-linear-gradient(
        45deg,
        #2A1F14 0px,
        #2A1F14 1px,
        transparent 1px,
        transparent 8px
    );
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-family: 'Bebas Neue', sans-serif;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #FFF8E7;
    text-shadow: 0 1px 0 #5C4A2D, 0 2px 4px rgba(0,0,0,0.3);
}

/* --- Opening Sequence --- */
.opening-sequence {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: #0E0B08;
    z-index: 10;
    overflow: hidden;
}

.gaslight-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(200,169,110,0.4) 0%, rgba(200,169,110,0.1) 40%, transparent 70%);
    opacity: 0;
    transition: width 1.2s ease-out, height 1.2s ease-out, opacity 0.8s ease-out;
    pointer-events: none;
}

.gaslight-glow.active {
    width: 150vmax;
    height: 150vmax;
    opacity: 1;
}

.opening-content {
    position: relative;
    z-index: 2;
    text-align: center;
}

.logotype {
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.2em;
    color: #FFF8E7;
    text-shadow: 0 2px 0 #5C4A2D, 0 4px 8px rgba(0,0,0,0.4);
    margin-bottom: 1.5rem;
}

.logo-letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.logo-letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.morse-line {
    display: block;
    margin: 0 auto 1.5rem;
    opacity: 0;
    transition: opacity 0.6s ease-out 0.5s;
}

.morse-line.visible {
    opacity: 1;
}

.morse-line line,
.morse-line rect,
.morse-line circle {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
}

.morse-line.animate line,
.morse-line.animate rect,
.morse-line.animate circle {
    animation: morseReveal 2s ease-out forwards;
}

@keyframes morseReveal {
    to { stroke-dashoffset: 0; }
}

.opening-tagline {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 500;
    font-style: italic;
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: #C8A96E;
    letter-spacing: 0.04em;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.opening-tagline.visible {
    opacity: 1;
}

/* --- Header Ribbon --- */
.header-ribbon {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: linear-gradient(to bottom, #A0894D, #8B7355);
    border-bottom: 1px solid #5C4A2D;
    box-shadow: inset 0 1px 0 rgba(255,248,231,0.15), 0 2px 8px rgba(0,0,0,0.4);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.header-ribbon.visible {
    opacity: 1;
    transform: translateY(0);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-logotype {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 28px;
    font-weight: 400;
    letter-spacing: 0.15em;
    color: #FFF8E7;
    text-transform: uppercase;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.telegraph-icon-left,
.telegraph-icon-right {
    display: block;
    opacity: 0.8;
}

/* --- Ticker Bar --- */
.ticker-bar {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    height: 32px;
    background: #1C1410;
    border-bottom: 1px solid #3D2E1A;
    z-index: 999;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-100%);
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
}

.ticker-bar.visible {
    opacity: 1;
    transform: translateY(0);
}

.ticker-track {
    display: flex;
    white-space: nowrap;
    animation: tickerScroll 45s linear infinite;
    height: 100%;
    align-items: center;
}

.ticker-text {
    font-family: 'Courier Prime', monospace;
    font-size: 13px;
    color: #C8A96E;
    letter-spacing: 0.03em;
    padding-right: 2rem;
    flex-shrink: 0;
}

@keyframes tickerScroll {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* --- Parallax Layers --- */
.parallax-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.parallax-layer {
    position: absolute;
    top: -20%;
    left: -10%;
    width: 120%;
    height: 140%;
    will-change: transform;
}

.parallax-map {
    opacity: 0.08;
    background-image:
        radial-gradient(ellipse at 30% 40%, #2A1F14 0%, transparent 60%),
        radial-gradient(ellipse at 70% 60%, #2A1F14 0%, transparent 50%);
    /* World map suggestion through radial gradients */
}

.parallax-map::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 25% 35%, #3D2E1A 2px, transparent 2px),
        radial-gradient(circle at 65% 45%, #3D2E1A 3px, transparent 3px),
        radial-gradient(circle at 45% 55%, #3D2E1A 2px, transparent 2px),
        radial-gradient(circle at 75% 30%, #3D2E1A 1.5px, transparent 1.5px),
        radial-gradient(circle at 35% 65%, #3D2E1A 2px, transparent 2px);
}

.parallax-cables {
    opacity: 0.06;
    background: repeating-linear-gradient(
        -30deg,
        transparent 0px,
        transparent 80px,
        #3D2E1A 80px,
        #3D2E1A 81px
    ),
    repeating-linear-gradient(
        30deg,
        transparent 0px,
        transparent 120px,
        #3D2E1A 120px,
        #3D2E1A 121px
    );
}

.parallax-ornaments {
    opacity: 0.04;
    background:
        linear-gradient(to right, #8B7355 1px, transparent 1px) left top / 100% 1px no-repeat,
        linear-gradient(to right, #8B7355 1px, transparent 1px) left bottom / 100% 1px no-repeat,
        linear-gradient(to bottom, #8B7355 1px, transparent 1px) left top / 1px 100% no-repeat,
        linear-gradient(to bottom, #8B7355 1px, transparent 1px) right top / 1px 100% no-repeat;
}

/* --- Masonry Grid --- */
.masonry-grid {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 120px 20px 60px;
    column-count: 3;
    column-gap: 12px;
}

/* --- Tiles (General) --- */
.tile {
    position: relative;
    break-inside: avoid;
    margin-bottom: 12px;
    padding: 24px;
    background: #1C1410;
    border: 2px solid #8B7355;
    transition: box-shadow 0.3s ease-out;
    overflow: hidden;
}

.tile:hover {
    box-shadow: 0 0 20px rgba(200,169,110,0.15), inset 0 0 12px rgba(200,169,110,0.05);
}

/* Tile corners */
.tile-corner {
    position: absolute;
    z-index: 2;
    transition: transform 0.2s ease-out;
}

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

.tile:hover .tile-corner-tl { transform: rotate(-3deg); }
.tile:hover .tile-corner-tr { transform: rotate(3deg); }
.tile:hover .tile-corner-bl { transform: rotate(3deg); }
.tile:hover .tile-corner-br { transform: rotate(-3deg); }

/* Tile entry animation */
.tile {
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out, box-shadow 0.3s ease-out;
}

.tile.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Tile category label */
.tile-category {
    font-family: 'IM Fell English', serif;
    font-size: 0.8rem;
    font-style: italic;
    color: #8B7355;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #3D2E1A;
}

/* Tile heading */
.tile-heading {
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.2;
    margin-bottom: 16px;
    letter-spacing: 0.08em;
}

/* Tile subheading */
.tile-subheading {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    letter-spacing: 0.04em;
    color: #C8A96E;
    text-transform: none;
    text-shadow: none;
    margin-bottom: 16px;
    line-height: 1.4;
}

/* Tile body */
.tile-body {
    font-family: 'Courier Prime', monospace;
    font-size: clamp(0.9rem, 1.8vw, 1.05rem);
    line-height: 1.75;
    color: #D4C4A0;
    letter-spacing: 0.01em;
}

.tile-body p {
    margin-bottom: 1em;
}

.tile-body p:last-child {
    margin-bottom: 0;
}

/* Drop caps */
.drop-cap {
    float: left;
    font-family: 'IM Fell English', serif;
    font-size: 4.5rem;
    line-height: 0.8;
    color: #C8A96E;
    background: #2A1F14;
    outline: 2px solid #8B7355;
    outline-offset: 4px;
    padding: 4px 12px 4px 8px;
    margin: 4px 12px 0 0;
}

/* Tile divider */
.tile-divider {
    margin: 16px 0 12px;
    opacity: 0.7;
}

/* Tile footer */
.tile-footer {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

/* --- Dispatch Tile --- */
.tile-dispatch {
    background: #1C1410;
}

/* --- Diagram Tile --- */
.tile-diagram {
    background: #FFF8E7;
    border-color: #8B7355;
}

.tile-diagram .tile-category {
    color: #5C4A2D;
    border-bottom-color: #C8A96E;
}

.tile-diagram .tile-subheading {
    color: #3D2E1A;
}

.diagram-illustration {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 16px 0;
    padding: 12px;
}

.diagram-caption {
    font-family: 'IM Fell English', serif;
    font-size: 0.85rem;
    font-style: italic;
    color: #5C4A2D;
    line-height: 1.5;
    margin-top: 8px;
}

/* SVG Draw animation */
.svg-draw {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.tile.visible .svg-draw {
    stroke-dashoffset: 0;
}

/* --- Map Fragment Tile --- */
.tile-map {
    background: #1C1410;
    aspect-ratio: 4 / 3;
    display: flex;
    flex-direction: column;
}

.map-illustration {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.map-svg {
    max-width: 100%;
    height: auto;
}

/* --- Logbook Tile --- */
.tile-logbook {
    background: #1C1410;
    padding: 20px;
}

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

.logbook-line {
    display: grid;
    grid-template-columns: 50px 60px 1fr;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #2A1F14;
    align-items: start;
    font-size: 0.85rem;
}

.logbook-line:last-child {
    border-bottom: none;
}

.logbook-time {
    font-family: 'Courier Prime', monospace;
    color: #C8A96E;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
}

.logbook-morse {
    font-family: 'Courier Prime', monospace;
    color: #8B7355;
    font-size: 0.75rem;
    letter-spacing: 0.15em;
    white-space: nowrap;
}

.logbook-entry {
    font-family: 'Courier Prime', monospace;
    color: #D4C4A0;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* --- Instrument Tile --- */
.tile-instrument {
    background: #1C1410;
    text-align: center;
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 0;
}

.gauge {
    position: relative;
    width: 160px;
    height: 160px;
}

.gauge-bezel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(135deg, #A0894D 0%, #8B7355 40%, #5C4A2D 100%);
    padding: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,248,231,0.2);
}

.gauge-face {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(
        from 220deg,
        #2A1F14 0deg,
        #3D2E1A 60deg,
        #5C4A2D 120deg,
        #3D2E1A 200deg,
        #2A1F14 280deg
    );
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.4);
    overflow: hidden;
}

/* Glass reflection effect */
.gauge-face::after {
    content: '';
    position: absolute;
    top: 8%;
    left: 15%;
    width: 45%;
    height: 30%;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255,248,231,0.12) 0%, transparent 100%);
    pointer-events: none;
}

/* Gauge markings */
.gauge-marking {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 10px;
    background: #C8A96E;
    transform-origin: center -55px;
    margin-left: -1px;
    margin-top: -65px;
}

.gauge-marking-1 { transform: rotate(-60deg); }
.gauge-marking-2 { transform: rotate(-40deg); }
.gauge-marking-3 { transform: rotate(-20deg); }
.gauge-marking-4 { transform: rotate(0deg); }
.gauge-marking-5 { transform: rotate(20deg); }
.gauge-marking-6 { transform: rotate(40deg); }
.gauge-marking-7 { transform: rotate(60deg); }
.gauge-marking-8 { transform: rotate(80deg); height: 6px; width: 1px; }
.gauge-marking-9 { transform: rotate(100deg); height: 6px; width: 1px; }

.gauge-label-min {
    position: absolute;
    bottom: 28%;
    left: 18%;
    font-family: 'IM Fell English', serif;
    font-size: 0.6rem;
    color: #8B7355;
    font-style: italic;
}

.gauge-label-max {
    position: absolute;
    bottom: 28%;
    right: 15%;
    font-family: 'IM Fell English', serif;
    font-size: 0.6rem;
    color: #8B7355;
    font-style: italic;
}

.gauge-label-unit {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'IM Fell English', serif;
    font-size: 0.65rem;
    color: #C8A96E;
    font-style: italic;
}

.gauge-needle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 50px;
    background: linear-gradient(to top, #B87333, #C8A96E);
    transform-origin: bottom center;
    transform: translate(-50%, -100%) rotate(-60deg);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    border-radius: 1px 1px 0 0;
    z-index: 2;
}

.gauge-needle.animated {
    /* Target rotation set by JS */
}

.gauge-center-cap {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C8A96E, #8B7355);
    transform: translate(-50%, -50%);
    z-index: 3;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

.gauge-reading {
    font-family: 'Courier Prime', monospace;
    font-size: 0.85rem;
    color: #D4C4A0;
    margin-top: 12px;
}

.gauge-reading strong {
    color: #C8A96E;
}

/* --- Telegraph Tape Footer --- */
.telegraph-footer {
    position: relative;
    z-index: 1;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0E0B08;
    padding: 60px 20px;
}

.telegraph-tape {
    width: 100%;
    max-width: 900px;
    background: #FFF8E7;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.tape-perforations {
    display: flex;
    justify-content: space-between;
    padding: 0 12px;
    height: 12px;
    align-items: center;
}

.tape-perforations-top {
    border-bottom: 1px solid #D4C4A0;
}

.tape-perforations-bottom {
    border-top: 1px solid #D4C4A0;
}

.perforation {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0E0B08;
    flex-shrink: 0;
}

.tape-text {
    font-family: 'Courier Prime', monospace;
    font-size: 14px;
    color: #1C1410;
    padding: 10px 16px;
    min-height: 28px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Dimming effect for end */
.telegraph-footer.dimming {
    transition: opacity 3s ease-out;
    opacity: 0;
}

/* --- Links / Interactive --- */
a {
    color: #4A7C6B;
    text-decoration: none;
    border-bottom: 1px solid rgba(74,124,107,0.4);
    transition: color 0.2s, border-color 0.2s;
}

a:hover {
    color: #5a9c84;
    border-bottom-color: #5a9c84;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .masonry-grid {
        column-count: 2;
        padding-top: 110px;
    }
}

@media (max-width: 640px) {
    .masonry-grid {
        column-count: 1;
        padding-top: 100px;
    }

    .logotype {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .header-ribbon {
        height: 48px;
    }

    .header-logotype {
        font-size: 22px;
    }

    .ticker-bar {
        top: 48px;
    }

    .tile {
        padding: 16px;
    }

    .gauge {
        width: 130px;
        height: 130px;
    }

    .logbook-line {
        grid-template-columns: 45px 50px 1fr;
        font-size: 0.8rem;
    }

    .drop-cap {
        font-size: 3.5rem;
    }

    .tile-map {
        aspect-ratio: auto;
    }
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #1C1410;
}

::-webkit-scrollbar-thumb {
    background: #5C4A2D;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8B7355;
}

/* --- Selection --- */
::selection {
    background: rgba(200,169,110,0.3);
    color: #FFF8E7;
}