/*
 * Poem of the Day (spec 072): the header slot item and the dialog it opens.
 *
 * A global stylesheet, not a .razor.css file, because every element here is made by
 * wwwroot/js/headerSlot.poem.js and Blazor's scoped CSS only reaches markup a component wrote.
 * Per-line fonts, colours and sizes are set inline by that script; this file holds the parts that
 * are the same every time.
 */

/* ---- the header item ---------------------------------------------------------------------- */

.aa-poem {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: inherit;
    color: #f4ead5;
    font: inherit;
    text-align: center;
    cursor: pointer;
    overflow: hidden;
    /* a soft lamp-light glow on the ink background the slot paints */
    background:
        radial-gradient(ellipse at 50% 120%, rgba(226, 196, 106, 0.18), transparent 60%),
        radial-gradient(ellipse at 10% -20%, rgba(177, 198, 105, 0.12), transparent 55%);
}

.aa-poem:focus-visible {
    outline: 2px solid #e2c46a;
    outline-offset: -3px;
}

.aa-poem-stage {
    position: absolute;
    inset: 0;
    box-sizing: border-box;
}

/* Everything on the stage is stacked in the centre; only one thing is ever meant to be readable. */
.aa-poem-stage > * {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
}

/* Two poem lines sharing a frame. The box shrink-wraps to the longer line and is centred by the
   holder around it, so the shorter line starts at the same left edge. The gap separates the two;
   headerSlot.poem.js allows for it (PAIR_GAP) when sizing them, so change both together. */
.aa-poem-pair {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

/* One poem line: shrink-wrapped to its text so headerSlot.poem.js can measure it. */
.aa-poem-line-h {
    display: inline-block;
    line-height: 1.15;
}

.aa-poem-bit {
    display: inline-block;
    white-space: pre;
}

/* Placed by headerSlot.poem.js, which moves it to just after each letter as it is typed. */
.aa-poem-caret {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0.8;
    pointer-events: none;
}

.aa-poem-intro-head {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: #b1c669;
    white-space: nowrap;
}

.aa-poem-intro-rule {
    width: 55%;
    height: 1px;
    margin: 3px 0 2px;
    background: linear-gradient(90deg, transparent, #e2c46a, transparent);
    transform-origin: center;
}

.aa-poem-intro-sub {
    max-width: 90%;
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    color: #d8ccb2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aa-poem-cta {
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 500;
    white-space: nowrap;
    /* a slow gold shimmer passing across the words */
    background: linear-gradient(100deg, #e2c46a 30%, #fff6d8 50%, #e2c46a 70%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: aa-poem-shimmer 2.8s linear infinite;
}

.aa-poem:hover .aa-poem-cta,
.aa-poem:focus-visible .aa-poem-cta {
    text-decoration: underline;
    text-decoration-color: rgba(226, 196, 106, 0.6);
    text-underline-offset: 3px;
}

.aa-poem-finale-by {
    margin-top: 2px;
    font-family: 'Caveat', 'Segoe Script', cursive;
    color: #d8ccb2;
}

.aa-poem-still-head {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: #b1c669;
    inset: 0 0 auto 0 !important;
    height: 30%;
}

.aa-poem-still-cta {
    font-size: 11px;
    font-style: italic;
    color: #e2c46a;
    inset: auto 0 0 0 !important;
    height: 28%;
}

@keyframes aa-poem-shimmer {
    from { background-position: 100% 0; }
    to   { background-position: -150% 0; }
}

/* ---- the dialog --------------------------------------------------------------------------- */

html.aa-poem-open {
    overflow: hidden;
}

.aa-poem-dialog {
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: transparent;
    color: #2b2418;
    overflow: visible;
}

.aa-poem-dialog::backdrop {
    background: rgba(18, 16, 24, 0.72);
    backdrop-filter: blur(3px);
}

.aa-poem-dialog[open] {
    animation: aa-poem-pop 0.45s cubic-bezier(.2, 1.3, .4, 1);
}

.aa-poem-card {
    position: relative;
    box-sizing: border-box;
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 36px 20px 24px;
    border-radius: 14px;
    /* parchment, a little darker at the edges */
    background:
        radial-gradient(ellipse at 50% 30%, #fbf5e6 0%, #f1e6cc 70%, #e6d6b2 100%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(115, 114, 68, 0.25);
}

.aa-poem-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #6b5d43;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}

.aa-poem-close:hover,
.aa-poem-close:focus-visible {
    background: rgba(115, 114, 68, 0.14);
    outline: none;
}

.aa-poem-kicker {
    font-family: 'Cinzel', 'Times New Roman', serif;
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #737244;
}

.aa-poem-kicker-date {
    letter-spacing: 0.04em;
    text-transform: none;
    color: #8f8060;
}

.aa-poem-title {
    margin: 10px 0 4px;
    font-family: 'Playfair Display', Georgia, serif;
    font-style: italic;
    font-weight: 500;
    font-size: clamp(24px, 5vw, 34px);
    line-height: 1.15;
    color: #2b2418;
}

.aa-poem-author {
    font-family: 'Caveat', 'Segoe Script', cursive;
    font-size: 22px;
    color: #8a4b3c;
}

.aa-poem-rule {
    width: 80px;
    height: 2px;
    margin: 14px 0 18px;
    background: linear-gradient(90deg, #a3812f, transparent);
}

.aa-poem-body {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 19px;
    line-height: 1.6;
}

.aa-poem-stanza + .aa-poem-stanza {
    margin-top: 1em;
}

.aa-poem-line {
    animation: aa-poem-line-in 0.6s cubic-bezier(.22, .9, .3, 1) both;
    animation-delay: calc(0.25s + var(--i, 0) * 0.07s);
}

.aa-poem-foot {
    margin-top: 26px;
    padding-top: 12px;
    border-top: 1px solid rgba(115, 114, 68, 0.25);
    font-size: 12px;
    color: #8f8060;
}

.aa-poem-foot a {
    color: #737244;
}

@keyframes aa-poem-pop {
    from { opacity: 0; transform: translateY(18px) scale(0.96); }
    to   { opacity: 1; transform: none; }
}

@keyframes aa-poem-line-in {
    from { opacity: 0; transform: translateX(-10px); filter: blur(2px); }
    to   { opacity: 1; transform: none; filter: none; }
}

@media (max-width: 600px) {
    .aa-poem-card { padding: 30px 11px 20px; }
    .aa-poem-body { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    .aa-poem-cta,
    .aa-poem-dialog[open],
    .aa-poem-line {
        animation: none;
    }
}
