/* ---------- Shared ---------- */
:root {
    --bg: #251c13;          /* matches the home.jpg background */
    --ink: #e9dec6;
    --ink-soft: #c9bb9c;
    --gold: #d9c27a;
    --gold-dim: #8c7a4a;
    --red: #b42e25;
    --red-bright: #d8463a;
    --s: min(100vw, 100vh); /* side length of the square image on screen */
}
@supports (height: 100dvh) {
    :root { --s: min(100vw, 100dvh); }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Georgia, "Times New Roman", Times, serif;
}

/* ---------- Home: full-page image ---------- */
body.home {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.stage {
    position: relative;
    width: var(--s);
    height: var(--s);
    flex: 0 0 auto;
}

.hero-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

/* Enlarged red arrow, placed where the original small arrow sat (right of "1729") */
.next-arrow {
    position: absolute;
    left: 84%;
    top: 69.0%;
    width: 13.5%;
    aspect-ratio: 260 / 110;
    display: block;
    text-decoration: none;
    color: #fff;
    filter: drop-shadow(0 0 calc(var(--s) * 0.004) rgba(216, 70, 58, 0.55));
    animation: beckon 2.4s ease-in-out infinite;
    transform-origin: 50% 50%;
    transition: filter 0.25s ease, transform 0.25s ease;
    outline: none;
}
.next-arrow svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}
.next-arrow .label {
    position: absolute;
    left: 0;
    top: 0;
    width: 71%;              /* the arrow body is 185/260 of the total width */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-weight: 700;
    font-size: calc(var(--s) * 0.013);
    letter-spacing: 0.08em;
    white-space: nowrap;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.next-arrow:hover,
.next-arrow:focus-visible {
    animation-play-state: paused;
    transform: scale(1.08);
    filter: drop-shadow(0 0 calc(var(--s) * 0.01) rgba(216, 70, 58, 0.95));
}
.next-arrow:hover svg polygon:first-child,
.next-arrow:focus-visible svg polygon:first-child {
    fill: var(--red-bright);
}
@keyframes beckon {
    0%, 100% { transform: translateX(0); }
    50%      { transform: translateX(calc(var(--s) * 0.006)); }
}
@media (prefers-reduced-motion: reduce) {
    .next-arrow { animation: none; }
}

/* Phones: the inline spot is too small to read, so drop the arrow just below the icon row */
@media (max-width: 640px) {
    .next-arrow {
        left: auto;
        right: 3%;
        top: 74%;
        width: 34%;
    }
    .next-arrow .label {
        font-size: calc(var(--s) * 0.034);
    }
}

/* In-flow version of the red arrow, used at the foot of the letter and poem pages */
.next-arrow.inline {
    position: relative;
    left: auto; top: auto;
    width: clamp(150px, 20vw, 190px);
    flex: 0 0 auto;
    filter: drop-shadow(0 0 3px rgba(216, 70, 58, 0.55));
}
.next-arrow.inline .label {
    font-size: clamp(0.85rem, 0.55rem + 1vw, 1rem);
}
.next-arrow.inline:hover,
.next-arrow.inline:focus-visible {
    filter: drop-shadow(0 0 9px rgba(216, 70, 58, 0.95));
}
@media (max-width: 640px) {
    .next-arrow.inline { right: auto; top: auto; width: clamp(150px, 20vw, 190px); }
    .next-arrow.inline .label { font-size: clamp(0.85rem, 0.55rem + 1vw, 1rem); }
}

/* ---------- Front cover page (cream artwork) ---------- */
body.cover { background: #fff9dc; }          /* matches cover.jpg */
.cover .next-arrow {
    left: 83.5%;
    top: 62.2%;                              /* centred on the hand-lettered author name */
    width: 13.5%;
    filter: drop-shadow(0 2px calc(var(--s) * 0.004) rgba(120, 30, 20, 0.35));
}
.cover .next-arrow:hover,
.cover .next-arrow:focus-visible {
    filter: drop-shadow(0 3px calc(var(--s) * 0.008) rgba(120, 30, 20, 0.55));
}
@media (max-width: 640px) {
    .cover .next-arrow { left: auto; right: 4%; top: 70%; width: 30%; }
}

/* Return link overlaid on image pages (bottom-left corner, inside the frame) */
.return-link {
    position: absolute;
    left: 4%;
    bottom: 3.6%;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: calc(var(--s) * 0.014);
    letter-spacing: 0.18em;
    text-decoration: none;
    color: rgba(60, 38, 20, 0.6);
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
    outline: none;
}
.return-link:hover, .return-link:focus-visible {
    color: #3c2614;
    border-bottom-color: #3c2614;
}
@media (max-width: 640px) {
    .return-link { font-size: calc(var(--s) * 0.032); left: 5%; bottom: 5%; }
}

/* ---------- Letter page ---------- */
body.letter {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: clamp(2rem, 6vh, 4rem) 1.25rem 3rem;
}

.letter-wrap {
    width: 100%;
    max-width: 680px;
}

.masthead {
    text-align: center;
    margin-bottom: 2.5rem;
}
.masthead .numeral {
    display: block;
    color: var(--gold);
    font-size: clamp(2.6rem, 7vw, 3.8rem);
    line-height: 1;
    letter-spacing: 0.04em;
}
.masthead .name {
    display: block;
    color: var(--gold);
    font-size: clamp(0.8rem, 2.2vw, 1.05rem);
    letter-spacing: 0.32em;
    margin-top: 0.5rem;
}
.rule {
    position: relative;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-dim) 15%, var(--gold-dim) 85%, transparent);
    margin: 1.4rem auto 0;
}
.rule::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 6px;
    height: 6px;
    background: var(--gold-dim);
    transform: translate(-50%, -50%) rotate(45deg);
}

.letter-body {
    font-size: clamp(1.05rem, 1.25vw + 0.6rem, 1.25rem);
    line-height: 1.7;
    color: var(--ink);
}
.letter-body p { margin: 0 0 1.35em; }
.letter-body .dateline { color: var(--ink-soft); margin-bottom: 1.6em; }
.letter-body .salutation { margin-bottom: 1.6em; }
.letter-body .title { font-style: italic; }
.letter-body .closing { margin-top: 2.2em; margin-bottom: 0.6em; }
.letter-body .signature {
    font-size: 1.15em;
    color: var(--gold);
    line-height: 1.45;
    margin-bottom: 0;
}
.letter-body .signature small {
    display: block;
    font-size: 0.78em;
    color: var(--ink-soft);
    letter-spacing: 0.06em;
}

.page-nav {
    margin-top: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}
.back {
    text-align: left;
}
.page-nav.end { justify-content: flex-start; }
.back a {
    color: var(--gold-dim);
    text-decoration: none;
    font-size: 0.9rem;
    letter-spacing: 0.18em;
    border-bottom: 1px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.back a:hover, .back a:focus-visible {
    color: var(--gold);
    border-bottom-color: var(--gold);
    outline: none;
}

/* ---------- Poem page ---------- */
.poem {
    font-size: clamp(1.1rem, 1.25vw + 0.65rem, 1.3rem);
    line-height: 1.75;
    color: var(--ink);
    max-width: 34em;
    margin: 0 auto;
}
.poem .poem-title {
    font-weight: 700;
    letter-spacing: 0.04em;
    margin: 0 0 1.6em;
}
.poem .stanza { margin: 0 0 1.4em; }
.poem .attribution {
    font-style: italic;
    color: var(--gold);
    margin-top: 2em;
}
