/* ============================================================
   MMIDDL.com v2 — Cartographic Median
   Colors: Survey Ink #2C3E50, Verdigris Copper #2E8B7B,
           Parchment Cream #F5F0E8, Datum Red #C0392B,
           Cartouche Gold #D4A960, Bathymetric Blue #1A5276,
           Contour Shadow #7F8C8D, Vellum White #FDFCFA
   Fonts: Overpass (display), Source Serif 4 (body), Inconsolata (data)
   ============================================================ */

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

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

body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    line-height: 1.72;
    color: #2C3E50;
    background-color: #FDFCFA;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   ISOMETRIC GRID OVERLAY
   ============================================================ */
.iso-grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 1;
    opacity: 0.04;
    transition: opacity 0.6s ease;
}

body:hover .iso-grid-overlay {
    opacity: 0.07;
}

/* ============================================================
   OPENING SURVEY (HERO)
   ============================================================ */
.opening-survey {
    position: relative;
    width: 100%;
    height: 100vh;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #FDFCFA;
    overflow: hidden;
    z-index: 2;
}

.hero-contours {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.hero-grid {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.hero-grid.is-drawn {
    opacity: 1;
}

/* Compass rose */
.compass-rose {
    position: relative;
    z-index: 3;
}

.compass-rose--large {
    width: 200px;
    height: 200px;
    margin-bottom: 1.5rem;
    opacity: 0;
    transition: opacity 1s ease 0.8s;
}

.compass-rose--large.is-visible {
    opacity: 1;
}

.compass-rose--medium {
    width: 80px;
    height: 80px;
    margin-bottom: 1rem;
}

.compass-svg {
    width: 100%;
    height: 100%;
}

.compass-label {
    font-family: 'Inconsolata', monospace;
    font-size: 8px;
    fill: #2C3E50;
    font-weight: 400;
    letter-spacing: 0.04em;
}

.compass-needle {
    transform-origin: center;
}

/* Hero logotype */
.hero-logotype {
    position: relative;
    z-index: 4;
    font-family: 'Overpass', sans-serif;
    font-weight: 700;
    font-size: clamp(32px, 5vw, 72px);
    letter-spacing: 0.04em;
    color: #2C3E50;
    text-transform: uppercase;
    line-height: 1;
    margin-bottom: 0.75rem;
}

.logo-letter {
    display: inline-block;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.logo-letter.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Hero subtitle */
.hero-subtitle {
    position: relative;
    z-index: 4;
    font-family: 'Overpass', sans-serif;
    font-weight: 300;
    font-size: clamp(12px, 1.5vw, 18px);
    letter-spacing: 0.08em;
    color: #7F8C8D;
    text-transform: lowercase;
    margin-bottom: 3rem;
    opacity: 0;
    transition: opacity 0.8s ease 2s;
}

.hero-subtitle.is-visible {
    opacity: 1;
}

/* Elevation profile */
.elevation-profile {
    position: absolute;
    bottom: 60px;
    left: 10%;
    right: 10%;
    z-index: 4;
    opacity: 0;
    transition: opacity 0.6s ease 1.6s;
}

.elevation-profile.is-visible {
    opacity: 1;
}

.elevation-svg {
    width: 100%;
    height: 80px;
}

.elevation-line {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 2s ease-in-out;
}

.elevation-line.is-drawn {
    stroke-dashoffset: 0;
}

.datum-label {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #C0392B;
    font-weight: 400;
}

.elev-tick {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    fill: #7F8C8D;
}

/* Datum marker pulse */
.datum-marker {
    opacity: 0;
    transition: opacity 0.4s ease;
}

.datum-marker.is-visible {
    opacity: 1;
}

.datum-marker polygon {
    animation: datum-pulse 2s ease-in-out infinite;
}

@keyframes datum-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ============================================================
   HONEYCOMB NAVIGATION
   ============================================================ */
.honeycomb-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 64px;
    background-color: #FDFCFA;
    border-bottom: 1px solid rgba(44, 62, 80, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.honeycomb-strip {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.hex-cell {
    position: relative;
    width: 100px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    clip-path: polygon(8% 50%, 25% 0%, 75% 0%, 92% 50%, 75% 100%, 25% 100%);
    background-color: transparent;
    border: none;
    transition: background-color 0.3s ease;
    overflow: hidden;
}

.hex-cell::before {
    content: '';
    position: absolute;
    inset: 2px;
    clip-path: polygon(8% 50%, 25% 0%, 75% 0%, 92% 50%, 75% 100%, 25% 100%);
    border: 1.5px solid #2C3E50;
    pointer-events: none;
    z-index: 1;
}

.hex-cell::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 4px,
        rgba(46, 139, 123, 0.08) 4px,
        rgba(46, 139, 123, 0.08) 5px
    );
    background-size: 100% 200%;
    background-position: 0 100%;
    transition: background-position 0.4s ease;
    z-index: 0;
}

.hex-cell:hover::after {
    background-position: 0 0;
}

.hex-cell--active {
    background-color: rgba(46, 139, 123, 0.15);
}

.hex-cell--active::before {
    border-color: #2E8B7B;
}

.hex-cell-text {
    position: relative;
    z-index: 2;
    font-family: 'Overpass', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #2C3E50;
    text-transform: uppercase;
}

.hex-cell--active .hex-cell-text {
    color: #2E8B7B;
}

/* ============================================================
   CROSS-SECTION DIVIDERS
   ============================================================ */
.cross-section-divider {
    width: 100%;
    padding: 0 5%;
    margin: 0;
    position: relative;
    z-index: 2;
}

.cross-section-svg {
    width: 100%;
    height: 60px;
    display: block;
}

.cross-section-path {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.8s ease;
}

.cross-section-divider.is-revealed .cross-section-path {
    stroke-dashoffset: 0;
}

.cross-section-datum {
    opacity: 0;
    transition: opacity 0.3s ease 0.6s, transform 0.4s ease 0.6s;
}

.cross-section-divider.is-revealed .cross-section-datum {
    opacity: 1;
    animation: datum-bounce 0.4s ease 0.8s;
}

@keyframes datum-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ============================================================
   CONTENT TERRITORIES
   ============================================================ */
.territory {
    position: relative;
    z-index: 2;
    padding: 120px 0;
    background-color: #FDFCFA;
}

.territory:nth-child(even of .territory) {
    background-color: #F5F0E8;
}

.territory--deep {
    background-color: #F5F0E8;
}

.territory--closing {
    padding-bottom: 160px;
}

.territory-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 5%;
}

/* Z-pattern layout */
.territory-z-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 80px;
    align-items: start;
}

.territory-z-layout--reverse {
    direction: rtl;
}

.territory-z-layout--reverse > * {
    direction: ltr;
}

.territory-z-layout--centered {
    grid-template-columns: 1fr;
    text-align: center;
}

.territory-column {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.territory-z-layout--reverse .territory-column--left {
    transform: translateX(60px);
}

.territory-z-layout--reverse .territory-column--right {
    transform: translateX(-60px);
}

.territory-column--right {
    transform: translateX(60px);
}

.territory-column--full {
    transform: translateY(40px) translateX(0);
}

.territory-column.is-revealed {
    opacity: 1;
    transform: translateX(0) translateY(0);
}

.territory-heading {
    font-family: 'Overpass', sans-serif;
    font-weight: 700;
    font-size: clamp(24px, 3.5vw, 48px);
    letter-spacing: 0.04em;
    color: #2C3E50;
    line-height: 1.15;
    margin-bottom: 1.25rem;
}

.territory-heading em {
    font-style: normal;
    color: #2E8B7B;
}

.territory-heading--centered {
    text-align: center;
}

.territory-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-weight: 400;
    font-size: 1rem;
    line-height: 1.72;
    color: #2C3E50;
    margin-bottom: 1.5rem;
    max-width: 520px;
}

.territory-body--centered {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.territory-annotation {
    margin-top: 1rem;
}

.territory-annotation--centered {
    text-align: center;
    margin-top: 2rem;
}

.coord-label {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.06em;
    color: #7F8C8D;
    text-transform: uppercase;
}

.coord-value {
    font-family: 'Inconsolata', monospace;
    font-size: 14px;
    font-weight: 400;
    color: #2C3E50;
    margin-right: 1rem;
}

/* ============================================================
   HEXAGONAL FRAMES
   ============================================================ */
.hex-frame {
    width: 300px;
    height: 280px;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    background-color: #F5F0E8;
    border: 2px solid #2E8B7B;
    position: relative;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 0 2px #2E8B7B;
    transition: box-shadow 0.3s ease;
}

.hex-frame:hover {
    box-shadow: 0 0 12px rgba(46, 139, 123, 0.3);
}

.hex-frame--wide {
    width: 400px;
    height: 300px;
}

.hex-frame-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.contour-fill-svg,
.traverse-svg {
    width: 100%;
    height: 100%;
}

.contour-elev-label {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    fill: #7F8C8D;
}

.contour-center-label {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #C0392B;
    font-weight: 400;
}

.contour-annotation {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    fill: #7F8C8D;
    text-anchor: end;
}

.traverse-label {
    font-family: 'Inconsolata', monospace;
    font-size: 11px;
    fill: #7F8C8D;
}

.traverse-label--active {
    fill: #C0392B;
    font-weight: 400;
}

.traverse-n-label {
    font-family: 'Inconsolata', monospace;
    font-size: 9px;
    fill: #2C3E50;
}

/* ============================================================
   SURVEY STAKES
   ============================================================ */
.survey-stake {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5rem;
    opacity: 0;
    transform: scaleY(0);
    transform-origin: bottom center;
    transition: opacity 0.5s ease, transform 0.6s ease;
}

.survey-stake.is-visible {
    opacity: 1;
    transform: scaleY(1);
}

.survey-stake--inline {
    margin-top: 1rem;
}

.stake-flag {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    color: #FDFCFA;
    background-color: #C0392B;
    padding: 3px 10px;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.stake-line {
    display: block;
    width: 1px;
    height: 40px;
    background-color: #C0392B;
}

/* ============================================================
   ISOMETRIC CARDS
   ============================================================ */
.isometric-cluster {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.isometric-cluster--offset {
    grid-template-columns: repeat(2, 1fr);
}

.iso-card {
    background-color: #FDFCFA;
    padding: 28px 24px;
    position: relative;
    transform: perspective(800px) rotateX(2deg) rotateY(-2deg);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    border: 1px solid rgba(44, 62, 80, 0.1);
    opacity: 0;
    transform: perspective(800px) rotateX(8deg) translateY(30px);
}

.iso-card.is-revealed {
    opacity: 1;
    transform: perspective(800px) rotateX(0deg) translateY(0);
}

.iso-card:hover {
    transform: perspective(800px) rotateX(0deg) translateY(-4px);
    box-shadow: 0 8px 24px rgba(44, 62, 80, 0.08);
}

/* Contour line background on cards */
.iso-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 7px,
        rgba(127, 140, 141, 0.08) 7px,
        rgba(127, 140, 141, 0.08) 8px
    );
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 1;
}

.iso-card:hover::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 7px,
        rgba(127, 140, 141, 0.16) 7px,
        rgba(127, 140, 141, 0.16) 8px
    );
}

/* Offset pattern for 4-card clusters */
.iso-card--4 { grid-column: 1; grid-row: 1; }
.iso-card--5 { grid-column: 2; grid-row: 1; margin-top: 30px; }
.iso-card--6 { grid-column: 1; grid-row: 2; }
.iso-card--7 { grid-column: 2; grid-row: 2; margin-top: 30px; }

.iso-card-number {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    color: #C0392B;
    letter-spacing: 0.04em;
    display: block;
    margin-bottom: 0.5rem;
}

.iso-card-title {
    font-family: 'Overpass', sans-serif;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.04em;
    color: #2C3E50;
    margin-bottom: 0.5rem;
    line-height: 1.25;
}

.iso-card-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 14px;
    line-height: 1.65;
    color: #2C3E50;
}

/* ============================================================
   TRAVERSE STATIONS
   ============================================================ */
.traverse-stations {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 2rem;
    padding: 1.5rem 0;
}

.station-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.station-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #2C3E50;
    border: 2px solid #2C3E50;
}

.station-marker--current .station-dot {
    background-color: #C0392B;
    border-color: #C0392B;
    box-shadow: 0 0 8px rgba(192, 57, 43, 0.4);
}

.station-label {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    color: #7F8C8D;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.station-marker--current .station-label {
    color: #C0392B;
}

.station-connector {
    flex: 1;
    height: 1px;
    background-color: #2C3E50;
    min-width: 20px;
    margin: 0 -1px;
    margin-bottom: 18px;
}

/* ============================================================
   BENCHMARK DISC
   ============================================================ */
.benchmark-disc {
    width: 240px;
    height: 240px;
    margin: 2.5rem auto;
}

.benchmark-svg {
    width: 100%;
    height: 100%;
}

.benchmark-text {
    font-family: 'Overpass', sans-serif;
    letter-spacing: 0.08em;
}

.benchmark-text--title {
    font-size: 24px;
    font-weight: 700;
    fill: #2C3E50;
}

.benchmark-text--subtitle {
    font-size: 11px;
    font-weight: 700;
    fill: #7F8C8D;
}

.benchmark-text--elev {
    font-family: 'Inconsolata', monospace;
    font-size: 14px;
    fill: #C0392B;
    letter-spacing: 0.04em;
}

.benchmark-text--datum {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #D4A960;
    letter-spacing: 0.06em;
}

/* ============================================================
   FOOTER DATUM LINE
   ============================================================ */
.footer-datum {
    position: relative;
    z-index: 2;
    background-color: #FDFCFA;
    padding: 40px 5% 60px;
    text-align: center;
}

.datum-line-container {
    width: 100%;
    margin-bottom: 2rem;
}

.datum-line-svg {
    width: 100%;
    height: 120px;
}

.datum-tick-label {
    font-family: 'Inconsolata', monospace;
    font-size: 10px;
    fill: #7F8C8D;
}

.datum-tick-label--center {
    fill: #C0392B;
    font-size: 11px;
}

.datum-tick-label--depth {
    fill: #1A5276;
}

.return-to-center {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid #C0392B;
    padding: 10px 24px;
    cursor: pointer;
    font-family: 'Overpass', sans-serif;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.08em;
    color: #C0392B;
    text-transform: uppercase;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-bottom: 2rem;
}

.return-to-center:hover {
    background-color: #C0392B;
    color: #FDFCFA;
}

.return-to-center:hover .return-icon polygon {
    fill: #FDFCFA;
}

.footer-coordinates {
    font-family: 'Inconsolata', monospace;
    font-size: 12px;
    color: #7F8C8D;
    letter-spacing: 0.04em;
}

/* ============================================================
   CONTOUR LINE SECTION BACKGROUNDS
   ============================================================ */
.territory::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 7px,
            rgba(127, 140, 141, 0.04) 7px,
            rgba(127, 140, 141, 0.04) 8px
        );
    pointer-events: none;
    z-index: 0;
}

.territory > * {
    position: relative;
    z-index: 1;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .territory-z-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .territory-z-layout--reverse {
        direction: ltr;
    }

    .hex-frame,
    .hex-frame--wide {
        width: 260px;
        height: 240px;
    }

    .isometric-cluster {
        grid-template-columns: 1fr;
    }

    .iso-card--5,
    .iso-card--7 {
        margin-top: 0;
    }

    .hex-cell {
        width: 72px;
        height: 40px;
    }

    .hex-cell-text {
        font-size: 9px;
    }

    .territory-column {
        transform: translateX(0) translateY(30px);
    }

    .territory-z-layout--reverse .territory-column--left,
    .territory-z-layout--reverse .territory-column--right {
        transform: translateX(0) translateY(30px);
    }
}

@media (max-width: 600px) {
    html {
        font-size: 16px;
    }

    .honeycomb-strip {
        gap: 2px;
        overflow-x: auto;
        padding: 0 12px;
    }

    .hex-cell {
        width: 60px;
        height: 36px;
        flex-shrink: 0;
    }

    .hex-cell-text {
        font-size: 8px;
    }

    .territory {
        padding: 80px 0;
    }

    .traverse-stations {
        flex-wrap: wrap;
        justify-content: center;
    }

    .station-connector {
        min-width: 12px;
    }

    .benchmark-disc {
        width: 180px;
        height: 180px;
    }
}
