/* ====================================
   gabs.cafe - Korean Market Gazette
   ==================================== */

/* CSS Custom Properties */
:root {
    --aged-parchment: #F2E8D5;
    --espresso-ink: #2C1810;
    --dark-roast: #3D2E1F;
    --pencil-graphite: #6B5744;
    --worn-brass: #8B7355;
    --vermillion-seal: #C4463A;
    --cafe-latte: #A0764E;
    --aged-gold: #D4A042;
    --creased-linen: #E0D4BE;
}

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

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

body {
    background-color: var(--aged-parchment);
    color: var(--espresso-ink);
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    line-height: 1.85;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

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

/* Paper Grain Overlay */
.paper-grain-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.06;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
}

/* Fold Lines */
.fold-lines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transition: opacity 600ms ease;
}

.fold-lines.visible {
    opacity: 1;
}

.fold-line {
    position: absolute;
    background-color: var(--worn-brass);
}

.fold-horizontal {
    top: 50vh;
    left: 0;
    width: 100%;
    height: 2px;
    opacity: 0.03;
}

.fold-vertical {
    top: 0;
    left: 50vw;
    width: 2px;
    height: 100%;
    opacity: 0.03;
}

/* Scroll Progress Bar */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 2px;
    width: 0%;
    background-color: var(--aged-gold);
    z-index: 10001;
    transition: width 50ms linear;
}

/* Section Navigation */
.section-nav {
    position: fixed;
    top: 2px;
    left: 0;
    width: 100%;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    background-color: rgba(242, 232, 213, 0.92);
    z-index: 10000;
    font-family: 'DM Serif Display', serif;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--pencil-graphite);
    backdrop-filter: blur(4px);
}

.nav-item {
    cursor: pointer;
    padding: 0 12px;
    position: relative;
    transition: color 200ms ease, font-weight 200ms ease;
}

.nav-item::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    right: 50%;
    height: 1px;
    background-color: var(--vermillion-seal);
    transition: left 200ms ease, right 200ms ease;
}

.nav-item.active {
    color: var(--espresso-ink);
    font-weight: 700;
}

.nav-item.active::after {
    left: 12px;
    right: 12px;
}

.nav-item:hover {
    color: var(--espresso-ink);
}

.nav-separator {
    color: var(--worn-brass);
    opacity: 0.5;
    user-select: none;
}

/* Page Sections */
.page {
    min-height: 100vh;
    position: relative;
    padding: 60px 5vw 40px;
}

/* ====================================
   SECTION 1: MASTHEAD
   ==================================== */
.masthead {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 50px;
}

.masthead-grid {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 3fr;
    grid-template-rows: auto 1fr auto auto;
    gap: 0;
    width: 100%;
    max-width: 1200px;
    height: 85vh;
    position: relative;
}

/* Dateline Column */
.dateline-column {
    grid-column: 1;
    grid-row: 1 / -1;
    border-right: 1px solid rgba(139, 115, 85, 0.2);
    padding: 20px 20px 20px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dateline-item {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--pencil-graphite);
    letter-spacing: 0.04em;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.dateline-item.visible {
    opacity: 1;
    transform: translateY(0);
}

.dateline-kr {
    font-family: 'Noto Sans KR', sans-serif;
    font-size: 0.7rem;
}

.dateline-day {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--espresso-ink);
}

.dateline-divider {
    width: 40px;
    height: 1px;
    background-color: var(--worn-brass);
    opacity: 0.3;
    margin: 8px 0;
}

.dateline-section {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 400ms ease, transform 400ms ease;
}

.dateline-section.visible {
    opacity: 1;
    transform: translateY(0);
}

.section-link {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--espresso-ink);
    text-decoration: none;
    letter-spacing: 0.04em;
    position: relative;
    display: inline-block;
}

.section-link::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: var(--vermillion-seal);
    transition: width 300ms ease;
}

.section-link:hover::after {
    width: 100%;
}

/* Masthead Character Area */
.masthead-character-area {
    grid-column: 2;
    grid-row: 1 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-left: 40px;
}

.coffee-ring-watermark {
    position: absolute;
    top: 15%;
    left: 20%;
    opacity: 1;
    pointer-events: none;
}

.masthead-svg {
    width: clamp(200px, 40vw, 500px);
    height: auto;
    position: relative;
    z-index: 2;
}

.gabs-char {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: draw-char 2.4s ease forwards;
    animation-delay: 0.8s;
}

@keyframes draw-char {
    to {
        stroke-dashoffset: 0;
    }
}

.masthead-fill-char {
    position: absolute;
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(3rem, 10vw, 8rem);
    color: var(--espresso-ink);
    letter-spacing: 0.04em;
    z-index: 3;
    opacity: 0;
    animation: fill-appear 400ms ease forwards;
    animation-delay: 3.2s;
    filter: drop-shadow(0 0 0px rgba(212, 160, 66, 0));
}

@keyframes fill-appear {
    0% {
        opacity: 0;
        filter: drop-shadow(0 0 8px rgba(212, 160, 66, 0.3));
    }
    50% {
        opacity: 1;
        filter: drop-shadow(0 0 8px rgba(212, 160, 66, 0.3));
    }
    100% {
        opacity: 1;
        filter: drop-shadow(0 0 0px rgba(212, 160, 66, 0));
    }
}

/* Banner Headline */
.banner-headline {
    grid-column: 1 / -1;
    grid-row: 3;
    padding: 20px 0;
    overflow: hidden;
}

.banner-text-mask {
    overflow: hidden;
    position: relative;
}

.banner-text {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(2rem, 5vw, 4rem);
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--espresso-ink);
    white-space: nowrap;
    transform: translateX(-100%);
    animation: slide-reveal 800ms ease forwards;
    animation-delay: 1.2s;
}

@keyframes slide-reveal {
    to {
        transform: translateX(0);
    }
}

/* Masthead Subtitle */
.masthead-subtitle {
    grid-column: 1 / -1;
    grid-row: 4;
    padding: 8px 0 20px;
    border-top: 1px solid rgba(139, 115, 85, 0.2);
}

.subtitle-kr {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(0.85rem, 1.2vw, 1rem);
    color: var(--pencil-graphite);
    letter-spacing: 0.08em;
}

/* ====================================
   SECTION 2: MARKET REPORT
   ==================================== */
.market-report {
    border-top: 2px solid rgba(139, 115, 85, 0.15);
}

.market-grid {
    display: grid;
    grid-template-columns: 2.5fr 1fr 1.2fr;
    gap: 0;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
}

.section-title {
    font-family: 'Noto Serif KR', serif;
    font-weight: 900;
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    color: var(--espresso-ink);
    letter-spacing: 0.04em;
    margin-bottom: 30px;
}

.section-title-en {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: var(--pencil-graphite);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: 12px;
}

/* Market Narrative */
.market-narrative {
    padding-right: 30px;
    border-right: 1px solid rgba(139, 115, 85, 0.2);
}

.narrative-body p {
    margin-bottom: 1.5em;
    color: var(--dark-roast);
    text-align: justify;
}

.typewriter-paragraph {
    opacity: 0;
    transition: opacity 600ms ease;
}

.typewriter-paragraph.visible {
    opacity: 1;
}

.typewriter-paragraph .word {
    opacity: 0.04;
    transition: opacity 60ms ease;
}

.typewriter-paragraph .word.revealed {
    opacity: 1;
}

/* Price Inventory */
.price-inventory {
    padding: 0 20px;
    border-right: 1.5px solid rgba(139, 115, 85, 0.2);
}

.inventory-title {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--espresso-ink);
    margin-bottom: 24px;
    letter-spacing: 0.04em;
}

.inventory-title-en {
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    font-size: 0.7rem;
    color: var(--pencil-graphite);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-left: 6px;
}

.inventory-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.inventory-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(139, 115, 85, 0.1);
}

.item-name {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--espresso-ink);
}

.item-name-en {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 0.72rem;
    color: var(--pencil-graphite);
    display: block;
    margin-top: 2px;
}

.item-price {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 1.1rem;
    color: var(--espresso-ink);
    font-variant-numeric: tabular-nums;
}

.item-unit {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 0.75rem;
    color: var(--pencil-graphite);
}

/* Market Marginalia */
.market-marginalia {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    padding-top: 80px;
}

.margin-note {
    font-family: 'Gaegu', cursive;
    font-size: clamp(0.85rem, 1.1vw, 1.05rem);
    color: var(--pencil-graphite);
    line-height: 1.6;
    opacity: 0;
    transform: translateY(15px) scale(0.95);
    transition: opacity 400ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.margin-note.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ====================================
   SECTION 3: COMMENTARY
   ==================================== */
.commentary {
    border-top: 2px solid rgba(139, 115, 85, 0.15);
}

.commentary-grid {
    display: grid;
    grid-template-columns: 80px 1fr 80px;
    gap: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.commentary-title {
    text-align: center;
}

/* Seal Stamps */
.seal-margin {
    display: flex;
    flex-direction: column;
    gap: 40px;
    padding-top: 100px;
}

.seal-margin-left {
    align-items: flex-start;
}

.seal-margin-right {
    align-items: flex-end;
}

.seal-stamp {
    opacity: 0;
    transform: scale(1.1);
    transition: opacity 150ms ease, transform 150ms ease;
}

.seal-stamp.visible {
    opacity: 1;
    transform: scale(1);
}

/* Commentary Content */
.commentary-content {
    padding: 0 20px;
}

.commentary-body p {
    color: var(--dark-roast);
    margin-bottom: 1.5em;
    text-align: justify;
}

.commentary-body em {
    font-style: normal;
}

/* Red underline */
.red-underline {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='6'%3E%3Cpath d='M0 5 Q 10 1, 20 4 T 40 4 T 60 4 T 80 4 T 100 4' fill='none' stroke='%23C4463A' stroke-width='1.5' stroke-opacity='0.4'/%3E%3C/svg%3E");
    background-repeat: repeat-x;
    background-position: bottom;
    background-size: 100px 6px;
    padding-bottom: 4px;
    font-style: normal;
}

/* Pull Quotes */
.pull-quote-wrapper {
    position: relative;
    margin: 40px 0;
    padding: 20px 60px;
}

.pull-quote {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    color: var(--espresso-ink);
    line-height: 1.5;
    text-align: center;
}

.pull-quote-mark {
    font-family: 'Noto Serif KR', serif;
    font-size: 6rem;
    color: var(--espresso-ink);
    opacity: 0.04;
    position: absolute;
    line-height: 1;
    transition: opacity 600ms ease, filter 600ms ease;
    filter: blur(8px);
}

.pull-quote-mark.focused {
    opacity: 0.10;
    filter: blur(0px);
}

.pull-quote-open {
    top: -20px;
    left: 0;
}

.pull-quote-close {
    bottom: -40px;
    right: 0;
}

.pull-quote-lower {
    margin-top: 30px;
}

/* ====================================
   SECTION 4: CLASSIFIEDS
   ==================================== */
.classifieds {
    border-top: 2px solid rgba(139, 115, 85, 0.15);
}

.classifieds-title {
    text-align: center;
    margin-bottom: 40px;
}

.classifieds-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    max-width: 1100px;
    margin: 0 auto;
}

.classified-card {
    background-color: var(--aged-parchment);
    border: 1px solid rgba(139, 115, 85, 0.15);
    padding: 24px 20px;
    position: relative;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 300ms cubic-bezier(0.34, 1.56, 0.64, 1), transform 300ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 300ms ease;
}

.classified-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.classified-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(44, 24, 16, 0.08);
}

.classified-card:hover .card-price {
    color: var(--vermillion-seal);
}

.card-alt {
    background-color: rgba(224, 212, 190, 0.3);
}

.card-seal {
    position: absolute;
    top: 12px;
    right: 12px;
}

.card-concept {
    font-family: 'DM Serif Display', serif;
    font-size: 1.2rem;
    color: var(--espresso-ink);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.card-concept-kr {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--pencil-graphite);
    margin-bottom: 12px;
}

.card-description {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: 0.82rem;
    color: var(--dark-roast);
    line-height: 1.7;
    margin-bottom: 16px;
}

.card-price {
    font-family: 'Gaegu', cursive;
    font-size: 0.9rem;
    color: var(--pencil-graphite);
    transition: color 300ms ease;
    border-top: 1px solid rgba(139, 115, 85, 0.1);
    padding-top: 10px;
}

/* ====================================
   SECTION 5: BACK PAGE
   ==================================== */
.back-page {
    border-top: 2px solid rgba(139, 115, 85, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.back-page-content {
    max-width: 600px;
    text-align: center;
    opacity: 0;
    transition: opacity 1200ms ease;
}

.back-page-content.visible {
    opacity: 1;
}

.closing-text {
    font-family: 'Noto Sans KR', sans-serif;
    font-weight: 300;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: var(--dark-roast);
    line-height: 2;
    margin-bottom: 30px;
}

.closing-kr {
    font-family: 'Noto Serif KR', serif;
    font-weight: 700;
    font-size: clamp(1.2rem, 2vw, 1.6rem);
    color: var(--espresso-ink);
    letter-spacing: 0.04em;
}

.coffee-ring-container {
    position: absolute;
    bottom: 15%;
    right: 15%;
}

.coffee-ring-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 2s ease;
}

.coffee-ring-path.drawn {
    stroke-dashoffset: 0;
}

.coffee-ring-path.pulse {
    animation: ring-pulse 4s ease-in-out infinite;
}

@keyframes ring-pulse {
    0%, 100% {
        stroke-opacity: 0.08;
    }
    50% {
        stroke-opacity: 0.12;
    }
}

.colophon {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--worn-brass);
    letter-spacing: 0.1em;
}

/* ====================================
   COLUMN RULES (progressive)
   ==================================== */
.market-narrative,
.price-inventory {
    position: relative;
}

.market-narrative::after,
.price-inventory::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 0;
    background-color: rgba(139, 115, 85, 0.2);
    transition: height 600ms ease;
}

.market-report.in-view .market-narrative::after {
    height: 100%;
    transition-delay: 0ms;
}

.market-report.in-view .price-inventory::after {
    height: 100%;
    transition-delay: 200ms;
}

/* ====================================
   MAGNETIC SEAL EFFECT (handled by JS)
   ==================================== */

/* ====================================
   RESPONSIVE
   ==================================== */
@media (max-width: 1024px) {
    .classifieds-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .market-grid {
        grid-template-columns: 1fr 1fr;
    }

    .market-marginalia {
        grid-column: 1 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        padding-top: 30px;
        padding-left: 0;
        border-top: 1px solid rgba(139, 115, 85, 0.1);
    }
}

@media (max-width: 768px) {
    .masthead-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
    }

    .dateline-column {
        grid-column: 1;
        grid-row: 1;
        border-right: none;
        border-bottom: 1px solid rgba(139, 115, 85, 0.2);
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px 0;
        gap: 12px;
    }

    .masthead-character-area {
        grid-column: 1;
        grid-row: 2;
        padding-left: 0;
    }

    .banner-headline {
        grid-column: 1;
        grid-row: 3;
    }

    .masthead-subtitle {
        grid-column: 1;
        grid-row: 4;
    }

    .banner-text {
        font-size: clamp(1.4rem, 6vw, 2.5rem);
        white-space: normal;
    }

    .market-grid {
        grid-template-columns: 1fr;
    }

    .market-narrative {
        border-right: none;
        padding-right: 0;
        border-bottom: 1px solid rgba(139, 115, 85, 0.1);
        padding-bottom: 30px;
    }

    .price-inventory {
        border-right: none;
        padding: 20px 0;
        border-bottom: 1px solid rgba(139, 115, 85, 0.1);
    }

    .market-marginalia {
        padding-left: 0;
        padding-top: 20px;
    }

    .commentary-grid {
        grid-template-columns: 40px 1fr 40px;
        gap: 15px;
    }

    .classifieds-grid {
        grid-template-columns: 1fr;
    }

    .section-nav {
        font-size: 0.6rem;
        gap: 0;
    }

    .nav-item {
        padding: 0 6px;
    }
}

@media (max-width: 480px) {
    .page {
        padding: 50px 4vw 30px;
    }

    .commentary-grid {
        grid-template-columns: 1fr;
    }

    .seal-margin {
        flex-direction: row;
        padding-top: 0;
        gap: 20px;
    }

    .seal-margin-left {
        order: -1;
    }

    .seal-margin-right {
        order: 3;
    }

    .commentary-content {
        padding: 0;
    }

    .pull-quote-wrapper {
        padding: 20px 30px;
    }

    .pull-quote-mark {
        font-size: 3rem;
    }
}
