/* reasr.one - Honeycomb Terminal */
/* Colors: Charred Walnut #1c1814, Smoked Umber #2a231c, Aged Brass #8b7355, 
   Parchment Glow #e8dcc8, Tarnished Gold #b09a7a, Amber Signal #d4a54a, 
   Warm Ember #e8712a, Oxidized Verdigris #5a8a72 */

:root {
    --bg-primary: #1c1814;
    --bg-secondary: #2a231c;
    --aged-brass: #8b7355;
    --parchment: #e8dcc8;
    --tarnished-gold: #b09a7a;
    --amber-signal: #d4a54a;
    --warm-ember: #e8712a;
    --verdigris: #5a8a72;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-primary);
    color: var(--parchment);
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
}

body {
    opacity: 0;
    animation: bodyFadeIn 2s ease-out 0.5s forwards;
}

@keyframes bodyFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.svg-filters {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Amber Dot - materialization */
#amber-dot {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--amber-signal);
    transform: translate(-50%, -50%);
    box-shadow: 0 0 30px rgba(212,165,74,0.4), 0 0 60px rgba(212,165,74,0.2);
    z-index: 100;
    animation: amberDotPulse 0.5s ease-out forwards, amberDotFade 1s ease-out 1.5s forwards;
}

@keyframes amberDotPulse {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes amberDotFade {
    to { opacity: 0; }
}

/* Scan Line */
#scan-line {
    position: fixed;
    top: -2px;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(212,165,74,0.3) 20%, rgba(212,165,74,0.3) 80%, transparent 100%);
    z-index: 50;
    opacity: 0;
    animation: scanLineMove 8s linear 3.5s infinite;
}

@keyframes scanLineMove {
    0% { top: -2px; opacity: 0; }
    2% { opacity: 1; }
    98% { opacity: 1; }
    100% { top: 100vh; opacity: 0; }
}

/* Radial fade mask */
#radial-mask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(28,24,20,0.4) 60%, rgba(28,24,20,0.85) 100%);
}

/* Honeycomb Container */
#honeycomb {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hexagonal Cell */
.hex-cell {
    position: absolute;
    clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
    background: var(--bg-secondary);
    cursor: pointer;
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), opacity 0.6s ease;
    transform-style: preserve-3d;
    perspective: 800px;
    overflow: hidden;
}

.hex-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise-texture);
    pointer-events: none;
    z-index: 1;
}

/* Nucleus */
.hex-cell.nucleus {
    width: clamp(280px, 38vw, 420px);
    height: clamp(243px, 33vw, 364px);
    z-index: 10;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    animation: nucleusFadeIn 1s ease-out 1.5s forwards;
}

@keyframes nucleusFadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.hex-cell.nucleus .hex-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.hex-cell.nucleus .hex-border-svg {
    width: 100%;
    height: 100%;
}

/* Ring hexagons */
.hex-cell.ring {
    width: clamp(160px, 22vw, 240px);
    height: clamp(139px, 19vw, 208px);
    z-index: 5;
    opacity: 0;
}

.hex-cell.ring[data-index="1"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.0s forwards;
}
.hex-cell.ring[data-index="2"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.1s forwards;
}
.hex-cell.ring[data-index="3"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.2s forwards;
}
.hex-cell.ring[data-index="4"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.3s forwards;
}
.hex-cell.ring[data-index="5"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.4s forwards;
}
.hex-cell.ring[data-index="6"] {
    animation: ringFadeIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) 2.5s forwards;
}

@keyframes ringFadeIn {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}

/* Periphery hexagons */
.hex-cell.periphery {
    width: clamp(80px, 12vw, 140px);
    height: clamp(69px, 10.4vw, 121px);
    z-index: 2;
    opacity: 0;
    animation: peripheryFadeIn 0.8s ease-out 3s forwards;
}

@keyframes peripheryFadeIn {
    from { opacity: 0; }
    to { opacity: 0.4; }
}

/* Hex border SVG */
.hex-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

.hex-border-svg {
    width: 100%;
    height: 100%;
    filter: url(#roughen);
}

.hex-outline-outer {
    fill: none;
    stroke: var(--aged-brass);
    stroke-width: 1;
}

.hex-outline-inner {
    fill: none;
    stroke: var(--amber-signal);
    stroke-width: 0.5;
    opacity: 0.6;
}

.hex-node {
    fill: var(--amber-signal);
    opacity: 0.8;
    filter: drop-shadow(0 0 4px rgba(212,165,74,0.6));
}

.hex-cell.nucleus .hex-outline-outer {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawHexBorder 1s ease-out 0.8s forwards;
}

.hex-cell.nucleus .hex-outline-inner {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawHexBorder 1s ease-out 1s forwards;
}

.hex-cell.nucleus .hex-node {
    opacity: 0;
    animation: nodeAppear 0.3s ease-out forwards;
}

.hex-cell.nucleus .hex-node:nth-child(3) { animation-delay: 0.5s; }
.hex-cell.nucleus .hex-node:nth-child(4) { animation-delay: 0.6s; }
.hex-cell.nucleus .hex-node:nth-child(5) { animation-delay: 0.7s; }
.hex-cell.nucleus .hex-node:nth-child(6) { animation-delay: 0.8s; }
.hex-cell.nucleus .hex-node:nth-child(7) { animation-delay: 0.9s; }
.hex-cell.nucleus .hex-node:nth-child(8) { animation-delay: 1.0s; }

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

@keyframes nodeAppear {
    from { opacity: 0; r: 0; }
    to { opacity: 0.8; }
}

/* Hex Content */
.hex-content {
    position: relative;
    z-index: 3;
    padding: clamp(16px, 3vw, 32px);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hex-title {
    font-family: 'Poiret One', 'Trebuchet MS', sans-serif;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--parchment);
    filter: url(#roughen);
    margin-bottom: 0.5em;
}

.hex-cell.nucleus .hex-title {
    font-size: clamp(2.2rem, 5vw, 4.5rem);
    text-shadow: 0 0 20px rgba(212,165,74,0.15);
}

.hex-cell.ring .hex-title {
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
}

.hex-body {
    font-family: 'Libre Baskerville', Georgia, serif;
    font-size: clamp(0.7rem, 1vw, 0.9rem);
    line-height: 1.6;
    color: var(--parchment);
    opacity: 0.85;
    max-width: 90%;
}

.hex-cell.ring .hex-body {
    font-size: clamp(0.6rem, 0.85vw, 0.78rem);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* HUD Data readouts */
.hex-hud-data {
    position: absolute;
    font-family: 'Poiret One', monospace;
    font-size: 10px;
    color: var(--tarnished-gold);
    opacity: 0.5;
    letter-spacing: 0.08em;
    z-index: 4;
}

.hex-hud-data.top-left { top: 18%; left: 18%; }
.hex-hud-data.top-right { top: 18%; right: 18%; }
.hex-hud-data.bottom-left { bottom: 18%; left: 18%; }
.hex-hud-data.bottom-right { bottom: 18%; right: 18%; }

/* Star Charts */
.star-chart {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
    opacity: 0.35;
}

.star-line {
    stroke: var(--aged-brass);
    stroke-width: 0.5;
    fill: none;
    opacity: 0.6;
}

.star-node {
    fill: var(--amber-signal);
    opacity: 0.5;
    animation: starPulse 5s ease-in-out infinite;
}

.star-node:nth-child(odd) { animation-delay: -1.2s; }
.star-node:nth-child(3n) { animation-delay: -2.8s; }
.star-node:nth-child(4n) { animation-delay: -4s; }

@keyframes starPulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* Gauge Arcs */
.gauge-arc {
    position: absolute;
    bottom: 8%;
    right: 8%;
    width: 50px;
    height: 50px;
    z-index: 3;
    pointer-events: none;
    opacity: 0.4;
}

.gauge-small {
    width: 35px;
    height: 35px;
}

.gauge-circle {
    fill: none;
    stroke: var(--aged-brass);
    stroke-width: 1;
    stroke-dasharray: 180 100;
    animation: gaugeRotate 30s linear infinite;
    transform-origin: center;
}

@keyframes gaugeRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Hover effects */
.hex-cell.ring:hover {
    z-index: 15;
    filter: brightness(1.1);
}

.hex-cell.ring:hover .hex-outline-outer {
    stroke: var(--amber-signal);
    transition: stroke 0.3s ease;
}

.hex-cell.ring:hover .hex-node {
    fill: var(--warm-ember);
    transition: fill 0.3s ease;
}

.hex-cell.nucleus:hover .hex-outline-outer {
    stroke: var(--amber-signal);
    filter: drop-shadow(0 0 8px rgba(212,165,74,0.3));
    transition: all 0.3s ease;
}

/* Active state - when a ring hex is promoted to nucleus */
.hex-cell.ring.active {
    z-index: 20;
    transition: transform 0.8s cubic-bezier(0.19, 1, 0.22, 1), 
                width 0.8s cubic-bezier(0.19, 1, 0.22, 1),
                height 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Tilt 3D hover effect class (applied by JS) */
.hex-cell.tilting {
    transition: none;
}

/* Ambient noise texture on background */
body::after {
    content: '';
    position: fixed;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.03;
    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='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
    animation: noiseDrift 60s linear infinite;
}

@keyframes noiseDrift {
    from { transform: translate(0, 0); }
    to { transform: translate(-20px, -15px); }
}

/* HUD pulse animation on nucleus border */
.hex-cell.nucleus .hex-outline-inner {
    animation: drawHexBorder 1s ease-out 1s forwards, hudPulse 4s ease-in-out 3s infinite;
}

@keyframes hudPulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Links in verdigris */
a {
    color: var(--verdigris);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

/* Data readout update animation */
.hex-hud-data.updating {
    animation: dataFlicker 0.2s steps(2) 3;
}

@keyframes dataFlicker {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 0.1; }
}

/* Mobile layout */
@media (max-width: 640px) {
    #honeycomb {
        flex-direction: column;
        overflow-y: auto;
        padding: 20px 0;
        align-items: center;
        justify-content: flex-start;
    }

    .hex-cell {
        position: relative;
        margin: -15px auto;
    }

    .hex-cell.nucleus {
        position: relative;
        left: auto;
        top: auto;
        transform: none;
        width: 85vw;
        height: calc(85vw * 0.866);
        animation: nucleusFadeInMobile 1s ease-out 1.5s forwards;
    }

    @keyframes nucleusFadeInMobile {
        from { opacity: 0; transform: scale(0.8); }
        to { opacity: 1; transform: scale(1); }
    }

    .hex-cell.ring {
        position: relative;
        width: 70vw;
        height: calc(70vw * 0.866);
    }

    .hex-cell.periphery {
        display: none;
    }

    #radial-mask {
        display: none;
    }
}

/* Scan line acceleration during transitions */
#scan-line.accelerated {
    animation-duration: 0.5s;
}
