/*
 * Coming up, Places and the bookshelf: shared by the retirement clock
 * (countdown/extras.js) and the year in review (year/year.js), so the map and
 * the shelf look the same in both and are styled in one place.
 */
/* ========================================
   Coming up · Places · the bookshelf (extras.js)
   Kyle's, so count-up only. They carry no data-mode (applyMode would
   un-hide them before their data arrived); this hides them otherwise.
   ======================================== */

body:not(.mode-countup) .journal-extra { display: none !important; }

.coming-section,
.places-section,
.shelf-section {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

body.mode-countup .coming-section,
body.mode-countup .places-section,
body.mode-countup .shelf-section {
    background: rgba(255, 255, 255, 0.38);
    border-color: rgba(255, 255, 255, 0.7);
}

.coming-section h2,
.places-section h2,
.shelf-section h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 16px;
}

.next-up {
    margin: 14px 0 0;
    text-align: center;
    font-size: 1.15rem;
    font-weight: 600;
}

.year-link {
    margin: 10px 0 0;
    text-align: center;
}

.year-link a {
    display: inline-block;
    padding: 4px 6px;
    color: inherit;
    font-weight: 600;
    text-underline-offset: 3px;
}

/* --- Coming up --- */

.coming-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 12px;
}

.coming-card {
    display: grid;
    grid-template-columns: 6.2rem minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.85);
}

.coming-card.is-now,
.coming-card.is-today {
    border: 2px solid #b4492f;
}

.coming-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    line-height: 1;
    padding-top: 2px;
}

.coming-n {
    font-size: 2.6rem;
    font-weight: 800;
    color: #9c3a22;
    font-variant-numeric: tabular-nums;
}

.is-now .coming-n,
.is-today .coming-n {
    font-size: 1.7rem;
}

.coming-unit {
    margin-top: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.coming-kind {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
}

.coming-title {
    margin: 2px 0 4px;
    font-size: 1.25rem;
    line-height: 1.25;
}

.coming-note,
.coming-wait {
    margin: 0;
    font-size: 0.95rem;
}

.coming-wait {
    margin-top: 6px;
    font-style: italic;
}

.coming-milestone {
    margin: 8px 0 0;
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(246, 211, 101, 0.5);
    font-weight: 600;
    font-size: 0.95rem;
}

.coming-link {
    display: inline-block;
    margin-top: 6px;
    padding: 3px 0;
    color: inherit;
    font-weight: 600;
    text-underline-offset: 3px;
}

.coming-weather {
    margin-top: 10px;
}

.wx-where,
.wx-stars {
    margin: 0 0 6px;
    font-size: 0.9rem;
    font-weight: 600;
}

.wx-stars {
    margin: 8px 0 0;
}

.wx-strip {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(3.1rem, 1fr));
    gap: 6px;
    max-width: 30rem;
}

.wx-day {
    display: grid;
    justify-items: center;
    padding: 6px 4px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    line-height: 1.3;
}

.wx-dow { font-weight: 700; }
.wx-glyph { font-size: 1.2rem; }
.wx-hi { font-weight: 700; }
.wx-rain { color: #24577a; font-weight: 600; }

/* --- Places --- */

.places-map {
    position: relative;
    aspect-ratio: 1000 / 560;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(161, 196, 253, 0.35), rgba(255, 255, 255, 0.25));
}

.places-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.places-grat { fill: none; stroke: rgba(58, 47, 69, 0.08); stroke-width: 1; vector-effect: non-scaling-stroke; }
.places-land { fill: rgba(58, 47, 69, 0.16); stroke: rgba(58, 47, 69, 0.32); stroke-width: 0.8; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

.places-arc {
    fill: none;
    stroke: #b4492f;
    stroke-width: 2.5;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
    stroke-dasharray: 1;
    stroke-dashoffset: 0;
}

.places--waiting .places-arc:not(.places-arc--future) { stroke-dashoffset: 1; }
.places--drawn .places-arc:not(.places-arc--future) {
    animation: places-draw 1.1s cubic-bezier(.3, .7, .3, 1) both;
    animation-delay: calc(var(--i, 0) * 0.32s);
}
@keyframes places-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }

.places-arc--future {
    stroke: #5a3f7a;
    stroke-dasharray: 0.012 0.014;
    animation: places-march 2.4s linear infinite;
}
@keyframes places-march { to { stroke-dashoffset: -0.052; } }

.places-home,
.places-pin {
    position: absolute;
    transform: translate(-50%, -50%);
}

.places-home { pointer-events: none; }
.places-home-dot {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #3a2f45;
    border: 3px solid #fff;
}

.places-pin {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.places-pin-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #b4492f;
    border: 2.5px solid #fff;
    box-shadow: 0 1px 3px rgba(58, 47, 69, 0.4);
}

.places-pin--future .places-pin-dot { background: #5a3f7a; }

.places-pin--next::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    border: 2px solid #5a3f7a;
    animation: places-pulse 2s ease-out infinite;
}
@keyframes places-pulse { from { transform: scale(0.6); opacity: 1; } to { transform: scale(1.8); opacity: 0; } }

.places-pin[aria-pressed="true"] .places-pin-dot { transform: scale(1.35); }
.places-pin:focus-visible { outline: 3px solid #3a2f45; outline-offset: 2px; border-radius: 50%; }

.places-label {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 2px;
    padding: 1px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.82);
    color: #3a2f45;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
}

.places-label--left { left: auto; right: 100%; margin: 0 2px 0 0; }
/* Home's label reads to the left, out over the Pacific: everything Kyle
   visits is north, east or south of Mission Viejo, and San Diego's pin sits
   just right of it. */
.places-label--home { left: auto; right: 100%; margin: 0 4px 0 0; }

.places-caption {
    margin: 12px 0 2px;
    text-align: center;
    font-weight: 600;
}

.places-detail {
    margin: 0;
    min-height: 1.5em;
    text-align: center;
    font-size: 0.95rem;
}

/* --- The bookshelf --- */

.shelf {
    display: flex;
    justify-content: center;
    padding: 18px 12px 0;
    border-bottom: 14px solid #8a5a35;
    border-radius: 4px 4px 2px 2px;
    background: linear-gradient(180deg, rgba(138, 90, 53, 0.08), rgba(138, 90, 53, 0.2));
    box-shadow: 0 10px 14px -10px rgba(58, 47, 69, 0.6);
}

.shelf-books {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 190px;
}

.spine-slot { display: flex; align-items: flex-end; height: 100%; }

.spine {
    position: relative;
    width: var(--w, 38px);
    height: calc(var(--h, 0.9) * 100%);
    padding: 10px 0;
    border: 0;
    border-radius: 3px 3px 1px 1px;
    background:
        linear-gradient(90deg, rgba(0, 0, 0, 0.25), rgba(255, 255, 255, 0.12) 30%, rgba(0, 0, 0, 0.18)),
        var(--c, #2f4a6b);
    color: #fff;
    cursor: pointer;
    transform: rotate(var(--lean, 0deg));
    transform-origin: bottom center;
    transition: transform 0.2s ease;
    display: flex;
    justify-content: center;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.spine::before,
.spine::after {
    content: '';
    position: absolute;
    left: 4px;
    right: 4px;
    height: 2px;
    background: rgba(246, 211, 101, 0.85);
}
.spine::before { top: 8%; }
.spine::after { bottom: 8%; }
.spine--band1::before { top: 14%; height: 4px; }
.spine--band2::after { bottom: 14%; height: 4px; }

.spine-title {
    writing-mode: vertical-rl;
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    max-height: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spine:hover,
.spine:focus-visible { transform: rotate(var(--lean, 0deg)) translateY(-8px); }
.spine:focus-visible { outline: 3px solid #3a2f45; outline-offset: 2px; }

.spine--reading { margin-left: 10px; }
.spine-ribbon {
    position: absolute;
    top: -12px;
    right: 8px;
    width: 8px;
    height: 26px;
    background: #b4492f;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
}

.shelf-caption {
    margin: 14px 0 0;
    min-height: 1.5em;
    text-align: center;
    font-weight: 600;
}

@media (max-width: 600px) {
    /* Labels need room a phone's map does not have; the caption names home,
       and a tapped pin says where it is. */
    .places-label { display: none; }
    .coming-card { grid-template-columns: 4.6rem minmax(0, 1fr); gap: 10px; padding: 12px; }
    .coming-n { font-size: 2.1rem; }
    .is-now .coming-n, .is-today .coming-n { font-size: 1.35rem; }
    .shelf-books { height: 160px; }
}

@media (prefers-reduced-motion: reduce) {
    .places--drawn .places-arc,
    .places-arc--future,
    .places-pin--next::after { animation: none !important; }
    .places--waiting .places-arc { stroke-dashoffset: 0; }
    .spine { transition: none; }
}

@media (prefers-contrast: high) {
    body.mode-countup .coming-section,
    body.mode-countup .places-section,
    body.mode-countup .shelf-section,
    body.mode-countup .coming-card,
    body.mode-countup .wx-day {
        background: #000;
        border: 2px solid #fff;
        color: #fff;
    }
    body.mode-countup .coming-n,
    body.mode-countup .wx-rain { color: #fff; }
    body.mode-countup .coming-milestone { background: #000; border: 2px solid #fff; }
    .places-land { fill: rgba(255, 255, 255, 0.25); stroke: #fff; }
    .places-arc { stroke: #fff; }
    .places-label { background: #000; color: #fff; }
}

@media (forced-colors: active) {
    .places-arc, .places-arc--future { stroke: CanvasText; }
    .places-land { fill: Canvas; stroke: CanvasText; }
    .places-pin-dot, .places-home-dot { background: ButtonText; border-color: Canvas; }
    .spine { forced-color-adjust: none; }
}
