/* ==========================================================================
   Lumen & Ash — a small poetry press
   Shared styles for the index and all poem pages.
   Each poem page sets --accent / --accent-soft on <body> to re-tint the page.
   ========================================================================== */

:root {
    --ink: #08060d;
    --ink-raised: #100c1a;
    --paper: #f4f1ea;
    --muted: #9a93ad;
    --hairline: rgba(255, 255, 255, 0.09);

    --accent: #ff4fd8;
    --accent-soft: #a86bff;

    --serif: "Fraunces", "Iowan Old Style", Georgia, "Times New Roman", serif;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

    --measure: 34rem;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--ink);
    color: var(--paper);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Two ambient pools of accent light, plus a fine grain layer so the large
   dark areas don't band on cheap panels. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -2;
    background:
        radial-gradient(60rem 40rem at 12% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
        radial-gradient(50rem 40rem at 88% 8%, color-mix(in srgb, var(--accent-soft) 18%, transparent), transparent 70%),
        linear-gradient(180deg, #0b0812 0%, var(--ink) 55%);
    transition: background 900ms var(--ease);
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: 0.035;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

.shell {
    width: 100%;
    max-width: 68rem;
    margin: 0 auto;
    padding: 0 1.75rem;
}

/* --------------------------------------------------------------- typography */

h1,
h2,
h3 {
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin: 0;
}

.kicker {
    font-family: var(--sans);
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--accent);
    margin: 0;
}

.gradient-text {
    background: linear-gradient(100deg, var(--accent) 0%, var(--accent-soft) 55%, #fff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* -------------------------------------------------------------- site header */

.masthead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 2rem 0;
}

.wordmark {
    display: inline-flex;
    align-items: baseline;
    gap: 0.5rem;
    font-family: var(--serif);
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    color: var(--paper);
    text-decoration: none;
}

.wordmark .dot {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0.75rem var(--accent);
}

.masthead .issue {
    font-size: 0.72rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ------------------------------------------------------------------- hero */

.hero {
    padding: 4rem 0 3.5rem;
    max-width: 40rem;
}

.hero h1 {
    font-size: clamp(2.75rem, 7vw, 4.75rem);
    margin: 1.25rem 0 0;
}

.hero p {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 32rem;
    margin: 1.5rem 0 0;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    margin-top: 2.5rem;
}

/* ------------------------------------------------------- random poem button */

.shuffle {
    position: relative;
    isolation: isolate;
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.95rem 1.7rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(100deg, var(--accent), var(--accent-soft));
    color: #0a0710;
    font-family: var(--sans);
    font-size: 0.92rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 400ms var(--ease), box-shadow 400ms var(--ease);
    box-shadow: 0 0.6rem 2rem -0.5rem color-mix(in srgb, var(--accent) 65%, transparent);
}

/* Soft halo that swells on hover. */
.shuffle::after {
    content: "";
    position: absolute;
    inset: -2px;
    z-index: -1;
    border-radius: inherit;
    background: linear-gradient(100deg, var(--accent), var(--accent-soft));
    filter: blur(14px);
    opacity: 0.5;
    transition: opacity 400ms var(--ease);
}

.shuffle:hover,
.shuffle:focus-visible {
    transform: translateY(-3px) scale(1.02);
}

.shuffle:hover::after,
.shuffle:focus-visible::after {
    opacity: 0.9;
}

.shuffle:active {
    transform: translateY(-1px) scale(0.99);
}

.shuffle .die {
    display: inline-block;
    font-size: 1.05rem;
    transition: transform 500ms var(--ease);
}

.shuffle:hover .die {
    transform: rotate(22deg) scale(1.12);
}

/* While cycling titles, the label shouldn't reflow the button. */
.shuffle.is-shuffling {
    pointer-events: none;
}

.shuffle .label {
    min-width: 9.5rem;
    text-align: left;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.hint kbd {
    font-family: var(--sans);
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 0.35rem;
    border: 1px solid var(--hairline);
    background: rgba(255, 255, 255, 0.05);
    color: var(--paper);
}

/* ------------------------------------------------------------ section label */

.section-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 2.5rem;
}

.section-head h2 {
    font-size: 1.35rem;
}

.section-head .count {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-left: auto;
}

/* ------------------------------------------------------------------- cards */

.poem-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
    gap: 1.5rem;
    padding-bottom: 5rem;
    list-style: none;
    margin: 0;
}

.card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    min-height: 19rem;
    padding: 1.75rem;
    border: 1px solid var(--hairline);
    border-radius: 1.25rem;
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
    color: inherit;
    text-decoration: none;
    overflow: hidden;
    transition:
        transform 500ms var(--ease),
        border-color 500ms var(--ease),
        box-shadow 500ms var(--ease);
}

/* Accent wash that fades in behind the text on hover. */
.card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    opacity: 0;
    background: radial-gradient(28rem 18rem at 85% 0%, color-mix(in srgb, var(--card-accent) 30%, transparent), transparent 65%);
    transition: opacity 500ms var(--ease);
}

/* Hairline that draws itself across the top edge. */
.card::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--card-accent), transparent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 600ms var(--ease);
}

.card:hover,
.card:focus-visible {
    transform: translateY(-0.5rem);
    border-color: color-mix(in srgb, var(--card-accent) 55%, transparent);
    box-shadow:
        0 1.5rem 3rem -1.5rem rgba(0, 0, 0, 0.85),
        0 0 0 1px color-mix(in srgb, var(--card-accent) 18%, transparent),
        0 0 3.5rem -1.5rem color-mix(in srgb, var(--card-accent) 75%, transparent);
}

.card:hover::before,
.card:focus-visible::before {
    opacity: 1;
}

.card:hover::after,
.card:focus-visible::after {
    transform: scaleX(1);
}

.card .numeral {
    font-family: var(--serif);
    font-size: 0.8rem;
    letter-spacing: 0.2em;
    color: var(--card-accent);
    opacity: 0.85;
}

.card h3 {
    font-size: 1.6rem;
    margin: 0.9rem 0 0;
    transition: color 400ms var(--ease);
}

.card:hover h3,
.card:focus-visible h3 {
    color: var(--card-accent);
}

.card .excerpt {
    margin: 1rem 0 0;
    color: #cfc9dd;
    font-size: 0.95rem;
    font-style: italic;
    white-space: pre-line; /* excerpt keeps its own line breaks */
}

.card .meta {
    margin: 1.15rem 0 0;
    font-size: 0.72rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

.card .cta {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1.5rem;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--card-accent);
}

.card .cta .arrow {
    transition: transform 450ms var(--ease);
}

.card:hover .cta .arrow,
.card:focus-visible .cta .arrow {
    transform: translateX(0.4rem);
}

/* Card entrance — staggered by --i, set inline when the card is built. */
.card {
    animation: rise 750ms var(--ease) backwards;
    animation-delay: calc(var(--i, 0) * 90ms + 120ms);
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(1.75rem);
    }
}

/* Highlight used by the random-poem button as it cycles through cards. */
.card.is-target {
    border-color: var(--card-accent);
    box-shadow: 0 0 3rem -1rem color-mix(in srgb, var(--card-accent) 80%, transparent);
}

/* ============================== poem pages ============================== */

.poem-page .masthead {
    border-bottom: 1px solid var(--hairline);
}

.poem-wrap {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 4.5rem 0 3rem;
}

.poem-head {
    text-align: center;
    padding-bottom: 3rem;
}

.poem-head h1 {
    font-size: clamp(2.25rem, 6vw, 3.4rem);
    margin: 1rem 0 0;
}

.poem-head .byline {
    margin: 1.25rem 0 0;
    font-size: 0.78rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
}

/* Short accent rule under the title. */
.rule {
    width: 4.5rem;
    height: 2px;
    margin: 2rem auto 0;
    border: 0;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.poem {
    font-family: var(--serif);
    font-size: 1.28rem;
    /* Tight enough that lines within a stanza hold together, so the stanza
       margin below is what the eye reads as a break. */
    line-height: 1.6;
    letter-spacing: -0.005em;
    color: #ece7f5;
}

.poem .stanza {
    margin: 0 0 2.35rem;
}

.poem .stanza:last-child {
    margin-bottom: 0;
}

.poem .line {
    display: block;
}

/* Indented continuation lines, for the long ones that wrap. */
.poem .line.indent {
    padding-left: 2.25rem;
}

/* Line-by-line reveal. JS adds .is-lit once the page is ready; without JS the
   :not() guard below keeps everything visible. */
.js .poem .line {
    opacity: 0;
    transform: translateY(0.6rem);
    transition: opacity 800ms var(--ease), transform 800ms var(--ease);
}

.js .poem .line.is-lit {
    opacity: 1;
    transform: none;
}

.poem-foot {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 3.5rem 0 5rem;
    border-top: 1px solid var(--hairline);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

/* ------------------------------------------------------------------- links */

.back {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1.35rem;
    border: 1px solid var(--hairline);
    border-radius: 999px;
    color: var(--paper);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition:
        border-color 400ms var(--ease),
        background-color 400ms var(--ease),
        transform 400ms var(--ease),
        color 400ms var(--ease);
}

.back .arrow {
    transition: transform 400ms var(--ease);
}

.back:hover,
.back:focus-visible {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 60%, transparent);
    background-color: color-mix(in srgb, var(--accent) 10%, transparent);
    transform: translateY(-2px);
}

.back:hover .arrow,
.back:focus-visible .arrow {
    transform: translateX(-0.35rem);
}

.next-poem {
    display: inline-flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: right;
    text-decoration: none;
    color: var(--paper);
    transition: color 400ms var(--ease);
}

.next-poem .label {
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
}

.next-poem .title {
    font-family: var(--serif);
    font-size: 1.15rem;
}

.next-poem:hover,
.next-poem:focus-visible {
    color: var(--accent);
}

/* ------------------------------------------------------------------ footer */

.site-foot {
    padding: 2.5rem 0 3rem;
    border-top: 1px solid var(--hairline);
    color: var(--muted);
    font-size: 0.8rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: space-between;
}

/* ------------------------------------------------- focus, motion, no-script */

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.noscript {
    padding: 1rem 1.25rem;
    margin-bottom: 2rem;
    border: 1px solid var(--hairline);
    border-radius: 0.75rem;
    background: rgba(255, 255, 255, 0.04);
    color: var(--muted);
    font-size: 0.9rem;
}

.noscript a {
    color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .js .poem .line {
        opacity: 1;
        transform: none;
    }

    .card:hover {
        transform: none;
    }
}

@media (max-width: 40rem) {
    .shell {
        padding: 0 1.25rem;
    }

    .hero {
        padding: 2.5rem 0;
    }

    .poem {
        font-size: 1.15rem;
    }

    .poem .line.indent {
        padding-left: 1.25rem;
    }

    .poem-foot {
        flex-direction: column;
        align-items: flex-start;
    }

    .next-poem {
        text-align: left;
    }
}
