/* ============================================================
   opensource.bar — Cottagecore Open Source
   Palette: Parchment #f5ead0, Walnut Ink #3e2714, Tawny #d4b896,
            Moss #4a6741, Dried Rose #a65d57, Brass #b8923e,
            Deep Bark #2a1a0e, Cream #faf6eb
   Fonts: Cormorant Garamond, Lora, Inconsolata
   ============================================================ */

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

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

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: #3e2714;
    background-color: #f5ead0;
    overflow-x: hidden;
    position: relative;
}

/* --- Parchment Desk Surface --- */
.desk-surface {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
    background-color: #f5ead0;
    background-image:
        radial-gradient(ellipse 600px 400px at 20% 30%, rgba(180, 160, 120, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 70% 60%, rgba(180, 160, 120, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 300px 500px at 50% 80%, rgba(180, 160, 120, 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 500px 200px at 85% 15%, rgba(180, 160, 120, 0.05) 0%, transparent 70%),
        radial-gradient(ellipse 250px 350px at 10% 70%, rgba(180, 160, 120, 0.06) 0%, transparent 70%);
}

.desk-surface::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cline x1='0' y1='20' x2='200' y2='25' stroke='rgba(160,140,110,0.04)' stroke-width='0.5'/%3E%3Cline x1='0' y1='55' x2='200' y2='50' stroke='rgba(160,140,110,0.03)' stroke-width='0.5'/%3E%3Cline x1='0' y1='88' x2='200' y2='92' stroke='rgba(160,140,110,0.04)' stroke-width='0.5'/%3E%3Cline x1='0' y1='130' x2='200' y2='126' stroke='rgba(160,140,110,0.03)' stroke-width='0.5'/%3E%3Cline x1='0' y1='168' x2='200' y2='172' stroke='rgba(160,140,110,0.04)' stroke-width='0.5'/%3E%3Cline x1='30' y1='0' x2='28' y2='200' stroke='rgba(160,140,110,0.02)' stroke-width='0.5'/%3E%3Cline x1='95' y1='0' x2='97' y2='200' stroke='rgba(160,140,110,0.02)' stroke-width='0.5'/%3E%3Cline x1='160' y1='0' x2='158' y2='200' stroke='rgba(160,140,110,0.02)' stroke-width='0.5'/%3E%3C/svg%3E");
    background-repeat: repeat;
    opacity: 1;
}

/* --- Typography --- */
h1, h2, h3 {
    font-family: 'Cormorant Garamond', serif;
    letter-spacing: 0.02em;
    line-height: 1.15;
}

h2.section-title {
    font-size: clamp(1.4rem, 3vw, 2.4rem);
    font-weight: 600;
    color: #3e2714;
    text-align: center;
    margin-top: 0.5em;
}

.workshop-title {
    color: #f5ead0;
}

code, .code-block {
    font-family: 'Inconsolata', monospace;
    font-weight: 400;
    font-size: 0.92em;
}

p code {
    background: rgba(62, 39, 20, 0.06);
    border-radius: 3px;
    padding: 0.1em 0.35em;
}

/* --- Main Content --- */
.content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2.5rem);
    padding-right: clamp(1rem, 4vw, 2.5rem);
}

@media (min-width: 1200px) {
    .content {
        margin-left: calc(50% - 500px);
        margin-right: auto;
    }
}

/* --- Document Panels --- */
.document-panel {
    position: relative;
    background: linear-gradient(160deg, #f5ead0 0%, #ebe0c8 100%);
    border-radius: 4px;
    padding: clamp(2rem, 5vw, 4rem);
    margin-bottom: -8%;
    box-shadow: 4px 6px 20px rgba(62, 39, 20, 0.15), inset 0 0 40px rgba(62, 39, 20, 0.08);
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    opacity: 0;
    transform: translateY(60px) scale(0.97);
    transition: none;
    clip-path: polygon(
        0% 2%, 2% 0.5%, 5% 1.8%, 8% 0.3%, 12% 1.5%, 16% 0.8%, 20% 2%, 24% 0.2%,
        28% 1.6%, 32% 0.6%, 36% 1.9%, 40% 0.4%, 44% 1.7%, 48% 0.5%, 52% 2.1%,
        56% 0.3%, 60% 1.4%, 64% 0.7%, 68% 2%, 72% 0.2%, 76% 1.8%, 80% 0.5%,
        84% 1.6%, 88% 0.3%, 92% 1.9%, 96% 0.6%, 100% 1.2%,
        100% 100%, 0% 100%
    );
}

.document-panel.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Micro-rotations for each panel */
.hero-panel {
    transform: translateY(100vh) rotate(-1.2deg);
    opacity: 1;
    z-index: 10;
    min-height: 100vh;
    margin-bottom: 0;
}

.hero-panel.visible {
    transform: translateY(0) rotate(-1.2deg);
}

.commons-panel {
    z-index: 9;
}

.commons-panel.visible {
    transform: translateY(0) scale(1) rotate(0.6deg);
}

.garden-panel {
    z-index: 8;
}

.garden-panel.visible {
    transform: translateY(0) scale(1) rotate(-0.8deg);
}

.workshop-panel {
    z-index: 7;
    background: #2a1a0e;
    color: #f5ead0;
    box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.3), inset 0 0 60px rgba(0, 0, 0, 0.2);
    clip-path: none;
    border-radius: 2px;
}

.workshop-panel.visible {
    transform: translateY(0) scale(1) rotate(0.4deg);
}

.hearth-panel {
    z-index: 6;
    margin-bottom: 4rem;
}

.hearth-panel.visible {
    transform: translateY(0) scale(1) rotate(-0.3deg);
}

/* --- Hover-Lift Effect --- */
.document-panel.visible:hover {
    transform: translateY(-4px) rotate(0deg) !important;
    box-shadow: 6px 10px 30px rgba(62, 39, 20, 0.22);
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.document-panel.visible {
    transition: transform 500ms ease-out, box-shadow 500ms ease-out;
}

/* --- Panel Decorations --- */
.panel-corner-flourish {
    position: absolute;
    width: 40px;
    height: 40px;
    z-index: 2;
}

.panel-corner-flourish.top-left {
    top: 8px;
    left: 8px;
}

.panel-corner-flourish.top-right {
    top: 8px;
    right: 8px;
}

.pin {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    z-index: 3;
}

.brass-pin {
    background: radial-gradient(circle at 35% 35%, #d4a84a, #b8923e 50%, #8a6b2e);
    box-shadow: 1px 1px 3px rgba(62, 39, 20, 0.3);
}

.top-pin {
    top: 16px;
    left: 50%;
    margin-left: -6px;
}

.left-pin {
    left: 24px;
    margin-left: 0;
}

.right-pin-offset {
    left: auto;
    right: 24px;
    margin-left: 0;
}

.tape-strip {
    position: absolute;
    width: 60px;
    height: 18px;
    background: rgba(212, 195, 160, 0.55);
    border: 1px solid rgba(184, 146, 62, 0.2);
    z-index: 3;
    top: 10px;
    left: 50%;
    margin-left: -30px;
}

.tape-strip.right-tape {
    left: auto;
    right: 30px;
    margin-left: 0;
    transform: rotate(15deg);
}

/* --- Section Headers --- */
.section-header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-rule {
    width: min(100%, 400px);
    height: 20px;
    display: block;
    margin: 0 auto 0.3rem;
}

/* --- Hero Section --- */
.hero-title {
    font-size: clamp(2.5rem, 7vw, 6rem);
    font-weight: 700;
    color: #3e2714;
    text-align: center;
    margin-bottom: 0.3em;
}

@supports (font-variation-settings: 'wght' 400) {
    .hero-title {
        font-variation-settings: 'wght' clamp(400, calc(350 + 50), 700);
    }
}

.hero-subtitle {
    font-family: 'Lora', serif;
    font-style: italic;
    font-size: clamp(1rem, 2.2vw, 1.3rem);
    color: #4a6741;
    text-align: center;
    min-height: 2em;
    letter-spacing: 0.02em;
}

.peek-hint {
    position: absolute;
    bottom: -20px;
    right: 40px;
    width: 120px;
    height: 30px;
    background: linear-gradient(160deg, #ebe0c8, #f5ead0);
    border-radius: 0 0 3px 3px;
    box-shadow: 2px 4px 10px rgba(62, 39, 20, 0.12);
    opacity: 0;
    transition: opacity 1s ease-in;
    z-index: -1;
}

.peek-hint.show {
    opacity: 1;
}

/* --- The Commons --- */
.commons-text {
    max-width: 38em;
    margin: 0 auto;
}

.commons-text p {
    margin-bottom: 1.4em;
}

.drop-cap {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 3.5em;
    float: left;
    line-height: 0.8;
    margin-right: 0.08em;
    margin-top: 0.05em;
    color: #a65d57;
}

/* --- The Garden: Seed Cards --- */
.seed-packets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
}

.seed-card {
    position: relative;
    background: linear-gradient(170deg, #faf6eb 0%, #f5ead0 100%);
    padding: 1.8rem 1.5rem;
    box-shadow: 3px 4px 14px rgba(62, 39, 20, 0.12);
    border-radius: 0 0 4px 4px;
    transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.seed-card:hover {
    transform: translateY(-3px) rotate(0deg) !important;
    box-shadow: 5px 8px 22px rgba(62, 39, 20, 0.18);
}

.seed-card-torn-edge {
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(170deg, #faf6eb, #f5ead0);
    clip-path: polygon(
        0% 100%, 0% 40%, 3% 70%, 6% 30%, 9% 65%, 12% 25%, 15% 60%,
        18% 35%, 21% 70%, 24% 20%, 27% 55%, 30% 40%, 33% 75%,
        36% 30%, 39% 60%, 42% 25%, 45% 70%, 48% 35%, 51% 65%,
        54% 20%, 57% 55%, 60% 40%, 63% 75%, 66% 30%, 69% 60%,
        72% 25%, 75% 70%, 78% 35%, 81% 65%, 84% 20%, 87% 55%,
        90% 40%, 93% 75%, 96% 30%, 100% 50%, 100% 100%
    );
}

.seed-icon {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
}

.seed-icon svg {
    width: 100%;
    height: 100%;
}

.seed-title {
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 600;
    color: #3e2714;
    text-align: center;
    margin-bottom: 0.6em;
}

.seed-text {
    font-size: clamp(0.88rem, 1.5vw, 0.98rem);
    line-height: 1.65;
    color: #3e2714;
    text-align: center;
}

/* --- The Workshop --- */
.workshop-content {
    max-width: 38em;
    margin: 0 auto;
}

.workshop-text {
    color: #f5ead0;
    margin: 1.8em 0;
    max-width: 38em;
}

.code-block {
    background: rgba(245, 234, 208, 0.06);
    border-left: 3px solid #b8923e;
    padding: 1.2rem 1.5rem;
    border-radius: 0 4px 4px 0;
    margin: 1.5rem 0;
    overflow-x: auto;
}

.code-line {
    font-family: 'Inconsolata', monospace;
    font-size: clamp(0.85rem, 1.4vw, 0.95rem);
    line-height: 1.8;
    color: #f5ead0;
}

.code-line .kw {
    color: #a65d57;
}

.code-line .fn {
    color: #b8923e;
}

.code-line .str {
    color: #4a6741;
}

.code-line .flag {
    color: #d4b896;
}

.code-line.comment {
    color: rgba(245, 234, 208, 0.45);
    font-style: italic;
}

/* --- The Hearth --- */
.hearth-content {
    max-width: 38em;
    margin: 0 auto;
    text-align: center;
}

.hearth-text {
    margin-bottom: 1.5em;
    text-align: left;
}

.hearth-seal-container {
    display: flex;
    justify-content: center;
    margin: 3rem 0;
}

.signature-line {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid #d4b896;
    text-align: right;
}

.signature-text {
    display: block;
    font-family: 'Lora', serif;
    font-style: italic;
    color: #4a6741;
    font-size: 0.95em;
    margin-bottom: 0.3em;
}

.signature-name {
    display: block;
    font-family: 'Cormorant Garamond', serif;
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 600;
    color: #3e2714;
}

.garden-gate-illustration {
    margin: 3rem auto 1rem;
    max-width: 300px;
}

.garden-gate-illustration svg {
    width: 100%;
    height: auto;
}

/* --- Wax Seals --- */
.wax-seal {
    width: 60px;
    height: 60px;
    margin: 2.5rem auto 0;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 38%, #c06b65, #a65d57 45%, #8a4a45 100%);
    box-shadow: 2px 3px 8px rgba(62, 39, 20, 0.25), inset 0 -2px 4px rgba(0, 0, 0, 0.15), inset 0 2px 4px rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: scale(1.3);
    filter: blur(2px);
    opacity: 0;
    transition: none;
}

.wax-seal.stamped {
    transform: scale(1);
    filter: blur(0);
    opacity: 1;
}

.wax-seal svg {
    width: 28px;
    height: 28px;
}

.wax-seal.large-seal {
    width: 80px;
    height: 80px;
}

.wax-seal.large-seal svg {
    width: 38px;
    height: 38px;
}

.wax-seal-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.15), transparent 70%);
    pointer-events: none;
}

/* --- Navigation --- */
.nav-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    background: linear-gradient(135deg, #d4a84a, #b8923e);
    color: #f5ead0;
    padding: 0.8rem 0.4rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'Cormorant Garamond', serif;
    font-style: italic;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    cursor: pointer;
    border-radius: 4px 0 0 4px;
    box-shadow: -2px 2px 8px rgba(62, 39, 20, 0.2);
    transition: background 200ms ease;
    user-select: none;
}

.nav-tab:hover {
    background: linear-gradient(135deg, #c9a04a, #a6822e);
}

.nav-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 280px;
    height: 100vh;
    background: linear-gradient(170deg, #faf6eb, #f5ead0);
    box-shadow: -4px 0 20px rgba(62, 39, 20, 0.15);
    z-index: 99;
    transform: translateX(100%);
    transition: transform 400ms cubic-bezier(0.16, 1, 0.3, 1);
    padding: 3rem 2rem;
    overflow-y: auto;
}

.nav-panel.open {
    transform: translateX(0);
}

.nav-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #3e2714;
    margin-bottom: 1.5rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #d4b896;
}

.nav-links {
    list-style: none;
}

.nav-links li {
    margin-bottom: 1rem;
}

.nav-links a {
    font-family: 'Lora', serif;
    font-style: italic;
    color: #4a6741;
    text-decoration: none;
    font-size: 1.05rem;
    transition: color 200ms ease;
    position: relative;
    display: inline-block;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: #a65d57;
    transition: width 300ms ease;
}

.nav-links a:hover {
    color: #a65d57;
}

.nav-links a:hover::after {
    width: 100%;
}

.nav-flourish {
    margin-top: 2rem;
    text-align: center;
}

.nav-ornament {
    width: 120px;
    height: 20px;
}

/* --- Margin Notes --- */
.margin-notes {
    display: none;
}

@media (min-width: 1200px) {
    .margin-notes {
        display: block;
        position: fixed;
        right: 40px;
        top: 50%;
        transform: translateY(-50%);
        width: 200px;
        z-index: 5;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M8 0 L16 8 L8 16 L0 8 Z' fill='none' stroke='%23d4b896' stroke-width='0.5' opacity='0.2'/%3E%3Ccircle cx='8' cy='8' r='1' fill='%23d4b896' opacity='0.25'/%3E%3C/svg%3E");
        padding: 1.5rem;
        border-radius: 4px;
    }

    .margin-note {
        text-align: center;
        margin-bottom: 2rem;
        opacity: 0;
        transition: opacity 400ms ease 1.5s;
    }

    .margin-note.note-visible {
        opacity: 1;
    }

    .botanical-drawing {
        width: 60px;
        height: auto;
        margin: 0 auto 0.5rem;
        display: block;
    }

    .botanical-drawing path,
    .botanical-drawing circle,
    .botanical-drawing line {
        stroke-dasharray: 200;
        stroke-dashoffset: 200;
        transition: stroke-dashoffset 1.5s ease-in-out;
    }

    .margin-note.note-visible .botanical-drawing path,
    .margin-note.note-visible .botanical-drawing circle,
    .margin-note.note-visible .botanical-drawing line {
        stroke-dashoffset: 0;
    }

    .margin-label {
        font-family: 'Lora', serif;
        font-style: italic;
        font-size: 0.78rem;
        color: #4a6741;
        display: block;
        opacity: 0;
        transition: opacity 400ms ease;
    }

    .margin-note.note-visible .margin-label {
        opacity: 1;
        transition-delay: 1.9s;
    }
}

/* --- Links --- */
a {
    color: #4a6741;
    text-decoration: underline;
    text-decoration-color: rgba(74, 103, 65, 0.3);
    text-underline-offset: 3px;
    transition: color 200ms ease, text-decoration-color 200ms ease;
}

a:hover {
    color: #a65d57;
    text-decoration-color: #a65d57;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    .document-panel {
        padding: clamp(1.5rem, 4vw, 2.5rem);
        min-height: 70vh;
    }

    .seed-packets {
        grid-template-columns: 1fr;
    }

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

/* --- Variable-Fluid Weights (where supported) --- */
@supports (font-variation-settings: 'wght' 400) {
    h1 {
        font-variation-settings: 'wght' 700;
    }

    h2 {
        font-variation-settings: 'wght' 600;
    }

    h3 {
        font-variation-settings: 'wght' 600;
    }
}
