/* ============================================================
   matsurika.dev — Bauhaus Alpine Grid
   Palette: Cool Grays, Zero Warm Tones, No Gradients
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary:    #1C2331;
    --bg-secondary:  #2E3440;
    --bg-hover:      #374151;
    --border:        #4B5563;
    --text-secondary:#6B7280;
    --text-body:     #9BA4AF;
    --text-primary:  #C8CDD4;
    --text-white:    #FFFFFF;
    --accent-red:    #ff0040;
    --accent-cyan:   #00f0ff;

    --font-display:  'Bebas Neue', sans-serif;
    --font-body:     'Space Grotesk', sans-serif;
    --font-mono:     'IBM Plex Mono', monospace;

    --grid-max:      1440px;
    --grid-pad:      80px;
    --grid-gap:      24px;
    --card-ratio:    calc(4 / 3);
}

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

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-body);
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 15px;
    line-height: 1.65;
    overflow-x: hidden;
}

/* ============================================================
   TYPOGRAPHY UTILITIES
   ============================================================ */

.label-text {
    font-family: var(--font-mono);
    font-weight: 400;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* ============================================================
   HEADER STRIP — 64px fixed
   ============================================================ */

.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background-color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    z-index: 100;
    border-bottom: 1px solid var(--border);
}

.site-wordmark {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 22px;
    letter-spacing: 0.35em;
    color: var(--text-white);
    text-transform: uppercase;
    cursor: default;
    transition: none;
}

/* Wordmark glitch hover */
.site-wordmark:hover {
    animation: glitch-hover 60ms linear forwards;
}

.site-nav {
    display: flex;
    gap: 32px;
}

.nav-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    cursor: default;
}

.nav-label:hover {
    color: var(--text-primary);
}

/* ============================================================
   HERO PANEL — 100vh
   ============================================================ */

.hero-panel {
    position: relative;
    width: 100%;
    height: 100vh;
    background-color: var(--bg-primary);
    overflow: hidden;
    display: flex;
    align-items: center;
    margin-top: 64px;
}

/* --- Three-Layer Mountain Construction (clip-path polygon) --- */

.mountain {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    opacity: 0;
    animation: mountain-fade-in 600ms linear 200ms forwards;
}

/* Layer 1: background ridgeline — 7 vertices, lower 40% of panel */
.mountain-l1 {
    background-color: #2E3440;
    height: 100%;
    clip-path: polygon(
        0% 100%,
        0% 72%,
        8% 65%,
        20% 58%,
        35% 52%,
        50% 60%,
        65% 55%,
        80% 62%,
        100% 58%,
        100% 100%
    );
    z-index: 1;
}

/* Layer 2: mid-ground sharper peaks — 5 vertices, dominant center-left peak */
.mountain-l2 {
    background-color: #374151;
    height: 100%;
    clip-path: polygon(
        0% 100%,
        0% 80%,
        15% 75%,
        30% 62%,
        42% 44%,
        55% 68%,
        72% 72%,
        88% 78%,
        100% 82%,
        100% 100%
    );
    z-index: 2;
    animation-delay: 200ms;
}

/* Layer 3: foreground fractured near-peak — 4 vertices, overlaps viewport bottom */
.mountain-l3 {
    background-color: #4B5563;
    height: 100%;
    clip-path: polygon(
        0% 100%,
        0% 88%,
        18% 82%,
        38% 72%,
        52% 78%,
        68% 85%,
        85% 90%,
        100% 92%,
        100% 100%
    );
    z-index: 3;
    animation-delay: 200ms;
}

@keyframes mountain-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* --- Hero Content --- */

.hero-content {
    position: relative;
    z-index: 10;
    max-width: var(--grid-max);
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--grid-pad);
    opacity: 0;
    animation: hero-content-enter 400ms cubic-bezier(0.22, 1, 0.36, 1) 800ms forwards;
}

@keyframes hero-content-enter {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.hero-eyebrow {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.hero-eyebrow .label-sep {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.5;
}

.hero-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: clamp(72px, 10vw, 120px);
    letter-spacing: 0.08em;
    line-height: 1;
    color: var(--text-white);
    margin-bottom: 24px;
    text-transform: uppercase;
}

/* Characters will be split by JS for kinetic animation */
.hero-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateX(-20px);
    animation: char-enter 400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes char-enter {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.hero-subtext {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-body);
    max-width: 480px;
}

/* --- Registration Marks on Hero --- */

.reg-mark {
    position: absolute;
    width: 10px;
    height: 10px;
    z-index: 20;
}

.reg-mark--tl {
    top: 24px;
    left: 24px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.reg-mark--tr {
    top: 24px;
    right: 24px;
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.reg-mark--bl {
    bottom: 24px;
    left: 24px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.reg-mark--br {
    bottom: 24px;
    right: 24px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* ============================================================
   CARD GRID FEED
   ============================================================ */

.grid-container {
    max-width: var(--grid-max);
    margin: 0 auto;
    padding: 80px var(--grid-pad);
}

/* Section header above grid */
.section-header {
    display: flex;
    align-items: baseline;
    gap: 32px;
    margin-bottom: 48px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.section-title {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 48px;
    letter-spacing: 0.08em;
    color: var(--text-white);
    text-transform: uppercase;
}

.section-title .char {
    display: inline-block;
    opacity: 0;
    transform: translateX(-20px);
    animation: char-enter 400ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.section-meta {
    color: var(--text-secondary);
}

/* Card Grid: 4 columns strict */
.grid-container > .card {
    /* Handled below in the CSS Grid context */
}

/* Apply CSS Grid to cards directly within grid-container */
.grid-container {
    display: block; /* wrapper */
}

.grid-container .section-header {
    grid-column: 1 / -1;
}

/* Wrap cards in a grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--grid-gap);
}

/* ============================================================
   CARD
   ============================================================ */

.card {
    position: relative;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0;
    overflow: hidden;
    /* 3:4 ratio (portrait DIN A4) */
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    /* Card entrance animation: invisible until IntersectionObserver triggers */
    opacity: 0;
    transform: translateY(-12px);
    transition:
        border-color 200ms linear,
        background-color 200ms linear;
}

.card.is-visible {
    animation: card-enter 300ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
    animation-delay: calc(var(--card-index, 0) * 0.2s);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(-12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure card stays visible after animation */
.card.is-visible.anim-done {
    opacity: 1;
    transform: translateY(0);
}

/* Card hover state */
.card:hover {
    border-color: #9BA4AF;
    background-color: var(--bg-hover);
}

/* Every 4th card glitch offset (index 3, 7, 11 = 0-based indices 3,7,11) */
.card--glitch-offset {
    /* Will be animated by JS GlitchEngine */
}

/* Card contour: SVG topographic lines inserted by JS */
.card-contour {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

/* Card registration marks — L-shaped corners */
.card-reg-mark {
    position: absolute;
    width: 10px;
    height: 10px;
    z-index: 2;
    pointer-events: none;
    transition: width 200ms linear, height 200ms linear;
}

.card:hover .card-reg-mark {
    width: 14px;
    height: 14px;
}

.card-reg-mark--tl {
    top: 6px;
    left: 6px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.card-reg-mark--tr {
    top: 6px;
    right: 6px;
    border-top: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.card-reg-mark--bl {
    bottom: 6px;
    left: 6px;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
}

.card-reg-mark--br {
    bottom: 6px;
    right: 6px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

/* Card body — sits above contour */
.card-body {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100%;
    gap: 16px;
}

.card-tag {
    /* inherits .label-text */
    display: block;
}

.card-title {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 17px;
    line-height: 1.3;
    color: var(--text-primary);
    flex-grow: 1;
}

.card-text {
    font-family: var(--font-body);
    font-weight: 300;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text-body);
    flex-grow: 2;
}

.card-meta {
    /* inherits .label-text */
    display: block;
    margin-top: auto;
}

/* ============================================================
   GLITCH STATE
   Applied by GlitchEngine JS class
   ============================================================ */

.glitching {
    filter: url(#glitch-svg-filter);
    transform: translateX(3px);
}

/* Text-shadow color aberration on glitching type */
.glitching .hero-title,
.glitching .card-title,
.site-wordmark.glitching {
    text-shadow: 2px 0 #ff0040, -2px 0 #00f0ff;
}

/* Hero panel glitch: only text layer shifts, mountain stays */
.hero-panel.glitching .hero-content {
    filter: url(#glitch-svg-filter);
    transform: translateX(8px);
}

.hero-panel.glitching .mountain {
    filter: none;
    transform: none;
}

/* ============================================================
   KEYFRAME ANIMATIONS: Glitch
   ============================================================ */

@keyframes glitch-hover {
    0%   { transform: translateX(0);   filter: none; }
    33%  { transform: translateX(3px); filter: hue-rotate(180deg) saturate(2); }
    66%  { transform: translateX(-3px); filter: hue-rotate(0deg) saturate(1); }
    100% { transform: translateX(0);   filter: none; }
}

/* ============================================================
   FOOTER PLANE — 120px
   ============================================================ */

.site-footer {
    height: 120px;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.footer-rule {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border);
}

.footer-inner {
    display: flex;
    align-items: center;
    gap: 24px;
}

.footer-text {
    /* inherits .label-text */
}

.footer-sep {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--border);
}

/* ============================================================
   GRID WRAP — actually place cards in CSS grid
   (We need to convert the flat structure)
   ============================================================ */

/* The section header + cards are siblings inside .grid-container.
   Use a more precise approach: wrap manually via JS or handle with CSS. */

/* ============================================================
   RESPONSIVE: Scale down gracefully
   (Keep 4 columns as long as possible)
   ============================================================ */

@media (max-width: 1200px) {
    :root {
        --grid-pad: 48px;
    }
}

@media (max-width: 900px) {
    :root {
        --grid-pad: 32px;
    }
    .cards-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    :root {
        --grid-pad: 16px;
    }
    .cards-grid {
        grid-template-columns: 1fr;
    }
    .hero-title {
        font-size: 56px;
    }
}
