@font-face {
    font-family: "Space Grotesk";
    src: url("./fonts/space-grotesk.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
}

:root {
    color-scheme: dark;
    font-family: "Space Grotesk", system-ui, sans-serif;
    --bg: #100b19;
    --surface: #181022;
    --ink: #f9f1ff;
    --muted: #baaacb;
    --accent: #e4b7ff;
    --aqua: #a7e6ea;
    --line: #3a2a4b;
    --frame: min(100% - clamp(2.25rem, 9vw, 9rem), 80rem);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    display: grid;
    grid-template-rows: auto 1fr auto;
    min-height: 100vh;
    min-height: 100svh;
    margin: 0;
    background: radial-gradient(ellipse at 50% 46%, #22142d 0%, transparent 64%), var(--bg);
    color: var(--ink);
}

button, select { font: inherit; }
a { color: inherit; }
a:focus-visible, button:focus-visible, select:focus-visible {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
}

.frame { width: var(--frame); margin-inline: auto; }

.site-header {
    display: flex;
    min-height: 5.25rem;
    align-items: center;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    font-size: 1.24rem;
    font-weight: 700;
    letter-spacing: -0.055em;
    text-decoration: none;
}

.brand-mark { flex: none; }
.brand-tld { color: var(--accent); }

.stage {
    display: grid;
    place-items: center;
    padding-block: 1.5rem clamp(1.5rem, 8vh, 6.75rem);
}

.content {
    width: min(100%, 41rem);
    min-width: 0;
    animation: arrive 650ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.quote-card {
    display: grid;
    position: relative;
    min-height: clamp(8rem, 24vh, 12rem);
    place-items: center;
    overflow: hidden;
    padding: clamp(1.25rem, 4.4vw, 2.6rem);
    border: 1px solid var(--line);
    border-inline-start: 2px solid #bb8ce0;
    border-radius: 0.85rem;
    background: linear-gradient(130deg, #261935, var(--surface) 72%);
}

.button svg {
    width: 1.2rem;
    height: 1.2rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

blockquote { width: 100%; margin: 0; text-align: center; }
blockquote p {
    margin: 0;
    font-size: clamp(1.24rem, 2.65vw, 2.05rem);
    font-weight: 500;
    line-height: 1.23;
    letter-spacing: -0.032em;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.quote-progress {
    position: absolute;
    inset: auto 0 0;
    height: 2px;
    overflow: hidden;
    visibility: hidden;
}

.quote-progress::before {
    display: block;
    width: 42%;
    height: 100%;
    background: linear-gradient(90deg, transparent, var(--accent), var(--aqua), transparent);
    content: "";
}

.quote-card[aria-busy="true"] .quote-progress { visibility: visible; }
.quote-card[aria-busy="true"] .quote-progress::before { animation: receive 1.1s linear infinite; }

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.7rem;
    margin-block: 0.95rem 1rem;
}

.button {
    display: inline-flex;
    min-height: 3.2rem;
    align-items: center;
    justify-content: center;
    gap: 0.58rem;
    padding: 0.72rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 180ms, border-color 180ms, box-shadow 180ms, transform 180ms;
}

.button-primary { background: var(--accent); color: #20112e; }

.button-speech { min-inline-size: 9rem; }
.button-speech, .button-autoplay {
    border-color: #5d456f;
    background: #21172d;
    color: var(--ink);
}
.button-speech.speaking, .button-autoplay:has(input:checked) {
    border-color: var(--accent);
    background: #342045;
}
.button:not(:disabled):active { transform: translateY(2px); }
.button:disabled { opacity: 0.58; cursor: default; }
#stop-icon { fill: currentColor; stroke: none; }

.option-row {
    display: flex;
    max-width: 32rem;
    margin-inline: auto;
    align-items: center;
    gap: 0.65rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.option-row + .option-row { margin-top: 0.5rem; }
.option-row label { min-width: 3.2rem; }

.option-row select {
    min-width: 0;
    min-height: 2.75rem;
    flex: 1;
    appearance: none;
    padding: 0.51rem 2rem 0.51rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 0.55rem;
    background:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 1rem) 50% / 5px 5px no-repeat,
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 0.7rem) 50% / 5px 5px no-repeat,
        var(--surface);
    color: var(--ink);
    text-overflow: ellipsis;
}

.button-autoplay input {
    width: 1.2rem;
    height: 1.2rem;
    flex: none;
    margin: 0;
    accent-color: var(--accent);
}

.button-autoplay:has(input:focus-visible) {
    outline: 2px solid var(--aqua);
    outline-offset: 4px;
}

.feedback { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.9rem; text-align: center; }
.feedback:empty { margin: 0; }
.feedback.error { color: #ffc0c5; }

.site-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1rem;
    padding-block: 0.45rem 0.65rem;
    color: var(--muted);
    font-size: 0.75rem;
}

.site-footer a, .site-footer button {
    display: inline-flex;
    min-height: 2rem;
    align-items: center;
    padding: 0 0.2rem;
    border: 0;
    background: none;
    color: inherit;
    text-decoration: none;
}

.site-footer button { cursor: pointer; }

body:has(.cookie-dialog[open]) { overflow: hidden; }

.cookie-dialog {
    width: min(100% - 2rem, 29rem);
    padding: clamp(1.15rem, 5vw, 1.8rem);
    border: 1px solid #674a84;
    border-radius: 0.85rem;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1.4rem 5rem #07040bd0;
}

.cookie-dialog::backdrop { background: #08050dcc; }
.cookie-dialog h2 { margin: 0; font-size: 1.45rem; line-height: 1.2; }
.cookie-dialog p { margin: 0.7rem 0; color: var(--muted); line-height: 1.45; }
#cookie-status { color: var(--aqua); font-size: 0.9rem; }

.cookie-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr));
    gap: 0.6rem;
    margin-block: 1.15rem 0.85rem;
}

.cookie-actions button {
    min-height: 2.85rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid #674a84;
    border-radius: 0.55rem;
    background: #291a37;
    color: var(--ink);
    font-weight: 600;
    cursor: pointer;
}

.cookie-actions #cookies-preferences { border-color: #466654; background: #192b22; }
.cookie-legal { color: var(--muted); font-size: 0.875rem; }

@media (hover: hover) and (pointer: fine) {
    .button-primary:hover:not(:disabled) {
        background: #f1d2ff;
        box-shadow: 0 0 1.7rem #c88dff38;
    }

    .button-speech:where(:hover:not(:disabled)),
    .button-autoplay:where(:hover:not(:has(input:disabled))) {
        border-color: #9074aa;
        background: #2b1d3a;
    }

    .site-footer a:hover, .site-footer button:hover { color: var(--ink); text-decoration: underline; }
    .cookie-actions button:hover { border-color: var(--accent); background: #352047; }
    .cookie-actions #cookies-preferences:hover { border-color: #a4d3b8; background: #21382b; }
}

@keyframes arrive {
    from { opacity: 0; transform: translateY(0.85rem); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes receive {
    from { transform: translateX(-100%); }
    to { transform: translateX(245%); }
}

@media (max-width: 760px) {
    .site-header { min-height: 4.65rem; }
}

@media (max-width: 430px) {
    .controls { flex-wrap: nowrap; gap: 0.45rem; }
    .controls .button {
        min-inline-size: 0;
        flex: 1 1 0;
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.45rem 0.25rem;
        font-size: 0.875rem;
        line-height: 1.2;
        text-align: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .quote-progress::before { width: 100%; }
}
