/* ============================================================
   Design tokens
   ============================================================ */
:root {
    --ink: #211F26;
    --paper: #FAF6EF;
    --muted: #8A8478;
    /* --theme-hue is set by script.js (applyThemeVisuals), deterministic
       per date. Falls back to a warm neutral if JS hasn't run yet. */
    --day-deep: hsl(var(--theme-hue, 30), 55%, 30%);
    --day-deep-text: hsl(var(--theme-hue, 30), 60%, 94%);
    --day-pale: hsl(var(--theme-hue, 30), 45%, 91%);
    --day-pale-text: hsl(var(--theme-hue, 30), 55%, 26%);
}

* { box-sizing: border-box; }

/* ============================================================
   Page
   ============================================================ */
body {
    font-family: 'Newsreader', serif;
    line-height: 1.7;
    color: var(--ink);
    margin: 0;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari: avoids the address-bar show/hide jump */

    /* Pale wash tied to the day's theme color. Stays close to a neutral
       lightness/saturation so it reads as a gentle tint. */
    background-color: hsl(var(--theme-hue, 30), 22%, 94%);

    /* Cross-platform: suppress the default gray tap-flash on iOS/Android;
       buttons below define explicit :active states as the replacement. */
    -webkit-tap-highlight-color: transparent;
}

.container {
    max-width: 640px;
    width: 100%;
    margin: 2rem auto;
    background: var(--paper);
    transition: opacity 0.3s ease-in-out;
    position: relative;
}

@media (max-width: 768px) {
    body { padding: 0; }
    .container {
        margin: 0;
        min-height: 100vh;
        min-height: 100dvh;
    }
}

/* ============================================================
   Hero band -- today's color is the primary chrome, not a
   background decoration. Holds the wordmark/audio controls, date,
   theme eyebrow, and deck line.
   ============================================================ */
.hero {
    position: relative;
    overflow: hidden;
    background: var(--day-deep);
    color: var(--day-deep-text);
    padding: 1.75rem 1.5rem 2rem;
}

/* Botanical accent -- full-height vertical vine near the right edge,
   different motif each day (see script.js BOTANICAL_SVGS), color
   independent of the hue above. Fades in/out via mask rather than
   being hard-clipped by overflow:hidden. */
.hero::before {
    content: '';
    position: absolute;
    top: 0;
    right: 20px;
    width: 65px;
    height: 100%;
    opacity: 0.22;
    background-image: var(--botanical-bg);
    background-size: 100% 100%;
    background-repeat: no-repeat;
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, transparent 0%, black 15%, black 85%, transparent 100%);
    pointer-events: none;
}

.hero-top {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.wordmark {
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.75;
}

.date {
    position: relative;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: clamp(1.9rem, 4vw + 1rem, 2.6rem);
    line-height: 1.15;
    margin: 0 0 1rem;
    max-width: 75%;
}

.eyebrow {
    position: relative;
    display: inline-block;
    font-family: 'Inter', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    background: rgba(255,255,255,0.14);
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.9rem;
}

.deck {
    position: relative;
    font-family: 'Newsreader', serif;
    font-style: italic;
    font-size: 1.05rem;
    line-height: 1.5;
    margin: 0;
    opacity: 0.92;
    max-width: 85%;
}

/* ============================================================
   Audio controls -- live in the hero-top row, recolored for the
   colored hero background (light icon color instead of the old
   bronze-on-cream treatment).
   ============================================================ */
.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--day-deep-text);
    box-sizing: border-box; /* so min-width/height include the padding below */
    padding: 10px; /* icon stays 24px, padding brings the tap target to 44px */
    min-width: 44px;
    min-height: 44px;
    transition: all 0.3s ease;
    opacity: 0.75;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.speed-btn {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    min-width: 44px; /* keeps the 44px tap target; also prevents jitter when text changes */
    letter-spacing: 0.02em;
}

.action-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

@media (hover: hover) and (pointer: fine) {
    .action-btn:hover {
        opacity: 1;
        transform: scale(1.1);
    }
}

.action-btn:active {
    opacity: 1;
    transform: scale(0.95);
}

.action-btn:focus-visible {
    outline: 2px solid var(--day-deep-text);
    outline-offset: 2px;
    border-radius: 50%;
}

/* Tooltip -- only for real hover-capable pointers; on touch, :hover
   can get stuck after a tap until the user taps elsewhere. */
.action-btn::after {
    content: attr(aria-label);
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--paper);
    padding: 4px 8px;
    font-size: 0.72rem;
    font-family: 'Inter', sans-serif;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 20;
}

@media (hover: hover) and (pointer: fine) {
    .action-btn:hover::after {
        opacity: 1;
    }
}

.spin-animation {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.action-btn.playing {
    opacity: 1;
}

/* ============================================================
   Reading area -- the ~110-180 word horoscope itself
   ============================================================ */
.reading {
    padding: 1.75rem 1.5rem 1.25rem;
}

.passage {
    font-family: 'Newsreader', serif;
    font-size: clamp(1.1rem, 1vw + 1rem, 1.3rem);
    line-height: 1.7;
    color: var(--ink);
    margin: 0;
    max-width: 46ch;
}

.dropcap-letter {
    float: left;
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 3.4em;
    line-height: 0.78;
    color: var(--day-deep);
    padding: 0.02em 0.08em 0 0;
}

.loading-spinner {
    color: var(--muted);
    font-style: italic;
    font-size: 1rem;
}

.error-container {
    text-align: center;
    background-color: hsl(var(--theme-hue, 30), 60%, 96%);
    padding: 2rem;
    border-radius: 8px;
    border: 1px solid hsl(var(--theme-hue, 30), 50%, 88%);
}

.error-message {
    font-size: 1.05rem;
    margin-bottom: 1rem;
    color: var(--ink);
}

.error-retry-btn {
    padding: 0.6rem 1.2rem;
    background-color: var(--day-deep);
    color: var(--day-deep-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    min-height: 44px;
}

/* ============================================================
   Stat-strip (Lucky Numbers / Lucky Color) + Tip ribbon
   ============================================================ */
.stat-strip {
    display: flex;
    border-top: 2px solid var(--day-deep);
}

.stat {
    flex: 1;
    padding: 0.9rem 1rem;
    text-align: center;
}

.stat + .stat {
    border-left: 1px solid rgba(33,31,38,0.08);
}

.stat .stat-label {
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

.stat .stat-value {
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink);
}

.tip-ribbon {
    text-align: center;
    padding: 0.8rem 1.5rem;
    border-top: 1px solid rgba(33,31,38,0.1);
    border-bottom: 1px solid rgba(33,31,38,0.1);
    font-family: 'Newsreader', serif;
    font-size: 0.9rem;
    color: var(--ink);
}

.tip-ribbon .tip-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

/* Only shown when money_note is non-empty -- script.js toggles display.
   No top border: it always sits directly under .tip-ribbon, whose
   bottom border already serves as the divider between them. */
.money-ribbon {
    text-align: center;
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid rgba(33,31,38,0.1);
    font-family: 'Newsreader', serif;
    font-size: 0.9rem;
    color: var(--ink);
}

.money-ribbon .money-label {
    display: block;
    font-family: 'Inter', sans-serif;
    font-size: 0.62rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.25rem;
}

/* ============================================================
   Week-cells -- desktop-only nearby-days strip. Cells carry
   enough text (day + date number) that they don't work well at
   phone widths, unlike the old circular day-strip; the plain
   Yesterday/Today/Tomorrow row below still covers mobile nav.
   ============================================================ */
.week-cells {
    display: none;
    gap: 6px;
    padding: 0.75rem 1.5rem 1.25rem;
}

.week-cells .day-cell {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.3rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    border: none;
    text-decoration: none;
    cursor: pointer;
    display: block;
    min-height: 44px;
}

.week-cells .day-cell .day-num {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 2px;
}

.week-cells .day-cell.today {
    background: var(--day-deep) !important;
    color: var(--day-deep-text) !important;
}

.week-cells .day-cell.invalid {
    background: repeating-linear-gradient(45deg, #ddd, #ddd 3px, #eee 3px, #eee 6px);
    color: var(--muted);
    cursor: default;
}

.week-cells .day-cell:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* ============================================================
   Prev / today / next
   ============================================================ */
.daynav {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(33,31,38,0.08);
    gap: 10px;
}

.daynav button {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 0.85rem;
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    min-height: 44px;
    flex: 1;
    transition: color 0.2s ease;
}

@media (hover: hover) and (pointer: fine) {
    .daynav button:hover:not(:disabled) {
        color: var(--ink);
    }
}

.daynav button:active:not(:disabled) {
    color: var(--ink);
}

.daynav button:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

#today-btn {
    font-weight: 600;
    color: var(--ink);
}

/* ============================================================
   Tablet tier -- softens the desktop->phone jump
   ============================================================ */
@media (min-width: 720px) {
    .week-cells { display: flex; }
    .hero { padding: 2.25rem 2.5rem 2.5rem; }
    .reading { padding: 2rem 2.5rem 1.5rem; }
    .stat { padding: 0.9rem 1.5rem; }
    .tip-ribbon { padding: 0.8rem 2.5rem; }
    .money-ribbon { padding: 0.8rem 2.5rem; }
    .daynav { padding: 1rem 2.5rem calc(1.5rem + env(safe-area-inset-bottom)); }
}

/* ============================================================
   Footer
   ============================================================ */
#footer {
    text-align: center;
    padding: 1.5rem;
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    color: var(--muted);
}

/* ============================================================
   Toast notification (audio loading)
   ============================================================ */
.toast-notification {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--ink);
    color: var(--paper);
    font-family: 'Newsreader', serif;
    font-style: italic;
    padding: 12px 24px;
    border-radius: 30px;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease, bottom 0.4s ease;
    pointer-events: none;
    font-size: 0.95rem;
    white-space: nowrap;
}

.toast-notification.show {
    opacity: 1;
    visibility: visible;
    bottom: 40px;
}

@media (max-width: 768px) {
    .toast-notification {
        bottom: calc(30px + env(safe-area-inset-bottom));
    }
    .toast-notification.show {
        bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
