@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,500;0,600;1,300;1,400;1,500&family=EB+Garamond:ital,wght@0,400;0,500;1,400;1,500&display=swap');

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

:root {
    --color-bg: #141211;
    --color-surface: #1e1c1a;
    --color-surface-raised: #262320;
    --color-text: #d8d0c4;
    --color-text-muted: #8a8078;
    --color-accent: #c9a96e;
    --color-accent-dim: rgba(201, 169, 110, 0.15);
    --color-divider: rgba(201, 169, 110, 0.08);
    --font-display: 'Cormorant Garamond', 'Georgia', serif;
    --font-body: 'EB Garamond', 'Georgia', serif;
}

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

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.75;
    -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════
   Gate page
   ═══════════════════════════════════════ */

.gate-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 50% 40%, rgba(201, 169, 110, 0.03) 0%, transparent 70%),
        var(--color-bg);
}

.gate-container {
    text-align: center;
    max-width: 420px;
    padding: 2rem;
}

.gate-container h1 {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 300;
    margin-bottom: 0.5rem;
    color: var(--color-accent);
    letter-spacing: 0.02em;
}

.gate-prompt {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--color-text-muted);
    margin-bottom: 2rem;
    font-style: italic;
    font-weight: 300;
}

#gate-form input {
    display: block;
    width: 100%;
    padding: 0.9rem 1.2rem;
    font-size: 1.1rem;
    font-family: var(--font-body);
    background: var(--color-surface);
    border: 1px solid rgba(201, 169, 110, 0.15);
    color: var(--color-text);
    border-radius: 2px;
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.03em;
    transition: border-color 0.3s ease;
}

#gate-form input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 20px rgba(201, 169, 110, 0.06);
}

#gate-form button {
    display: block;
    width: 100%;
    padding: 0.8rem;
    font-size: 0.85rem;
    font-family: var(--font-display);
    font-weight: 500;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#gate-form button:hover {
    background: var(--color-accent);
    color: var(--color-bg);
}

.gate-error {
    color: #c47070;
    margin-top: 1rem;
    font-size: 0.85rem;
    font-style: italic;
}

.gate-submit-link {
    margin-top: 3rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.05em;
}

.gate-submit-link a {
    color: var(--color-accent);
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 169, 110, 0.3);
    transition: border-color 0.2s;
}

.gate-submit-link a:hover {
    border-color: var(--color-accent);
}

/* ═══════════════════════════════════════
   Memorial page — layout
   ═══════════════════════════════════════ */

.memorial-page {
    background:
        radial-gradient(ellipse at 50% 0%, rgba(201, 169, 110, 0.02) 0%, transparent 50%),
        var(--color-bg);
}

.memorial-section {
    padding: 4rem 2rem;
    max-width: 900px;
    margin: 0 auto;
}

.memorial-section#intro {
    min-height: auto;
    padding-top: 6rem;
    padding-bottom: 4rem;
    text-align: center;
}

.memorial-section#outro {
    min-height: 60vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.intro-title {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 300;
    color: var(--color-accent);
    margin-bottom: 1rem;
    letter-spacing: 0.04em;
}

.intro-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-style: italic;
    color: var(--color-text-muted);
    max-width: 520px;
    margin: 0 auto;
    line-height: 1.8;
}

.era-section {
    padding-top: 8rem;
    padding-bottom: 8rem;
    position: relative;
}

.era-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-accent), transparent);
}

/* ═══════════════════════════════════════
   Era headers
   ═══════════════════════════════════════ */

.era-header {
    text-align: center;
    margin-bottom: 4rem;
}

.era-header h2 {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 300;
    color: var(--color-accent);
    margin-top: 1.5rem;
    letter-spacing: 0.04em;
}

.era-years {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    display: block;
    margin-top: 0.5rem;
}

/* ═══════════════════════════════════════
   Maps
   ═══════════════════════════════════════ */

.era-map {
    max-width: 280px;
    margin: 0 auto 1.5rem;
    opacity: 0;
    animation: mapFadeIn 1.5s ease-out forwards;
}

@keyframes mapFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.map-country {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 1.2;
    stroke-linejoin: round;
    opacity: 0.35;
    filter: drop-shadow(0 0 4px rgba(201, 169, 110, 0.1));
}

.map-country-detail {
    fill: none;
    stroke: var(--color-accent);
    stroke-width: 0.8;
    stroke-linejoin: round;
    stroke-dasharray: 4 3;
    opacity: 0.2;
}

.map-marker {
    fill: var(--color-accent);
    filter: drop-shadow(0 0 3px rgba(201, 169, 110, 0.6));
}

.map-marker-glow {
    fill: var(--color-accent);
    opacity: 0;
    animation: markerPulse 3.5s ease-in-out infinite;
}

@keyframes markerPulse {
    0%, 100% { opacity: 0; r: 6; }
    50% { opacity: 0.12; r: 16; }
}

.map-label {
    fill: var(--color-accent);
    font-family: var(--font-display);
    font-size: 11px;
    font-style: italic;
    letter-spacing: 0.05em;
}

.map-coords {
    fill: var(--color-text-muted);
    font-family: var(--font-body);
    font-size: 8px;
    letter-spacing: 0.12em;
    opacity: 0.4;
}

/* ═══════════════════════════════════════
   Narrative text
   ═══════════════════════════════════════ */

.narrative {
    max-width: 600px;
    margin: 0 auto;
}

.narrative p {
    font-family: var(--font-body);
    font-size: 1.05rem;
    line-height: 2;
    margin-bottom: 1.8rem;
    color: var(--color-text);
    text-indent: 0;
}

.narrative p:first-of-type::first-letter {
    font-family: var(--font-display);
    font-size: 3.2em;
    float: left;
    line-height: 0.8;
    margin-right: 0.08em;
    margin-top: 0.08em;
    color: var(--color-accent);
    font-weight: 300;
}

.narrative p strong,
.narrative p b {
    color: var(--color-accent);
    font-weight: 500;
}

.narrative p em {
    color: var(--color-text);
    font-style: italic;
}

.narrative-accent {
    font-family: var(--font-display) !important;
    font-size: 1.55rem !important;
    font-weight: 300 !important;
    color: var(--color-accent) !important;
    font-style: italic;
    text-align: center;
    text-indent: 0 !important;
    margin: 3.5rem 0 !important;
    line-height: 1.6 !important;
    letter-spacing: 0.01em;
}

.narrative-accent::first-letter {
    font-size: inherit !important;
    float: none !important;
    margin: 0 !important;
}

/* Year markers within narrative */
.narrative .year-marker {
    display: block;
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 400;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin: 4rem 0 2rem;
    position: relative;
}

.narrative .year-marker::before,
.narrative .year-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-accent));
}

.narrative .year-marker::before {
    right: calc(50% + 3.5em);
    background: linear-gradient(90deg, transparent, rgba(201, 169, 110, 0.3));
}

.narrative .year-marker::after {
    left: calc(50% + 3.5em);
    background: linear-gradient(270deg, transparent, rgba(201, 169, 110, 0.3));
}

/* Emotional emphasis - for key moments */
.narrative .moment {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 300;
    line-height: 1.8;
    color: var(--color-text);
    margin: 2.5rem 0;
    padding: 1.5rem 2rem;
    border-left: 2px solid var(--color-accent-dim);
    background: linear-gradient(90deg, var(--color-accent-dim), transparent 80%);
    text-indent: 0 !important;
}

.narrative .moment::first-letter {
    font-size: inherit !important;
    float: none !important;
    margin: 0 !important;
}

/* ═══════════════════════════════════════
   Media slots
   ═══════════════════════════════════════ */

.media-slot {
    margin: 3rem 0;
    padding: 0.5rem 0;
}

.media-gallery:empty::after,
.media-video:empty::after,
.media-slideshow:empty::after {
    content: attr(data-slot);
    display: block;
    padding: 3rem;
    text-align: center;
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-style: italic;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    border: 1px solid var(--color-divider);
    border-radius: 2px;
    opacity: 0.6;
}

.media-video video {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    display: block;
    border-radius: 2px;
}

.video-caption {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-style: italic;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* Horizontal slideshow */

.hslide {
    position: relative;
    overflow: hidden;
    border-radius: 2px;
}

.hslide-viewport {
    overflow: hidden;
}

.hslide-track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

.hslide-item {
    flex: 0 0 100%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
}

.hslide-item img,
.hslide-item video {
    max-width: 100%;
    max-height: 75vh;
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto;
    border-radius: 2px;
    object-fit: contain;
}

.hslide-prev,
.hslide-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    color: var(--color-text);
    border: none;
    width: 40px;
    height: 40px;
    font-size: 1.5rem;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 2;
}

.hslide:hover .hslide-prev,
.hslide:hover .hslide-next {
    opacity: 0.85;
}

.hslide-prev:hover,
.hslide-next:hover {
    background: rgba(0, 0, 0, 0.75);
}

.hslide-prev { left: 10px; }
.hslide-next { right: 10px; }

.hslide-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.hslide-pause {
    background: none;
    border: 1px solid #444;
    color: var(--color-text-muted);
    width: 28px;
    height: 28px;
    font-size: 0.65rem;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
}

.hslide-pause:hover {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.hslide-counter {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
}

/* ═══════════════════════════════════════
   Photo modal
   ═══════════════════════════════════════ */

.photo-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.photo-modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
}

.photo-modal-content {
    position: relative;
    display: flex;
    width: 100vw;
    height: 100vh;
    background: var(--color-bg);
    overflow: hidden;
    z-index: 1;
}

.photo-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.4);
    border-radius: 50%;
    font-size: 1.5rem;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
}

.photo-modal-prev,
.photo-modal-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 40px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}
.photo-modal-prev:hover,
.photo-modal-next:hover {
    background: rgba(0,0,0,0.85);
}
.photo-modal-prev { left: 12px; }
.photo-modal-next { right: 320px; }

.photo-modal-img-wrap {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.photo-modal-img-wrap img {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
}

.photo-modal-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #333;
}

.photo-modal-comments {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    font-size: 0.85rem;
}

.comment {
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.comment-nick {
    color: var(--color-accent);
    font-family: var(--font-display);
    font-weight: 500;
    margin-right: 0.4em;
}

.comment-text {
    color: var(--color-text);
}

.no-comments, .loading-comments {
    color: var(--color-text-muted);
    font-style: italic;
    font-family: var(--font-display);
    font-size: 0.8rem;
}

.photo-modal-form {
    display: flex;
    border-top: 1px solid #333;
    padding: 0.5rem;
    gap: 0.5rem;
}

.photo-modal-form input {
    flex: 1;
    background: var(--color-bg);
    border: 1px solid #333;
    color: var(--color-text);
    padding: 0.4rem 0.6rem;
    border-radius: 3px;
    font-size: 0.8rem;
    font-family: var(--font-body);
}

.photo-modal-form button {
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 3px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: var(--font-display);
}

.hslide-item {
    cursor: pointer;
    position: relative;
}

.hslide-item[data-media-type="video"] {
    cursor: default;
}

.hslide-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: var(--color-text);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    font-size: 1rem;
    line-height: 34px;
    text-align: center;
    cursor: pointer;
    z-index: 3;
    opacity: 0;
    transition: opacity 0.3s;
}

.hslide-item:hover .hslide-expand {
    opacity: 0.85;
}

.hslide-expand:hover {
    background: rgba(0, 0, 0, 0.85);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.hslide-caption {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: var(--color-accent);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-style: italic;
    padding: 0.3rem 0.6rem;
    border-radius: 2px;
    max-width: 60%;
    text-align: right;
    line-height: 1.3;
}

/* ═══════════════════════════════════════
   Visitor contributions & submit form
   ═══════════════════════════════════════ */

.contributions-title {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 300;
    color: var(--color-accent);
    text-align: center;
    margin-bottom: 0.5rem;
}

.contributions-intro {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-style: italic;
    color: var(--color-text-muted);
    text-align: center;
    margin-bottom: 2rem;
}

.submit-form-wrap {
    max-width: 480px;
    margin: 3rem auto 0;
    padding: 2rem;
    background: var(--color-surface);
    border-radius: 4px;
    border: 1px solid rgba(201, 169, 110, 0.1);
}

.submit-heading {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--color-accent);
    margin-bottom: 1rem;
    text-align: center;
}

.submit-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.submit-form select,
.submit-form input[type="text"],
.submit-form input[type="file"] {
    background: var(--color-bg);
    border: 1px solid #333;
    color: var(--color-text);
    padding: 0.5rem 0.75rem;
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: 0.85rem;
}

.submit-form select option {
    background: var(--color-bg);
}

.submit-btn {
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    padding: 0.6rem;
    border-radius: 3px;
    font-family: var(--font-display);
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.submit-btn:hover { opacity: 0.85; }

.submit-status {
    font-size: 0.8rem;
    text-align: center;
    font-family: var(--font-display);
    min-height: 1.2em;
}

.submit-status.success { color: #4a9; }
.submit-status.error { color: #a44; }

@media (max-width: 640px) {
    .photo-modal-content {
        flex-direction: column;
    }
    .photo-modal-img-wrap {
        flex: 0 0 55vh;
    }
    .photo-modal-sidebar {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 1px solid #333;
    }
    .photo-modal-next { right: 12px; }
    .photo-modal-prev,
    .photo-modal-next { top: 30vh; }
}

/* ═══════════════════════════════════════
   Outro
   ═══════════════════════════════════════ */

.outro-content {
    text-align: center;
}

.outro-text {
    font-family: var(--font-body);
    font-size: 1.1rem;
    line-height: 2;
    max-width: 540px;
    margin: 0 auto 4rem;
    color: var(--color-text);
}

.outro-remember {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 300;
    text-align: center;
    margin-bottom: 4rem;
    line-height: 1.7;
    letter-spacing: 0.01em;
}

.outro-remember strong {
    color: var(--color-accent);
    font-weight: 500;
    font-style: italic;
}

.nickname-wall {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 3rem;
    padding-top: 3rem;
    border-top: 1px solid var(--color-divider);
}

.nickname-tag {
    font-family: var(--font-display);
    background: transparent;
    color: var(--color-accent);
    padding: 0.35rem 1rem;
    border-radius: 0;
    font-size: 0.9rem;
    font-style: italic;
    font-weight: 400;
    border: 1px solid rgba(201, 169, 110, 0.2);
    letter-spacing: 0.03em;
    transition: all 0.3s ease;
}

.nickname-tag:hover {
    background: var(--color-accent-dim);
    border-color: var(--color-accent);
}

/* ═══════════════════════════════════════
   Scroll reveal animation
   ═══════════════════════════════════════ */

.narrative p,
.narrative .moment,
.narrative .year-marker,
.media-slot {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.narrative p.revealed,
.narrative .moment.revealed,
.narrative .year-marker.revealed,
.media-slot.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ═══════════════════════════════════════
   Responsive
   ═══════════════════════════════════════ */

@media (max-width: 600px) {
    html { font-size: 16px; }

    .memorial-section {
        padding: 2rem 1.25rem;
    }

    .era-section {
        padding-top: 5rem;
        padding-bottom: 5rem;
    }

    .era-header h2 {
        font-size: 2.4rem;
    }

    .narrative p:first-of-type::first-letter {
        font-size: 2.6em;
    }

    .narrative .moment {
        padding: 1rem 1.25rem;
    }

    .media-gallery {
        grid-template-columns: 1fr;
    }

    .media-slot {
        margin: 2rem 0;
    }

    .gate-container h1 {
        font-size: 2.2rem;
    }

    .outro-remember {
        font-size: 1.3rem;
    }
}

/* --- Read-only viewer mode --- */
[data-role="viewer"] #contributions,
[data-role="viewer"] .nickname-wall,
[data-role="viewer"] .outro-remember,
[data-role="viewer"] .photo-modal-form {
    display: none;
}
