/* bada.quest - Nautical Treasure Map / RPG Quest Log */
/* Colors: #E8D5B0 #3C2A1A #C9A24D #1B3A3F #8B3A2A #6B8FA3 #8B7745 #5A5A52 */

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

body {
    font-family: 'Crimson Text', serif;
    font-weight: 400;
    font-size: clamp(0.95rem, 1.1vw, 1.05rem);
    line-height: 1.75;
    background: #E8D5B0;
    color: #3C2A1A;
    overflow-x: hidden;
    position: relative;
}

/* ===== Parchment Texture ===== */
body::before {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background:
        repeating-linear-gradient(
            to bottom,
            transparent,
            transparent 39px,
            rgba(201,162,77,0.03) 39px,
            rgba(201,162,77,0.03) 40px
        ),
        radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(60,42,26,0.08) 100%);
    pointer-events: none;
    z-index: 0;
}

/* SVG grain overlay */
body::after {
    content: '';
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    filter: url(#paper-grain);
    background: #E8D5B0;
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

/* ===== Compass Watermark ===== */
#compass-watermark {
    position: fixed;
    top: 50%;
    right: 5%;
    transform: translateY(-50%);
    z-index: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s ease;
}

#compass-watermark.visible {
    opacity: 1;
}

/* ===== Continuous Route Line ===== */
#route-line-svg {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.2;
}

/* ===== Quest Sections ===== */
.quest-section {
    position: relative;
    z-index: 1;
    padding: 4rem 2rem;
}

/* ===== Hero: Chart Room ===== */
#hero {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.hero-content {
    position: relative;
    z-index: 2;
}

.quest-title {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 4rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3C2A1A;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 1.5s ease, transform 1.5s ease;
}

.quest-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.quest-subtitle {
    font-family: 'Caveat Brush', cursive;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: #5A5A52;
    margin-top: 1rem;
    letter-spacing: 0.05em;
    opacity: 0;
    transition: opacity 1s ease 0.8s, transform 1s ease 0.8s;
    transform: translateY(10px) rotate(-1deg);
}

.quest-subtitle.visible {
    opacity: 1;
    transform: translateY(0) rotate(-1deg);
}

.ornamental-flourish {
    display: flex;
    justify-content: center;
    margin: 0.75rem 0;
    opacity: 0;
    transition: opacity 1s ease 1.2s;
}

.ornamental-flourish.visible {
    opacity: 1;
}

.hero-note {
    margin-top: 1rem;
    opacity: 0;
    transition: opacity 1s ease 1.8s;
}

.hero-note.visible {
    opacity: 0.6;
}

.scroll-indicator {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    animation: fadeInScroll 1s ease 2.5s forwards;
}

@keyframes fadeInScroll {
    to { opacity: 1; }
}

.scroll-dot {
    animation: scrollDotBounce 2s ease-in-out infinite;
}

@keyframes scrollDotBounce {
    0%, 100% { cy: 10; }
    50% { cy: 22; opacity: 0.2; }
}

/* ===== Handwritten Notes ===== */
.handwritten-note {
    font-family: 'Caveat Brush', cursive;
    font-size: clamp(0.9rem, 1.2vw, 1.1rem);
    color: #8B3A2A;
    opacity: 0.6;
}

/* ===== Section Headings ===== */
.section-heading-wrap {
    text-align: center;
    margin-bottom: 2.5rem;
}

.section-heading {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: clamp(1.1rem, 2vw, 1.6rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #3C2A1A;
    text-align: center;
    position: relative;
}

/* ===== Island Stop Markers ===== */
.island-stop {
    display: flex;
    justify-content: center;
    padding: 1rem 0;
    position: relative;
    z-index: 2;
}

.island-marker-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #C9A24D;
    background: #E8D5B0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(60,42,26,0.12);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.island-marker-circle.visible {
    opacity: 1;
    transform: scale(1);
}

.island-marker-circle.pulse {
    animation: islandPulse 2s ease-in-out infinite alternate;
}

@keyframes islandPulse {
    from { transform: scale(1); }
    to { transform: scale(1.05); }
}

.island-numeral {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: 1rem;
    color: #8B3A2A;
    letter-spacing: 0.05em;
}

/* ===== Voyage Map ===== */
.route-container {
    max-width: 900px;
    margin: 0 auto;
    background: rgba(232,213,176,0.5);
    border: 2px solid rgba(107,143,163,0.5);
    border-radius: 4px;
    padding: 1rem;
    box-shadow: 0 6px 24px rgba(60,42,26,0.12), inset 0 0 0 1px rgba(27,58,63,0.15);
    position: relative;
}

#route-svg {
    width: 100%;
    height: auto;
}

.route-line {
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 3s ease;
}

.route-line.drawn {
    stroke-dashoffset: 0;
}

.island-marker {
    cursor: pointer;
}

.island-marker circle:first-child {
    transition: r 0.3s ease, stroke-width 0.3s ease;
}

.map-annotation {
    text-align: right;
    margin-top: 0.75rem;
    font-size: 0.95rem;
    transform: rotate(-0.5deg);
}

/* ===== Broken Grid: Navigator's Desk ===== */
.broken-grid {
    max-width: 900px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    position: relative;
}

/* Overlap effects */
.broken-grid .desk-card:nth-child(1) { transform: rotate(-1.5deg); z-index: 3; }
.broken-grid .desk-card:nth-child(2) { transform: rotate(1deg); margin-top: 2rem; z-index: 2; }
.broken-grid .desk-card:nth-child(3) { transform: rotate(0.5deg); margin-top: -1.5rem; z-index: 4; }
.broken-grid .desk-card:nth-child(4) { transform: rotate(-0.8deg); margin-top: 1rem; z-index: 1; }
.broken-grid .desk-card:nth-child(5) { transform: rotate(1.2deg); margin-top: -1rem; z-index: 5; }
.broken-grid .desk-card:nth-child(6) { transform: rotate(-0.5deg); margin-top: 2.5rem; z-index: 2; }

.desk-card {
    padding: 1.5rem;
    box-shadow: 4px 8px 24px rgba(60,42,26,0.15), 2px 4px 8px rgba(60,42,26,0.08);
    position: relative;
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.desk-card.visible {
    opacity: 1;
}

/* Card type: Parchment Scroll */
.scroll-card {
    background: linear-gradient(135deg, #E8D5B0, #DCC89E);
    border: 1px solid rgba(139,119,69,0.4);
    border-radius: 12px 12px 4px 4px;
}

.scroll-card::before,
.scroll-card::after {
    content: '';
    position: absolute;
    left: 10%; right: 10%;
    height: 6px;
    background: rgba(60,42,26,0.06);
    border-radius: 50%;
}

.scroll-card::before { top: -3px; }
.scroll-card::after { bottom: -3px; }

/* Card type: Logbook Entry */
.logbook-card {
    background: #F0E8D8;
    border: 1px solid rgba(139,119,69,0.3);
    border-radius: 2px;
}

.logbook-margin {
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 40px;
    border-right: 2px solid rgba(139,58,42,0.25);
    background: rgba(139,58,42,0.03);
}

.logbook-content {
    padding-left: 2.5rem;
}

.log-date {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8B7745;
    display: block;
    margin-bottom: 0.5rem;
}

/* Card type: Sealed Letter */
.letter-card {
    background: linear-gradient(160deg, #EDE0C8, #E2D3B8);
    border: 1px solid rgba(139,119,69,0.35);
    clip-path: polygon(0 0, calc(100% - 28px) 0, 100% 28px, 100% 100%, 0 100%);
    border-radius: 2px;
}

.folded-corner {
    position: absolute;
    top: 0;
    right: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(225deg, #E8D5B0 50%, #D4C49E 50%);
    box-shadow: -2px 2px 4px rgba(60,42,26,0.1);
}

.wax-seal {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
}

/* Card type: Brass Panel */
.brass-card {
    background: linear-gradient(145deg, #C4A853, #A89040, #C4A853);
    border: 2px solid #8B7745;
    border-radius: 3px;
    color: #3C2A1A;
}

.rivet {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #D4B860, #8B7745);
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.2);
}

.rivet.top-left { top: 8px; left: 8px; }
.rivet.top-right { top: 8px; right: 8px; }
.rivet.bottom-left { bottom: 8px; left: 8px; }
.rivet.bottom-right { bottom: 8px; right: 8px; }

.instrument-data {
    margin-top: 0.75rem;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(60,42,26,0.15);
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    letter-spacing: 0.04em;
}

.data-label {
    font-weight: 600;
    color: #3C2A1A;
}

.data-value {
    color: #1B3A3F;
    font-weight: 600;
}

/* ===== Card Headings ===== */
.card-heading {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.6vw, 1.25rem);
    color: #3C2A1A;
    letter-spacing: 0.06em;
    margin-bottom: 0.75rem;
}

.card-body {
    font-family: 'Crimson Text', serif;
    font-size: clamp(0.9rem, 1vw, 1rem);
    line-height: 1.75;
    color: #5A5A52;
}

.card-note {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.95rem;
}

/* ===== Card Reveal Animations ===== */
.card-reveal {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.card-reveal[data-direction="left"] {
    transform: translateX(-30px) rotate(-2deg);
}

.card-reveal[data-direction="right"] {
    transform: translateX(30px) rotate(1deg);
}

.card-reveal[data-direction="up"] {
    transform: translateY(30px);
}

.card-reveal.visible[data-direction="left"] {
    opacity: 1;
}

.card-reveal.visible[data-direction="right"] {
    opacity: 1;
}

.card-reveal.visible[data-direction="up"] {
    opacity: 1;
    transform: translateY(0);
}

/* ===== Treasures ===== */
.treasures-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    max-width: 850px;
    margin: 0 auto;
}

.treasure-card {
    background: rgba(232,213,176,0.6);
    border: 1px solid #C9A24D;
    border-radius: 4px;
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: 0 4px 16px rgba(60,42,26,0.1);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.treasure-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(60,42,26,0.18);
}

.treasure-icon {
    margin-bottom: 1rem;
}

.treasure-name {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 1rem;
    color: #3C2A1A;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.treasure-desc {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 0.9rem;
    color: #5A5A52;
    line-height: 1.6;
    margin-bottom: 0.75rem;
}

/* ===== Captain's Log (Footer) ===== */
#captains-log {
    padding: 4rem 2rem 3rem;
}

.log-entries {
    max-width: 700px;
    margin: 0 auto;
    position: relative;
}

.log-entries::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(to bottom, #C9A24D 0px, #C9A24D 6px, transparent 6px, transparent 10px);
}

.log-entry {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.log-entry.visible {
    opacity: 1;
    transform: translateX(0);
}

.entry-marker {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #C9A24D;
    background: #E8D5B0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.day-number {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: 0.9rem;
    color: #8B3A2A;
}

.entry-content {
    flex: 1;
    padding-top: 0.25rem;
}

.entry-date {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8B7745;
    display: block;
    margin-bottom: 0.25rem;
}

.entry-title {
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    color: #3C2A1A;
    margin-bottom: 0.5rem;
    letter-spacing: 0.03em;
}

.entry-text {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 0.95rem;
    line-height: 1.8;
    color: #5A5A52;
    margin-bottom: 0.5rem;
}

.entry-coords {
    font-family: 'Caveat Brush', cursive;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    color: #8B7745;
}

/* ===== Footer Close ===== */
.footer-close {
    text-align: center;
    margin-top: 3rem;
    padding-top: 2rem;
}

.footer-domain {
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    color: #3C2A1A;
    letter-spacing: 0.1em;
    margin-top: 1.5rem;
}

.footer-motto {
    font-family: 'Crimson Text', serif;
    font-style: italic;
    font-size: 0.95rem;
    color: #6B8FA3;
    margin-top: 0.5rem;
    letter-spacing: 0.03em;
}

.footer-note {
    margin-top: 1rem;
    display: inline-block;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .broken-grid {
        grid-template-columns: 1fr;
    }

    .broken-grid .desk-card:nth-child(n) {
        transform: none;
        margin-top: 0;
    }

    .treasures-grid {
        grid-template-columns: 1fr;
        max-width: 400px;
    }

    .log-entries::before {
        left: 18px;
    }

    .entry-marker {
        width: 38px;
        height: 38px;
    }

    .day-number {
        font-size: 0.75rem;
    }

    #compass-watermark {
        display: none;
    }

    .logbook-margin {
        width: 28px;
    }

    .logbook-content {
        padding-left: 2rem;
    }
}

@media (max-width: 480px) {
    .quest-section {
        padding: 2.5rem 1rem;
    }

    .island-marker-circle {
        width: 48px;
        height: 48px;
    }
}
