/* ============================================
   ringworld.quest — Styles
   Earth-tone Swiss Grid + Classical Glitch Art
   ============================================ */

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

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.125rem);
    line-height: 1.65;
    color: #3B2F2F;
    background-color: #FAF0E6;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Noise (hidden) --- */
.noise-svg {
    position: absolute;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* --- Scan-line Overlay --- */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(59, 47, 47, 0.03) 1px,
        rgba(59, 47, 47, 0.03) 2px
    );
    pointer-events: none;
    z-index: 9998;
}

/* --- Noise Texture Overlay --- */
.noise-overlay {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    filter: url(#noiseFilter);
    opacity: 0.03;
    pointer-events: none;
    z-index: 9997;
}

/* --- Fixed Top Bar --- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 80px;
    background: rgba(250, 240, 230, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    transition: box-shadow 0.3s ease;
}

.top-bar.scrolled {
    box-shadow: 0 1px 3px rgba(30, 17, 8, 0.1);
}

.top-bar-title {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3B2F2F;
}

.top-bar-line {
    width: 100%;
    height: 1px;
    background: #3B2F2F;
    margin-top: 4px;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1E1108;
    overflow: hidden;
}

.hero-scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 1px,
        rgba(59, 47, 47, 0.05) 1px,
        rgba(59, 47, 47, 0.05) 2px
    );
    pointer-events: none;
    z-index: 3;
}

.hero-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50vmin;
    height: 50vmin;
    border: 2px solid #C2A878;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ringPulse 8s ease-in-out infinite;
    z-index: 1;
    opacity: 0.6;
}

@keyframes ringPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1.0); }
    50% { transform: translate(-50%, -50%) scale(1.02); }
}

.hero-content {
    position: relative;
    text-align: center;
    z-index: 2;
    max-width: 900px;
    padding: 0 24px;
}

/* --- Glitch Text Effect --- */
.glitch-text {
    position: relative;
    display: inline-block;
}

.glitch-text::before,
.glitch-text::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch-text::before {
    color: #C67B4B;
    opacity: 0.6;
    mix-blend-mode: multiply;
    animation: glitchShift1 3s ease-in-out infinite;
}

.glitch-text::after {
    color: #4A7C6F;
    opacity: 0.5;
    mix-blend-mode: screen;
    animation: glitchShift2 3s ease-in-out infinite;
}

@keyframes glitchShift1 {
    0%, 90%, 100% { transform: translate(0, 0); }
    92% { transform: translate(-2px, 1px); }
    94% { transform: translate(0, 0); }
    96% { transform: translate(-1px, 0); }
    98% { transform: translate(0, 0); }
}

@keyframes glitchShift2 {
    0%, 90%, 100% { transform: translate(0, 0); }
    91% { transform: translate(1px, -1px); }
    93% { transform: translate(0, 0); }
    95% { transform: translate(1px, 0); }
    97% { transform: translate(0, 0); }
}

.hero-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(2.5rem, 6vw, 5rem);
    letter-spacing: 0.04em;
    color: #FAF0E6;
    margin-bottom: 24px;
    text-transform: none;
}

.hero-rule {
    width: 120px;
    height: 1px;
    border: none;
    background: #C2A878;
    margin: 0 auto 20px;
}

.hero-subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: #C2A878;
    letter-spacing: 0.02em;
}

/* --- Grid Container --- */
.grid-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 80px;
}

/* --- Segment Divider --- */
.segment-divider {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 64px 0 40px;
}

.segment-rule {
    flex: 1;
    height: 1px;
    border: none;
    background: #3B2F2F;
}

.segment-number {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5C4033;
    white-space: nowrap;
    overflow: hidden;
    display: inline-block;
}

.segment-number.typed {
    border-right: 2px solid #5C4033;
    animation: blinkCursor 0.6s step-end infinite;
    width: 0;
}

.segment-number.typed.done {
    border-right-color: transparent;
    animation: none;
}

@keyframes blinkCursor {
    50% { border-right-color: transparent; }
}

/* --- Card Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding-bottom: 24px;
}

/* --- Sector Card --- */
.sector-card {
    background: #E8DCC8;
    border: 2px solid #5C4033;
    border-radius: 0;
    padding: 28px 24px;
    aspect-ratio: 1 / 1.2;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s ease;
    opacity: 0;
    transform: translateY(40px);
}

.sector-card.visible {
    animation: bounceEnter 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes bounceEnter {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.sector-card:hover {
    border-color: #C2A878;
}

.sector-card:hover .card-content-wrapper {
    animation: glitchJitter 0.2s linear;
}

@keyframes glitchJitter {
    0% { transform: translateX(0); }
    10% { transform: translateX(3px); }
    20% { transform: translateX(-2px); }
    30% { transform: translateX(4px); }
    40% { transform: translateX(-3px); }
    50% { transform: translateX(2px); }
    60% { transform: translateX(-4px); }
    70% { transform: translateX(3px); }
    80% { transform: translateX(-2px); }
    90% { transform: translateX(1px); }
    100% { transform: translateX(0); }
}

/* Hover glitch on the whole card */
.sector-card.glitching {
    animation: cardGlitch 0.2s linear;
}

@keyframes cardGlitch {
    0% { transform: translateX(0) translateY(0); }
    10% { transform: translateX(3px) translateY(0); }
    20% { transform: translateX(-2px) translateY(0); }
    30% { transform: translateX(4px) translateY(0); }
    40% { transform: translateX(-3px) translateY(0); }
    50% { transform: translateX(2px) translateY(0); }
    60% { transform: translateX(-4px) translateY(0); }
    70% { transform: translateX(3px) translateY(0); }
    80% { transform: translateX(-2px) translateY(0); }
    90% { transform: translateX(1px) translateY(0); }
    100% { transform: translateX(0) translateY(0); }
}

.sector-card.visible.glitching {
    opacity: 1;
}

/* --- Card Label --- */
.card-label {
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #5C4033;
    margin-bottom: 16px;
}

/* --- Card Pattern --- */
.card-pattern {
    width: 100%;
    height: 80px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

/* Concentric circles */
.pattern-concentric {
    background: repeating-radial-gradient(
        circle at center,
        transparent 0px,
        transparent 8px,
        #5C4033 8px,
        #5C4033 9px
    );
    opacity: 0.3;
}

/* Horizontal lines */
.pattern-lines {
    background: repeating-linear-gradient(
        to bottom,
        transparent 0px,
        transparent 6px,
        #5C4033 6px,
        #5C4033 7px
    );
    opacity: 0.3;
}

/* Greek key approximation */
.pattern-key {
    background:
        repeating-linear-gradient(
            90deg,
            #5C4033 0px,
            #5C4033 2px,
            transparent 2px,
            transparent 12px
        ),
        repeating-linear-gradient(
            0deg,
            #5C4033 0px,
            #5C4033 2px,
            transparent 2px,
            transparent 12px
        );
    opacity: 0.25;
}

/* Dot pattern */
.pattern-dots {
    background: radial-gradient(circle, #5C4033 1.5px, transparent 1.5px);
    background-size: 12px 12px;
    opacity: 0.3;
}

/* Cross pattern */
.pattern-cross {
    background:
        linear-gradient(#5C4033 1px, transparent 1px),
        linear-gradient(90deg, #5C4033 1px, transparent 1px);
    background-size: 16px 16px;
    background-position: center center;
    opacity: 0.2;
}

/* Spiral approximation */
.pattern-spiral {
    background:
        repeating-radial-gradient(
            circle at 30% 50%,
            transparent 0px,
            transparent 10px,
            #5C4033 10px,
            #5C4033 11px
        ),
        repeating-radial-gradient(
            circle at 70% 50%,
            transparent 0px,
            transparent 10px,
            #C67B4B 10px,
            #C67B4B 11px
        );
    opacity: 0.25;
}

/* Wave pattern */
.pattern-waves {
    background:
        repeating-linear-gradient(
            45deg,
            transparent 0px,
            transparent 4px,
            #5C4033 4px,
            #5C4033 5px
        ),
        repeating-linear-gradient(
            -45deg,
            transparent 0px,
            transparent 4px,
            #4A7C6F 4px,
            #4A7C6F 5px
        );
    opacity: 0.2;
}

/* Grid pattern */
.pattern-grid {
    background:
        linear-gradient(#5C4033 2px, transparent 2px),
        linear-gradient(90deg, #5C4033 2px, transparent 2px),
        linear-gradient(#C2A878 1px, transparent 1px),
        linear-gradient(90deg, #C2A878 1px, transparent 1px);
    background-size: 40px 40px, 40px 40px, 10px 10px, 10px 10px;
    opacity: 0.2;
}

/* Chevron pattern */
.pattern-chevron {
    background:
        linear-gradient(135deg, #5C4033 25%, transparent 25%),
        linear-gradient(225deg, #5C4033 25%, transparent 25%),
        linear-gradient(315deg, #5C4033 25%, transparent 25%),
        linear-gradient(45deg, #5C4033 25%, transparent 25%);
    background-size: 20px 20px;
    background-position: 0 0, 10px 0, 10px -10px, 0 10px;
    opacity: 0.15;
}

/* Radial pattern */
.pattern-radial {
    background: repeating-conic-gradient(
        from 0deg,
        #5C4033 0deg 10deg,
        transparent 10deg 20deg
    );
    opacity: 0.15;
}

/* --- Card Title --- */
.card-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    letter-spacing: 0.04em;
    color: #3B2F2F;
    margin-bottom: 12px;
    text-transform: none;
}

/* --- Card Body --- */
.card-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.875rem, 1vw, 1rem);
    line-height: 1.65;
    color: #3B2F2F;
    flex: 1;
}

/* --- Card Ornament --- */
.card-ornament {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    color: #C2A878;
    text-align: center;
    letter-spacing: 0.5em;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(92, 64, 51, 0.2);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .grid-container {
        padding: 0 48px;
    }

    .top-bar {
        padding: 0 48px;
    }

    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

@media (max-width: 640px) {
    .grid-container {
        padding: 0 24px;
    }

    .top-bar {
        padding: 0 24px;
    }

    .card-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .segment-divider {
        padding: 48px 0 28px;
    }

    .sector-card {
        aspect-ratio: auto;
        padding: 24px 20px;
    }
}

/* --- Links (Verdigris) --- */
a {
    color: #4A7C6F;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #C2A878;
}

/* --- Decorative Greek Key Border (for special cards) --- */
.greek-key-border {
    border-image: repeating-linear-gradient(
        90deg,
        #5C4033 0px,
        #5C4033 8px,
        transparent 8px,
        transparent 12px,
        #5C4033 12px,
        #5C4033 14px,
        transparent 14px,
        transparent 18px
    ) 2;
}

/* --- Selection --- */
::selection {
    background: #C2A878;
    color: #1E1108;
}
