/* =============================================
   layer-2.wiki — Skeuomorphic Coastal Atlas
   Hexagonal Knowledge Atlas Styles
   ============================================= */

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

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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.2vw, 1.1rem);
    line-height: 1.8;
    color: #3A3A3A;
    background-color: #F2EAD8;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* -- Chart-Paper Grid Background -- */
#chart-grid {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 200ms ease;
    background-image:
        linear-gradient(#D4C8B8 1px, transparent 1px),
        linear-gradient(90deg, #D4C8B8 1px, transparent 1px);
    background-size: 40px 40px;
}

#chart-grid.visible {
    opacity: 0.08;
}

/* -- Hex Tessellation Decoration -- */
.hex-tessellation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 1.5s ease 1.8s;
}

.hex-tessellation.visible {
    opacity: 1;
}

.hex-tessellation .hex-frag {
    position: absolute;
    border: 1px solid #D4C8B8;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0.04;
}

/* -- Typography -- */
h1, h2, h3, h4 {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0.5, 'MONO' 0;
    color: #2A3A4A;
    font-weight: 700;
}

h1 {
    font-size: clamp(2.4rem, 5vw, 4rem);
    letter-spacing: 0.15em;
    line-height: 1.1;
}

h3 {
    font-size: clamp(0.85rem, 1.4vw, 1.05rem);
    letter-spacing: 0.04em;
    line-height: 1.3;
}

/* -- Utility Label Styles -- */
.coord-label {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 0.7rem;
    color: #7A9BAE;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.section-title-label {
    font-family: 'Overpass Mono', monospace;
    font-weight: 400;
    font-size: 0.7rem;
    color: #7A9BAE;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: 1rem;
}

/* -- Hero Section -- */
#hero {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 2rem;
    overflow: hidden;
}

.hero-content {
    text-align: center;
    max-width: 700px;
    position: relative;
    z-index: 2;
}

.hero-label {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 0.65rem;
    color: #7A9BAE;
    letter-spacing: 0.25em;
    text-transform: uppercase;
    margin-bottom: 1.5rem;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.hero-label.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-title {
    color: #2A3A4A;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease 0.3s, transform 0.8s ease 0.3s;
}

.hero-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.hero-underline {
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, #B8964A, transparent);
    margin: 0.8rem auto 1.5rem;
    transition: width 1.2s ease 0.8s;
}

.hero-underline.visible {
    width: 220px;
}

.hero-subtitle {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 300;
    font-size: clamp(0.95rem, 1.2vw, 1.15rem);
    color: #3A3A3A;
    line-height: 1.8;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s ease 1.2s, transform 0.8s ease 1.2s;
}

.hero-subtitle.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Hero hex decorations */
.hero-hex-decoration {
    position: absolute;
    width: 120px;
    height: 120px;
    border: 1px solid #D4C8B8;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    opacity: 0;
    transition: opacity 1.5s ease 1.5s;
}

.hero-hex-decoration.visible {
    opacity: 0.15;
}

.hero-hex-1 {
    top: 10%;
    right: 8%;
    transform: rotate(15deg);
}

.hero-hex-2 {
    bottom: 15%;
    left: 5%;
    width: 80px;
    height: 80px;
    transform: rotate(-10deg);
}

.hero-hex-3 {
    top: 25%;
    left: 12%;
    width: 60px;
    height: 60px;
    transform: rotate(30deg);
}

.hero-hex-4 {
    bottom: 20%;
    right: 15%;
    width: 50px;
    height: 50px;
    border-color: #B8964A;
    transform: rotate(-20deg);
}

/* -- Section Labels -- */
.section-label {
    display: flex;
    align-items: center;
    margin: 3rem 0 2rem;
    padding: 0 2rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.scale-bar {
    flex: 1;
    height: 1px;
    background: #D4C8B8;
    margin-left: 1.5rem;
    position: relative;
}

.scale-bar::before {
    content: '';
    position: absolute;
    left: 0;
    top: -2px;
    width: 5px;
    height: 5px;
    background: #D4C8B8;
    border-radius: 50%;
}

.scale-bar::after {
    content: '';
    position: absolute;
    right: 0;
    top: -3px;
    width: 7px;
    height: 7px;
    border-right: 1px solid #D4C8B8;
    border-top: 1px solid #D4C8B8;
    transform: rotate(45deg);
}

/* -- Honeycomb Grid -- */
#honeycomb-section {
    position: relative;
    z-index: 1;
    padding: 0 1rem 4rem;
}

.honeycomb-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem 0.8rem;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Offset odd rows for honeycomb effect */
.hex-cell[data-row="1"],
.hex-cell[data-row="3"] {
    transform: translateX(calc(50% / 4 + 0.4rem));
}

/* -- Hexagonal Cell -- */
.hex-cell {
    position: relative;
    aspect-ratio: 1 / 0.866;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background: rgba(242, 234, 216, 0.85);
    overflow: hidden;
}

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(184, 150, 74, 0.06) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 0;
}

.hex-cell:hover::before {
    opacity: 1;
}

.hex-cell:hover {
    transform: translateY(-3px);
    z-index: 5;
}

.hex-cell[data-row="1"]:hover,
.hex-cell[data-row="3"]:hover {
    transform: translateX(calc(50% / 4 + 0.4rem)) translateY(-3px);
}

.hex-border {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
}

.hex-path {
    fill: none;
    stroke: #7A9BAE;
    stroke-width: 3;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke 0.3s ease;
}

.hex-cell.animate .hex-path {
    animation: drawHex 0.4s ease forwards;
}

.hex-cell:hover .hex-path {
    stroke: #B8964A;
}

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

.hex-content {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20% 12%;
    text-align: center;
    z-index: 2;
}

.hex-icon {
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.85;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.hex-cell:hover .hex-icon {
    opacity: 1;
    transform: scale(1.1);
}

.hex-content h3 {
    font-size: clamp(0.72rem, 1.2vw, 0.95rem);
    margin-bottom: 0.25rem;
    color: #2A3A4A;
    transition: color 0.3s ease;
}

.hex-cell:hover .hex-content h3 {
    color: #B8964A;
}

.hex-meta {
    font-family: 'Overpass Mono', monospace;
    font-size: 0.6rem;
    color: #7A9BAE;
    letter-spacing: 0.02em;
    line-height: 1.4;
}

/* -- Article Overlay -- */
.article-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 55%;
    max-width: 700px;
    height: 100vh;
    background: #F2EAD8;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: -4px 0 40px rgba(42, 58, 74, 0.15);
}

.article-overlay.open {
    transform: translateX(0);
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #D4C8B8;
    position: sticky;
    top: 0;
    background: #F2EAD8;
    z-index: 10;
}

.overlay-label {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.overlay-topic-label {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0.5;
    font-size: 1.1rem;
    color: #2A3A4A;
    font-weight: 700;
}

.overlay-close {
    background: none;
    border: 1px solid #D4C8B8;
    color: #2A3A4A;
    cursor: pointer;
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.overlay-close:hover {
    border-color: #C45A4A;
    color: #C45A4A;
}

.overlay-body {
    padding: 2rem;
}

.overlay-body h2 {
    font-size: clamp(1.4rem, 2.5vw, 1.8rem);
    margin-bottom: 1rem;
    color: #2A3A4A;
    position: relative;
    padding-bottom: 0.8rem;
}

.overlay-body h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 2px;
    background: #B8964A;
}

.overlay-body p {
    margin-bottom: 1rem;
    color: #3A3A3A;
    font-weight: 400;
}

.overlay-body .article-section {
    margin-bottom: 2rem;
}

.overlay-body .article-section h4 {
    font-family: 'Overpass Mono', monospace;
    font-weight: 700;
    font-size: 0.75rem;
    color: #7A9BAE;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 0.6rem;
}

.overlay-body .key-stat {
    display: inline-block;
    font-family: 'Overpass Mono', monospace;
    font-size: 0.75rem;
    color: #2A6A6A;
    background: rgba(42, 106, 106, 0.08);
    padding: 0.2rem 0.6rem;
    margin: 0.2rem 0.3rem 0.2rem 0;
    border-left: 2px solid #2A6A6A;
}

.overlay-body .marker {
    color: #C45A4A;
    font-weight: 600;
}

.overlay-edge {
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(
        180deg,
        #D4C8B8 0%,
        #B8964A 20%,
        #D4C8B8 40%,
        #B8964A 60%,
        #D4C8B8 80%,
        #B8964A 100%
    );
    opacity: 0.4;
}

/* Overlay backdrop */
.overlay-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(42, 58, 74, 0.3);
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* -- Compass Rose -- */
.compass-rose {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 500;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.8s ease, transform 0.8s ease;
    cursor: pointer;
}

.compass-rose.visible {
    opacity: 1;
    transform: scale(1);
}

.compass-rose:hover {
    transform: scale(1.08);
}

.compass-ring {
    animation: compassPulse 4s ease-in-out infinite;
}

@keyframes compassPulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

.compass-needle {
    transform-origin: 60px 60px;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* -- Chart Annotations -- */
.chart-annotation {
    position: fixed;
    font-family: 'Overpass Mono', monospace;
    font-size: 0.55rem;
    color: #D4C8B8;
    letter-spacing: 0.1em;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease 2s;
}

.chart-annotation.visible {
    opacity: 0.5;
}

.annotation-1 {
    top: 15%;
    left: 1.5rem;
    writing-mode: vertical-lr;
}

.annotation-2 {
    top: 55%;
    right: 1.5rem;
    writing-mode: vertical-lr;
}

.annotation-3 {
    bottom: 8%;
    left: 1.5rem;
}

.annotation-4 {
    bottom: 12%;
    right: 10rem;
    font-size: 0.5rem;
    color: #B8964A;
    opacity: 0;
    transition: opacity 1s ease 2.5s;
}

.annotation-4.visible {
    opacity: 0.3;
}

/* -- Footer -- */
#footer {
    position: relative;
    z-index: 1;
    padding: 2rem;
    margin-top: 4rem;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 0;
}

.footer-border {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    height: 1px;
    background: linear-gradient(90deg, transparent, #D4C8B8, transparent);
    position: absolute;
    top: 2rem;
    left: 50%;
    transform: translateX(-50%);
}

.footer-left,
.footer-right {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.footer-label {
    font-family: 'Recursive', sans-serif;
    font-variation-settings: 'CASL' 0.5;
    font-weight: 700;
    font-size: 0.85rem;
    color: #2A3A4A;
    letter-spacing: 0.1em;
}

.footer-meta {
    font-family: 'Overpass Mono', monospace;
    font-size: 0.6rem;
    color: #7A9BAE;
    letter-spacing: 0.06em;
}

.footer-coord,
.footer-date {
    font-family: 'Overpass Mono', monospace;
    font-size: 0.6rem;
    color: #7A9BAE;
    letter-spacing: 0.06em;
    text-align: right;
}

.footer-compass {
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.footer-compass:hover {
    opacity: 1;
}

/* -- Responsive -- */
@media (max-width: 900px) {
    .honeycomb-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem 0.5rem;
    }

    .hex-cell[data-row="1"],
    .hex-cell[data-row="3"] {
        transform: translateX(calc(50% / 2 + 0.25rem));
    }

    .hex-cell[data-row="1"]:hover,
    .hex-cell[data-row="3"]:hover {
        transform: translateX(calc(50% / 2 + 0.25rem)) translateY(-3px);
    }

    .article-overlay {
        width: 85%;
    }

    .compass-rose {
        bottom: 1rem;
        right: 1rem;
    }

    .compass-rose svg {
        width: 80px;
        height: 80px;
    }

    .chart-annotation {
        display: none;
    }
}

@media (max-width: 600px) {
    .honeycomb-grid {
        grid-template-columns: 1fr;
        gap: 0.8rem;
        max-width: 280px;
    }

    .hex-cell[data-row="1"],
    .hex-cell[data-row="3"] {
        transform: none;
    }

    .hex-cell[data-row="1"]:hover,
    .hex-cell[data-row="3"]:hover {
        transform: translateY(-3px);
    }

    .article-overlay {
        width: 100%;
        max-width: 100%;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-right {
        align-items: center;
    }

    .hero-title {
        font-size: clamp(1.8rem, 8vw, 2.8rem);
    }

    .section-label {
        padding: 0 1rem;
    }

    .compass-rose {
        bottom: 0.5rem;
        right: 0.5rem;
    }

    .compass-rose svg {
        width: 60px;
        height: 60px;
    }

    .hero-hex-decoration {
        display: none;
    }
}
