/* ============================================
   perso.news — Skeuomorphic Editorial Design
   ============================================ */

/* 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;
    color: #3b2a1a;
    background: #f4efe6;
    line-height: 1.72;
    overflow-x: hidden;
}

/* ---- MASTHEAD ---- */
.masthead {
    position: relative;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4efe6;
    background-image: radial-gradient(ellipse at 30% 20%, rgba(180,160,130,0.08), transparent);
    overflow: hidden;
}

.masthead-grain {
    position: absolute;
    inset: 0;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    pointer-events: none;
}

.masthead-content {
    text-align: center;
    z-index: 1;
}

.masthead-title {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(2.8rem, 6vw, 5.5rem);
    color: #3b2a1a;
    letter-spacing: -0.02em;
    line-height: 1.15;
    text-shadow:
        1px 1px 0 rgba(244,239,230,0.8),
        -1px -1px 0 rgba(42,31,20,0.15);
    margin-bottom: 1.5rem;
}

.ornamental-divider {
    display: block;
    margin: 0 auto 1.5rem;
    max-width: 90vw;
}

.divider-path {
    stroke-dasharray: 800;
    stroke-dashoffset: 800;
    animation: draw-divider 1.8s ease-out 1.2s forwards;
}

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

.masthead-tagline {
    font-family: 'Caveat', cursive;
    font-size: clamp(1.1rem, 2vw, 1.5rem);
    color: #8b7355;
    font-weight: 400;
    margin-bottom: 0.8rem;
}

.masthead-date {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a0937e;
}

/* ---- BROADSHEET ---- */
.broadsheet {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 0 48px;
    padding: 80px clamp(24px, 5vw, 80px);
    align-items: start;
    background: #f8f4ed;
    position: relative;
    min-height: 250vh;
}

.broadsheet::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.04;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='4'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    pointer-events: none;
}

.broadsheet-main {
    position: relative;
    z-index: 1;
}

/* Column rules */
.broadsheet-main::after {
    content: '';
    position: absolute;
    top: 0;
    right: -24px;
    bottom: 0;
    width: 1px;
    border-right: 1px dashed #c5b9a4;
}

/* ---- STORY CARDS ---- */
.story-card {
    position: relative;
    margin-bottom: 48px;
    padding: 0;
    background: #f4efe6;
    transform: rotate(-0.4deg);
    /* Torn edge simulation */
    clip-path: polygon(
        0% 2%, 3% 0%, 8% 1%, 15% 0%, 22% 1.5%, 30% 0%, 38% 0.5%, 45% 0%, 52% 1%, 60% 0%, 68% 0.8%, 75% 0%, 82% 1.2%, 90% 0%, 95% 0.5%, 100% 0%,
        100% 98%, 97% 100%, 92% 99%, 85% 100%, 78% 98.5%, 70% 100%, 62% 99.5%, 55% 100%, 48% 99%, 40% 100%, 32% 99.2%, 25% 100%, 18% 98.8%, 10% 100%, 5% 99.5%, 0% 100%
    );
}

.story-card--lead {
    transform: rotate(0deg);
}

.story-card--rotated {
    transform: rotate(0.3deg);
}

.story-card--rotated-alt {
    transform: rotate(-0.6deg);
}

.story-card .border-trace {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

.story-card .border-trace rect {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    transition: stroke-dashoffset 0.8s ease-out;
}

.story-card.visible .border-trace rect {
    stroke-dashoffset: 0;
}

.story-card__inner {
    padding: 32px 36px;
    /* Fold crease */
    background-image: linear-gradient(transparent 48%, rgba(59,42,26,0.06) 50%, transparent 52%);
}

.story-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.gear-icon {
    animation: spin 8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.story-category {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a0937e;
}

.story-time,
.story-date {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    color: #a0937e;
}

.story-headline {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #3b2a1a;
    margin-bottom: 16px;
}

.story-card--lead .story-headline {
    font-weight: 900;
}

.story-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    color: #3b2a1a;
    max-width: 38em;
    margin-bottom: 20px;
}

.story-headline a {
    color: #5e8a7a;
    text-decoration: none;
}

.story-headline a:hover {
    color: #b87333;
}

.story-illustration {
    margin-top: 12px;
}

.story-illustration svg {
    max-width: 100%;
}

/* Illustration stroke animation */
.illust-stroke {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.2s ease-out;
}

.visible .illust-stroke,
.illustration.visible .illust-stroke {
    stroke-dashoffset: 0;
}

/* ---- DIVIDER RULES ---- */
.divider-rule {
    display: flex;
    justify-content: center;
    margin: 24px 0 36px;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.divider-rule.visible {
    opacity: 1;
}

.divider-rule .divider-line {
    stroke-dasharray: 400;
    stroke-dashoffset: 400;
    transition: stroke-dashoffset 0.8s ease-out;
}

.divider-rule.visible .divider-line {
    stroke-dashoffset: 0;
}

/* ---- MARGINALIA ---- */
.marginalia {
    position: sticky;
    top: 40px;
    padding-top: 40px;
    z-index: 1;
}

.circuit-traces {
    position: absolute;
    top: 0;
    left: -24px;
    bottom: 0;
    width: calc(100% + 24px);
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='800'%3E%3Cpath d='M160,0 L160,100 L200,150 L200,300 L120,350 L120,500 L180,550 L180,700 L160,800' stroke='%23c5b9a4' stroke-width='1' fill='none' opacity='0.12'/%3E%3Cpath d='M80,0 L80,200 L140,250 L140,400 L60,450 L60,600 L100,650 L100,800' stroke='%23c5b9a4' stroke-width='0.5' fill='none' opacity='0.08'/%3E%3C/svg%3E");
    background-size: 320px 800px;
}

.margin-note {
    font-family: 'Caveat', cursive;
    font-size: clamp(0.9rem, 1.5vw, 1.2rem);
    color: #8b7355;
    margin-bottom: 36px;
    transform: rotate(-1deg);
    padding: 16px 12px;
    border-left: 2px solid rgba(184,115,51,0.3);
    position: relative;
}

.margin-annotation {
    line-height: 1.5;
}

.margin-attribution {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 0.9em;
    display: block;
    margin-top: 4px;
}

.margin-note--highlight {
    background: rgba(184,115,51,0.05);
    border-left-color: #b87333;
    padding: 16px;
}

.margin-note--highlight .gear-icon--large {
    display: block;
    margin-top: 8px;
}

.margin-note--aside {
    transform: rotate(0deg);
}

.margin-label {
    font-family: 'IBM Plex Mono', monospace;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a0937e;
    margin-bottom: 8px;
}

.margin-list {
    list-style: none;
    font-family: 'Caveat', cursive;
    font-size: 1rem;
    color: #8b7355;
}

.margin-list li {
    padding: 4px 0;
    border-bottom: 1px dotted rgba(184,115,51,0.2);
}

.margin-list li:last-child {
    border-bottom: none;
}

/* ---- FOLIO ---- */
.folio {
    min-height: 100vh;
    background: #ede5d5;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(59,42,26,0.03) 2px, rgba(59,42,26,0.03) 4px);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px clamp(24px, 5vw, 80px);
}

.folio-spread {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    max-width: 1100px;
    width: 100%;
    position: relative;
}

.folio-spine {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 80%;
    background: linear-gradient(90deg, rgba(59,42,26,0.15), rgba(59,42,26,0.06), rgba(59,42,26,0.15));
    border-radius: 3px;
    z-index: 2;
    transition: width 0.4s ease;
    pointer-events: none;
}

.folio:hover .folio-spine {
    width: 10px;
}

.folio-text {
    padding: 48px 60px 48px 40px;
}

.folio-label {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: clamp(0.7rem, 0.9vw, 0.85rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #b87333;
    display: block;
    margin-bottom: 16px;
}

.folio-headline {
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(1.5rem, 3.5vw, 2.8rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: #3b2a1a;
    margin-bottom: 24px;
}

.folio-body {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.72;
    color: #3b2a1a;
    max-width: 38em;
    margin-bottom: 1.2em;
}

.folio-illustration {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.folio-illustration svg {
    max-height: 500px;
}

/* ---- DESK (Footer) ---- */
.desk {
    min-height: 60vh;
    background: #2a1f14;
    background-image: repeating-linear-gradient(0deg, transparent, transparent 8px, rgba(255,255,255,0.02) 8px, rgba(255,255,255,0.02) 10px);
    position: relative;
    padding: 80px clamp(24px, 5vw, 80px);
}

.desk-surface {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    gap: 40px;
    align-items: start;
}

.desk-clock {
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
}

.desk-postcard {
    grid-column: 2;
    grid-row: 1 / 3;
    background: #f4efe6;
    padding: 32px;
    transform: rotate(1.5deg);
    position: relative;
    box-shadow: 4px 4px 20px rgba(0,0,0,0.3);
}

.postcard-inner {
    position: relative;
}

.postcard-title {
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: #3b2a1a;
    margin-bottom: 12px;
}

.postcard-text {
    font-family: 'Source Serif 4', Georgia, serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #8b7355;
    margin-bottom: 20px;
}

.postcard-form {
    display: flex;
    gap: 8px;
}

.postcard-input {
    flex: 1;
    border: 1px solid #c5b9a4;
    background: #f8f4ed;
    padding: 10px 14px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: #3b2a1a;
    outline: none;
}

.postcard-input::placeholder {
    color: #a0937e;
}

.postcard-input:focus {
    border-color: #b87333;
}

.postcard-button {
    background: #3b2a1a;
    color: #f4efe6;
    border: none;
    padding: 10px 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.3s ease;
}

.postcard-button:hover {
    background: #b87333;
}

.postcard-stamp {
    position: absolute;
    top: 20px;
    right: 20px;
}

.desk-tabs {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tab-folder {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 400;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #a0937e;
    background: #3b2a1a;
    padding: 10px 18px;
    text-decoration: none;
    border: 1px solid #5e4a35;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    transition: color 0.3s ease, background 0.3s ease;
}

.tab-folder:hover {
    color: #f4efe6;
    background: #5e4a35;
}

.desk-colophon {
    grid-column: 1 / -1;
    grid-row: 3;
    text-align: center;
    padding-top: 40px;
    border-top: 1px solid rgba(184,115,51,0.2);
}

.colophon-text {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: 300;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: #a0937e;
    margin-bottom: 6px;
}

/* ---- DATA THREADS ---- */
#data-threads line {
    stroke: #5e8a7a;
    stroke-width: 1;
    stroke-dasharray: 4 4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#data-threads line.active {
    opacity: 0.6;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
    .broadsheet {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .broadsheet-main::after {
        display: none;
    }

    .marginalia {
        position: relative;
        top: auto;
        padding-top: 40px;
        border-top: 1px dashed #c5b9a4;
        margin-top: 40px;
    }

    .circuit-traces {
        display: none;
    }

    .folio-spread {
        grid-template-columns: 1fr;
    }

    .folio-illustration {
        order: -1;
        padding: 20px;
    }

    .folio-text {
        padding: 24px 20px;
    }

    .desk-surface {
        grid-template-columns: 1fr;
    }

    .desk-postcard {
        grid-column: 1;
        grid-row: auto;
    }

    .desk-clock {
        justify-self: center;
    }
}

@media (max-width: 600px) {
    .story-card {
        transform: none;
        clip-path: none;
    }

    .story-card--rotated,
    .story-card--rotated-alt {
        transform: none;
    }

    .desk-postcard {
        transform: none;
    }

    .postcard-form {
        flex-direction: column;
    }
}
