/* ==========================================================================
   Offerings — letters laid at the altar
   ========================================================================== */

/* ---------- Hero & year tabs ---------- */
.offerings-hero { padding-bottom: clamp(2.5rem, 5vw, 3.5rem); }
.offerings-hero .page-title { max-width: 14ch; }

.year-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 2.4rem;
}
.year-tab {
    position: relative;
    display: inline-flex;
    align-items: baseline;
    gap: .6rem;
    padding: .7rem 1.25rem .55rem;
    border: 1px solid rgba(242, 209, 140, .35);
    border-radius: 999px;
    text-decoration: none;
    color: rgba(246, 238, 221, .8);
    transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}
.year-tab b {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    line-height: 1;
}
.year-tab small {
    font-family: var(--font-read);
    font-style: italic;
    font-size: .95rem;
    opacity: .75;
}
.year-tab:hover { border-color: var(--marigold); color: var(--paper); }
.year-tab[aria-current='page'] {
    background: var(--marigold);
    border-color: var(--marigold);
    color: var(--night);
}
.year-tab.is-live::after {
    content: '';
    position: absolute;
    top: 6px; right: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #8fd07a;
    box-shadow: 0 0 0 0 rgba(143, 208, 122, .6);
    animation: livePulse 2.2s ease-out infinite;
}

/* ---------- Toolbar ---------- */
.toolbar {
    position: sticky;
    top: var(--header-h);
    z-index: 400;
    background: rgba(246, 238, 221, .9);
    -webkit-backdrop-filter: blur(12px) saturate(1.1);
    backdrop-filter: blur(12px) saturate(1.1);
    border-bottom: 1px solid var(--paper-edge);
}
.toolbar-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 210px) minmax(0, 210px) auto;
    gap: .75rem;
    padding-top: .85rem;
    padding-bottom: .85rem;
}

.search-field { position: relative; }
.search-field > svg {
    position: absolute;
    left: .95rem; top: 50%;
    width: 20px; height: 20px;
    transform: translateY(-50%);
    color: var(--ink-3);
    pointer-events: none;
}
.search-field input,
.filter-field select {
    width: 100%;
    height: 48px;
    font-family: var(--font-ui);
    font-size: 1rem;
    color: var(--ink);
    background: var(--paper-hi);
    border: 1px solid var(--paper-edge);
    border-radius: var(--radius);
    transition: border-color .2s ease, box-shadow .2s ease;
}
.search-field input { padding: .2rem 2.6rem 0 2.8rem; }
.search-field input::placeholder { color: var(--ink-3); opacity: .85; }
.search-field input::-webkit-search-cancel-button { display: none; }
.search-field input:focus,
.filter-field select:focus {
    outline: none;
    border-color: var(--kumkum);
    box-shadow: 0 0 0 3px rgba(179, 38, 30, .14);
}
.search-clear {
    position: absolute;
    right: .35rem; top: 50%;
    width: 38px; height: 38px;
    transform: translateY(-50%);
    font-size: 1.5rem;
    line-height: 1;
    color: var(--ink-3);
    border-radius: 50%;
}
.search-clear:hover { color: var(--kumkum); background: var(--paper-2); }

.filter-field select {
    padding: .2rem 2.3rem 0 .95rem;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    text-overflow: ellipsis;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2385694f' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 8 5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    background-size: 16px;
}
.filter-field select:disabled { opacity: .55; cursor: not-allowed; }

.btn-sm {
    min-height: 48px;
    padding: .7rem 1.1rem .6rem;
    font-size: .8rem;
}

/* ---------- Results ---------- */
.letters-section { padding: 2.25rem 0 clamp(4rem, 8vw, 6rem); }

.results-bar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    min-height: 2rem;
    margin-bottom: 1.5rem;
}
.results-count {
    font-family: var(--font-ui);
    font-size: .82rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.results-count strong {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--kumkum);
    margin-right: .15rem;
}

.notice {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .35rem 1rem;
    margin-bottom: 2rem;
    padding: 1.1rem 1.4rem 1.1rem 4.2rem;
    background: var(--paper-2);
    border: 1px solid var(--paper-edge);
    border-radius: var(--radius);
    font-size: 1.05rem;
    color: var(--ink-2);
}
.notice::before {
    content: '';
    position: absolute;
    left: 1.3rem; top: 1.2rem;
    width: 34px; height: 23px;
    background: var(--marigold);
    -webkit-mask: var(--lotus) center / contain no-repeat;
    mask: var(--lotus) center / contain no-repeat;
}
.notice strong { font-family: var(--font-display); font-weight: 600; color: var(--ink); flex-basis: 100%; }

/* ---------- Letters ---------- */
.letters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 1.5rem 1.4rem;
}

.letter {
    --tilt: 0deg;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 340px;
    padding: 1.5rem 1.55rem 1.35rem;
    text-align: left;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .5), transparent 40%),
        var(--paper-hi);
    border: 1px solid rgba(217, 196, 157, .75);
    border-radius: 2px;
    box-shadow: var(--shadow-paper);
    transform: rotate(var(--tilt));
    transition: transform .45s var(--ease-out), box-shadow .45s var(--ease-out), border-color .3s ease;
    animation: letterIn .7s var(--ease-out) both;
}
.letter:nth-child(4n+1) { --tilt: -.35deg; }
.letter:nth-child(4n+3) { --tilt: .3deg; }
.letter:nth-child(6n+2) { --tilt: .18deg; }

/* Folded corner */
.letter::before {
    content: '';
    position: absolute;
    top: -1px; right: -1px;
    width: 26px; height: 26px;
    background: linear-gradient(225deg, var(--paper) 50%, var(--paper-3) 50%);
    box-shadow: -2px 2px 3px rgba(42, 25, 16, .08);
    transform-origin: top right;
    transition: transform .35s var(--ease-out);
}
.letter:hover,
.letter:focus-visible {
    transform: translateY(-5px) rotate(0deg);
    box-shadow: var(--shadow-lift);
    border-color: var(--gold);
}
.letter:hover::before { transform: scale(1.45); }

.letter-top {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-ui);
    font-size: .7rem;
    font-weight: 500;
    letter-spacing: .18em;
    text-transform: uppercase;
    padding-right: 1.5rem;
}
.letter-no { color: var(--kumkum); }
.letter-len { color: var(--ink-3); }

.letter-text {
    display: block;
    margin-top: 1.1rem;
    max-height: calc(1.68em * 7.5);
    overflow: hidden;
    font-size: 1.03rem;
    line-height: 1.68;
    color: var(--ink-2);
    -webkit-mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 72%, transparent 100%);
    overflow-wrap: anywhere;
}
.letter-text::first-letter {
    float: left;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 3.1em;
    line-height: .78;
    margin: .2rem .45rem 0 0;
    color: var(--kumkum);
}

.letter-sign {
    display: block;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px dashed var(--paper-edge);
}
.letter-sign b {
    display: block;
    font-family: var(--font-display);
    font-size: 1.22rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--ink);
}
.letter-sign small {
    display: block;
    margin-top: .3rem;
    font-family: var(--font-ui);
    font-size: .72rem;
    font-weight: 500;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-3);
}
.letter mark,
.reader mark {
    background: rgba(242, 163, 58, .38);
    color: inherit;
    padding: 0 .08em;
    border-radius: 2px;
}

/* ---------- States ---------- */
.letters-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    padding: 4.5rem 1rem;
    text-align: center;
    color: var(--ink-2);
}
.letters-state[hidden] { display: none; }
.letters-state p { max-width: 32rem; font-size: 1.1rem; }
.letters-state strong { font-family: var(--font-display); font-size: 1.45rem; font-weight: 600; color: var(--ink); }
.letters-state .btn { margin-top: 1.2rem; }
.letters-state .spinner { margin-bottom: .6rem; }
.empty-mark {
    width: 66px; height: 44px;
    margin-bottom: .8rem;
    background: var(--gold);
    -webkit-mask: var(--lotus) center / contain no-repeat;
    mask: var(--lotus) center / contain no-repeat;
}

.load-more { display: flex; justify-content: center; margin-top: 3rem; }
.load-more[hidden] { display: none; }
#sentinel { height: 1px; }

/* ---------- Offer band ---------- */
.offer-band {
    position: relative;
    background:
        radial-gradient(520px 260px at 90% 120%, rgba(242, 163, 58, .26), transparent 70%),
        var(--night);
    color: var(--paper);
    padding: clamp(3.5rem, 7vw, 5rem) 0;
}
.offer-band::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 0;
    height: 10px;
    background: radial-gradient(circle at 50% 0, var(--paper) 5px, transparent 5.5px) repeat-x;
    background-size: 18px 10px;
}
.offer-band-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 2rem;
}
.offer-band .section-title { color: var(--paper); }
.offer-band .section-title em { color: var(--marigold); }

/* ---------- Reader ---------- */
html.reader-open { overflow: hidden; }

.reader {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--ink);
    overflow-y: auto;
    overscroll-behavior: contain;
}
.reader:not([open]) { display: none; }
.reader::backdrop {
    background: rgba(44, 11, 9, .9);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}
.reader[open] { animation: fadeIn .3s ease both; }

.reader-shell {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 780px;
    min-height: 100%;
    margin: 0 auto;
    padding: 1rem var(--gutter) 1.5rem;
    pointer-events: none;
}
.reader-shell > * { pointer-events: auto; }

.reader-bar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .25rem 0 .75rem;
    color: var(--paper);
}
.reader-pos {
    font-family: var(--font-ui);
    font-size: .78rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: rgba(246, 238, 221, .7);
    font-variant-numeric: tabular-nums;
}
.reader-actions { display: flex; gap: .5rem; }
.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 44px; height: 44px;
    border-radius: 50%;
    color: var(--paper);
    background: rgba(44, 11, 9, .6);
    border: 1px solid rgba(242, 209, 140, .35);
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--paper); color: var(--night); border-color: var(--paper); }

.reader-paper {
    position: relative;
    padding: clamp(2rem, 6vw, 4rem) clamp(1.4rem, 6vw, 4.25rem) clamp(2rem, 5vw, 3.25rem);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, .55), transparent 220px),
        var(--paper-hi);
    border-radius: 2px;
    box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .85), 0 0 0 1px rgba(217, 196, 157, .6);
    animation: paperIn .55s var(--ease-out) both;
}
.reader-paper:focus { outline: none; }
.reader-paper.turn-next { animation: turnNext .45s var(--ease-out) both; }
.reader-paper.turn-prev { animation: turnPrev .45s var(--ease-out) both; }
.reader-paper::before {
    content: '';
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(214, 162, 74, .28);
    pointer-events: none;
}

.reader-head { text-align: center; margin-bottom: 2rem; }
.reader-kicker {
    display: block;
    margin-bottom: 1rem;
    font-family: var(--font-ui);
    font-size: .74rem;
    font-weight: 600;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--kumkum);
}
.reader-head .lotus-rule { max-width: 260px; margin: 0 auto; }

.reader-text {
    font-size: clamp(1.1rem, 1.6vw, 1.22rem);
    line-height: 1.82;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.reader-text p + p { margin-top: 1.05em; }
.reader-text p:first-child::first-letter {
    float: left;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 4.1em;
    line-height: .78;
    margin: .25rem .65rem 0 0;
    color: var(--kumkum);
}

.reader-sign {
    margin-top: 2.6rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--paper-edge);
    text-align: right;
}
.reader-sign-label {
    display: block;
    font-style: italic;
    color: var(--ink-3);
}
.reader-sign strong {
    display: block;
    margin-top: .2rem;
    font-family: var(--font-display);
    font-size: clamp(1.45rem, 3vw, 1.9rem);
    font-weight: 600;
    line-height: 1.15;
}
#reader-place {
    display: block;
    margin-top: .35rem;
    font-family: var(--font-ui);
    font-size: .76rem;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.reader-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.25rem 0 .5rem;
    color: var(--paper);
}
.reader-step {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    min-height: 44px;
    padding: .5rem .9rem;
    font-family: var(--font-ui);
    font-size: .82rem;
    font-weight: 600;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--paper);
    border: 1px solid rgba(242, 209, 140, .35);
    border-radius: var(--radius);
    transition: background-color .2s ease, color .2s ease;
}
.reader-step svg { width: 18px; height: 18px; }
.reader-step:hover:not(:disabled) { background: var(--paper); color: var(--night); }
.reader-step:disabled { opacity: .3; cursor: default; }
.reader-hint {
    font-style: italic;
    font-size: .92rem;
    color: rgba(246, 238, 221, .5);
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    z-index: 3000;
    padding: .75rem 1.25rem .65rem;
    font-family: var(--font-ui);
    font-size: .9rem;
    font-weight: 500;
    letter-spacing: .04em;
    color: var(--night);
    background: var(--marigold);
    border-radius: 999px;
    box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .6);
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
    transition: opacity .25s ease, transform .3s var(--ease-out);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Keyframes ---------- */
@keyframes letterIn { from { opacity: 0; transform: translateY(16px) rotate(var(--tilt)); } to { opacity: 1; transform: rotate(var(--tilt)); } }
@keyframes paperIn { from { opacity: 0; transform: translateY(24px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes turnNext { from { opacity: .2; transform: translateX(36px); } to { opacity: 1; transform: none; } }
@keyframes turnPrev { from { opacity: .2; transform: translateX(-36px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes livePulse { 0% { box-shadow: 0 0 0 0 rgba(143, 208, 122, .6); } 80%, 100% { box-shadow: 0 0 0 8px rgba(143, 208, 122, 0); } }

/* ---------- Responsive ---------- */
@media (min-width: 1100px) {
    .reader-nav { justify-content: center; }
    .reader-step {
        position: fixed;
        top: 50%;
        flex-direction: column;
        gap: .7rem;
        width: 104px;
        padding: 1.1rem .5rem;
        font-size: .72rem;
        border-color: rgba(242, 209, 140, .22);
        transform: translateY(-50%);
    }
    .reader-step svg { width: 24px; height: 24px; }
    #reader-prev { right: calc(50% + 390px + 1.5rem); }
    #reader-next { left: calc(50% + 390px + 1.5rem); }
    #reader-next span { order: 2; }
}

@media (max-width: 900px) {
    .toolbar-inner {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
    }
    .search-field { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
    .toolbar { position: static; }
    .toolbar-inner { gap: .6rem; }
    .btn-sm { width: 48px; padding: 0; }
    .btn-sm svg { width: 22px; height: 22px; }
    .btn-sm .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
    .letters { grid-template-columns: 1fr; gap: 1.1rem; }
    .letter { min-height: 0; --tilt: 0deg !important; }
    .letter-text { max-height: calc(1.68em * 6); }
    .reader-shell { padding-left: .6rem; padding-right: .6rem; }
    .reader-hint { display: none; }
    .reader-step span { display: none; }
    .reader-step { padding: .5rem 1rem; }
    .year-tab { padding: .6rem 1rem .45rem; }
}
