/* ========================================
   lungless.dev - Styles
   Hand-drawn sketchbook aesthetic
   Masonry layout with blur-focus transitions
   ======================================== */

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

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

body {
    background-color: #F5F0E8;
    color: #1A1A1A;
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    position: relative;
}

/* --- SVG Defs (hidden) --- */
.svg-defs {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* --- Background Decorative Triangles --- */
.bg-triangles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
    opacity: 0.08;
}

.bg-triangle--small {
    border-width: 0 8px 15px 8px;
    border-color: transparent transparent #7A7267 transparent;
}

.bg-triangle--medium {
    border-width: 0 12px 22px 12px;
    border-color: transparent transparent #7A7267 transparent;
}

.bg-triangle--large {
    border-width: 0 14px 25px 14px;
    border-color: transparent transparent #7A7267 transparent;
}

/* --- Navigation Compass --- */
.compass-nav {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 100;
    cursor: pointer;
}

.compass-rose {
    width: 48px;
    height: 48px;
    transition: transform 0.4s ease;
}

.compass-nav:hover .compass-rose {
    transform: rotate(45deg);
}

.compass-nav.active .compass-rose {
    transform: rotate(90deg);
}

.radial-menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 200px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.compass-nav.active .radial-menu {
    opacity: 1;
    pointer-events: auto;
}

.radial-link {
    position: absolute;
    top: 24px;
    left: 24px;
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #1A1A1A;
    text-decoration: none;
    transform-origin: 0 0;
    transform: rotate(var(--angle)) translateX(70px) rotate(calc(-1 * var(--angle)));
    transition: color 0.2s ease;
    white-space: nowrap;
}

.radial-link:hover {
    color: #C45D3E;
}

/* --- Hero Section --- */
.hero {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
    padding: 2rem;
}

.hero-content {
    text-align: center;
    max-width: 900px;
}

.hero-title {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(3rem, 8vw, 6rem);
    letter-spacing: 0.02em;
    color: #1A1A1A;
    margin-bottom: 2rem;
    line-height: 1.1;
}

.letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: letterDraw 0.5s ease forwards;
    animation-delay: calc(var(--delay) * 0.12s);
}

@keyframes letterDraw {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-salamander {
    margin: 2rem auto;
    max-width: 500px;
    animation: breathe 3s ease-in-out infinite;
}

.salamander-svg {
    width: 100%;
    height: auto;
}

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

.breath-line {
    animation: breathFlow 3s ease-in-out infinite;
}

@keyframes breathFlow {
    0%, 100% {
        opacity: 0.15;
        stroke-dashoffset: 0;
    }
    50% {
        opacity: 0.5;
        stroke-dashoffset: -10;
    }
}

.hero-subtitle {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.2rem, 3vw, 2rem);
    color: #7A7267;
    margin-top: 1rem;
}

.scroll-hint {
    position: absolute;
    bottom: 2rem;
    animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-chevron {
    width: 32px;
    height: 32px;
}

@keyframes scrollBounce {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    50% {
        transform: translateY(8px);
        opacity: 1;
    }
}

/* --- Section Dividers --- */
.section-divider {
    width: 100%;
    padding: 1rem 0;
    overflow: hidden;
}

.section-divider.angled {
    transform: rotate(-2deg);
    margin: 2rem 0;
}

.wavy-line {
    width: 100%;
    height: 20px;
    display: block;
}

/* --- Masonry Grid --- */
.masonry-grid {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 2rem clamp(1rem, 4vw, 3rem);
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Masonry Cards --- */
.masonry-card {
    background: #EDE7D9;
    padding: 1.5rem;
    position: relative;
    will-change: filter, opacity, transform;
    transition: filter 0.6s ease-out, opacity 0.6s ease-out, transform 0.6s ease-out;
    overflow: hidden;
}

/* Hand-drawn border via box-shadow + SVG filter */
.masonry-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid #2B2B2B;
    filter: url(#hand-drawn);
    pointer-events: none;
    z-index: 2;
}

/* Diagonal corner cuts */
.masonry-card[data-corner="top-right"] {
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.masonry-card[data-corner="top-left"] {
    clip-path: polygon(12px 0, 100% 0, 100% 100%, 0 100%, 0 12px);
}

.masonry-card[data-corner="bottom-right"] {
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%);
}

.masonry-card[data-corner="bottom-left"] {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

/* Card height variations */
.card-compact {
    min-height: 200px;
}

.card-tall {
    min-height: 360px;
}

.card-breakout {
    grid-column: 1 / -1;
    min-height: 320px;
}

/* Blur-focus initial state */
.blur-target {
    filter: blur(8px);
    opacity: 0.6;
    transform: scale(0.97);
}

.blur-target.in-focus {
    filter: blur(0);
    opacity: 1;
    transform: scale(1);
}

.blur-target.past-focus {
    filter: blur(2px);
    opacity: 0.85;
    transform: scale(0.99);
}

/* Card hover diagonal slash marks */
.masonry-card::after {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 40px;
    background: repeating-linear-gradient(
        35deg,
        transparent,
        transparent 4px,
        rgba(196, 93, 62, 0.2) 4px,
        rgba(196, 93, 62, 0.2) 6px
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 3;
}

.masonry-card:hover::after {
    opacity: 1;
}

/* --- Card Typography --- */
.card-headline {
    font-family: 'Libre Baskerville', serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4.5vw, 3.2rem);
    letter-spacing: 0.02em;
    color: #1A1A1A;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.card-subheadline {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: #1A1A1A;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.card-body {
    font-family: 'Nunito', sans-serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.8vw, 1.1rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    color: #1A1A1A;
    margin-bottom: 0.75rem;
}

.card-body strong {
    font-weight: 600;
}

.card-annotation {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(0.85rem, 1.5vw, 1rem);
    color: #7A7267;
    display: block;
    margin-top: 0.75rem;
}

.card-annotation-large {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: #7A7267;
    line-height: 1.6;
}

/* --- Card Diagrams --- */
.card-diagram {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.5rem 0;
}

.card-diagram svg {
    width: 100%;
    max-width: 320px;
    height: auto;
}

/* --- Pull Quotes --- */
.card-quote {
    display: flex;
    align-items: center;
    justify-content: center;
}

.chevron-frame {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
}

.chevron-left,
.chevron-right {
    width: 20px;
    height: 60px;
    flex-shrink: 0;
}

.pull-quote p {
    font-family: 'Libre Baskerville', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.1rem, 2.5vw, 1.6rem);
    line-height: 1.5;
    color: #1A1A1A;
    text-align: center;
}

/* --- Diamond Bullet List --- */
.diamond-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-top: 0.5rem;
}

.diamond-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.diamond-bullet {
    display: inline-block;
    width: 12px;
    height: 12px;
    background: #C45D3E;
    transform: rotate(45deg);
    flex-shrink: 0;
    margin-top: 0.5rem;
}

.diamond-item .card-body {
    margin-bottom: 0;
}

/* --- Breakout Cards --- */
.breakout-content {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-top: 1rem;
}

.breakout-text {
    flex: 1;
}

.breakout-diagram {
    flex: 0 0 300px;
    display: flex;
    justify-content: center;
}

.breakout-diagram svg {
    width: 100%;
    max-width: 300px;
    height: auto;
}

/* --- Deep Dive Section --- */
.deep-dive {
    position: relative;
    z-index: 1;
    background-color: #EDE7D9;
    padding: 2rem 0;
}

.masonry-deep {
    max-width: 1400px;
    margin: 0 auto;
}

/* --- Philosophy Zone --- */
.philosophy-zone {
    position: relative;
    z-index: 1;
    padding: 3rem 0;
}

/* --- Closing Section --- */
.closing {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
}

.closing-composition {
    text-align: center;
    max-width: 600px;
}

.closing-salamander {
    width: 100%;
    max-width: 550px;
    height: auto;
    margin-bottom: 2.5rem;
}

.closing-statement {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    color: #7A7267;
    line-height: 1.5;
}

/* --- Margin Doodles --- */
.margin-doodles {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.margin-doodle {
    position: absolute;
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #7A7267;
    opacity: 0.25;
    user-select: none;
}

/* --- Responsive: Tablet --- */
@media (max-width: 1080px) {
    .masonry-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-breakout {
        grid-column: 1 / -1;
    }

    .breakout-content {
        flex-direction: column;
    }

    .breakout-diagram {
        flex: none;
        width: 100%;
    }
}

/* --- Responsive: Mobile --- */
@media (max-width: 600px) {
    .masonry-grid {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 16px;
    }

    .card-breakout {
        grid-column: 1;
    }

    .hero-title {
        font-size: clamp(2rem, 10vw, 3.5rem);
    }

    .compass-nav {
        top: 12px;
        left: 12px;
    }

    .compass-rose {
        width: 36px;
        height: 36px;
    }

    .radial-link {
        transform: rotate(var(--angle)) translateX(55px) rotate(calc(-1 * var(--angle)));
        font-size: 0.85rem;
    }

    .breakout-content {
        flex-direction: column;
    }

    .breakout-diagram {
        flex: none;
        width: 100%;
        max-width: 280px;
        margin: 0 auto;
    }

    .closing-salamander {
        max-width: 320px;
    }
}

/* --- Link Colors --- */
a {
    color: #2A6B6B;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #D4A843;
}

/* --- Error/Alert Accent (Oxide Red) --- */
.card-error-accent {
    border-left: 3px solid #8B3A2A;
}

.failure-mark {
    color: #8B3A2A;
}

/* --- Selection --- */
::selection {
    background: rgba(212, 168, 67, 0.3);
    color: #1A1A1A;
}
