:root,
:root[data-theme="light"] {
    --bg: #f3f6fc;
    --bg-rgb: 243, 246, 252;
    --surface: #ffffff;
    --text: #0f1b33;
    --muted: #5b6780;
    --border: #dde3ef;
    --accent: #1f5fd1;
    --accent-hover: #174bab;
    --accent-text: #ffffff;
    --idea-bg: #eef3fd;
    --title: #12306b;
    --shadow: 0 1px 2px rgba(15, 27, 51, 0.05), 0 8px 24px rgba(15, 27, 51, 0.06);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #040e27;
    --bg-rgb: 4, 14, 39;
    --surface: #0a1a3d;
    --text: #e8eefc;
    --muted: #93a2c4;
    --border: #17294f;
    --accent: #4d8dff;
    --accent-hover: #6da2ff;
    --accent-text: #040e27;
    --idea-bg: #0e2250;
    --title: #ffffff;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    transition: background 0.2s, color 0.2s;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* vertical centering of logo, title, subtitle and button */
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
    padding: 1rem 1rem 3rem;
}

/* Toolbar: language + theme toggles */
.toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
}

/* Language picker: current flag + code, with a menu of every language */
.lang { position: relative; }

.lang-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    height: 2.1rem;
    padding: 0 0.6rem;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.lang-btn:hover { border-color: var(--accent); }
.lang-chevron { color: var(--muted); transition: transform 0.15s; }
.lang-btn[aria-expanded="true"] .lang-chevron { transform: rotate(180deg); }

.flag {
    display: inline-flex;
    flex: none;
    width: 22px;
    height: 15px;
    overflow: hidden;
    border-radius: 3px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.flag svg { display: block; width: 100%; height: 100%; }

.lang-menu {
    position: absolute;
    top: calc(100% + 0.35rem);
    right: 0;
    z-index: 30;
    min-width: 11rem;
    margin: 0;
    padding: 0.3rem;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.lang-menu[hidden] { display: none; }

.lang-menu button {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    font: inherit;
    font-size: 0.9rem;
    color: var(--text);
    text-align: left;
    background: none;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
}

.lang-menu button:hover { background: var(--idea-bg); }
.lang-menu button[aria-selected="true"] { font-weight: 700; color: var(--accent); }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
}

.icon-btn:hover { color: var(--text); }

.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

.lang-btn:focus-visible, .lang-menu button:focus-visible, .icon-btn:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Hero */
.hero {
    text-align: center;
    margin: 0.5rem 0 2rem;
}

.logo {
    display: block;
    margin: 0 auto 0.75rem;
    height: 6rem;
    width: auto;
}

/* The crowned logo is taller (306x471 vs 612x756 at the same bulb width), so give it the matching height:
   the bulb keeps the same size and the crown sits on top. */
.logo.crowned { height: 7.5rem; }

.logo-link { display: inline-block; border-radius: 8px; }
.logo-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.logo-link .logo { margin-bottom: 0.75rem; transition: transform 0.15s; }
.logo-link:hover .logo { transform: scale(1.04); }

h1 {
    margin: 0;
    font-family: "Poppins", "Inter", sans-serif;
    font-size: 2.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--title);
}

/* Each part of the title gets its own weight/colour: whats[my][idea].com */
h1 .w-whats { font-weight: 300; }
h1 .w-my { font-weight: 800; color: var(--accent); }
h1 .w-idea { font-weight: 800; }
h1 .w-com { font-weight: 300; color: var(--muted); }

.subtitle {
    margin: 0.25rem 0 0;
    font-size: 1.05rem;
    color: var(--muted);
}

/* Panel */
/* No card around the button, so the space reserved for the result stays invisible until used. */
.panel { text-align: center; }

.btn {
    font: inherit;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    transition: background 0.15s;
}

.btn:hover:not(:disabled) { background: var(--accent-hover); }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Reserve space so the centered layout does not jump when the result appears. */
/* Premium accents (the server adds data-premium to <html> while premium is active) */
html[data-premium="1"] .tokens-icon { color: #e0a800; }
html[data-premium="1"] .donate { color: #e0a800; border-color: #e0a800; }
html[data-premium="1"] .donate:hover { background: #e0a800; color: #1a1300; }

/* Premium / Thanks pages */
.code-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.code-box {
    padding: 0.4rem 0.8rem;
    font-size: 1rem;
    letter-spacing: 0.04em;
    word-break: break-all;
    color: var(--text);
    background: var(--idea-bg);
    border: 1px dashed var(--accent);
    border-radius: 8px;
}

.btn-small {
    display: inline-block;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
}

.prose a.btn-small { color: var(--accent-text); }
.btn-small:hover { background: var(--accent-hover); }

.honor {
    padding: 0.8rem 1rem;
    background: var(--idea-bg);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
}

.redeem { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.redeem input {
    flex: 1 1 16rem;
    font: inherit;
    padding: 0.45rem 0.7rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.redeem-msg { min-height: 1.5rem; color: var(--muted); }

/* Daily token counter under the button */
.tokens {
    margin: 0.9rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.tokens[hidden] { display: none; }
.tokens-icon { color: var(--accent); }
.tokens-more { margin-left: 0.5rem; font-weight: 600; color: var(--accent); }
.tokens-more[hidden] { display: none; }
.tokens-reset { margin-left: 0.4rem; opacity: 0.85; }
.tokens-reset:not(:empty)::before { content: "\00B7"; margin-right: 0.4rem; }
.tokens.low { color: var(--text); }
.tokens.low .tokens-icon { color: #d9822b; }
.tokens.spent .tokens-icon { animation: spend 0.6s ease-out; }

@keyframes spend {
    0% { transform: scale(1); }
    40% { transform: scale(1.6) rotate(-15deg); }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .tokens.spent .tokens-icon { animation: none; }
}

.output { margin-top: 1.5rem; min-height: 7.5rem; }

/* Nothing to show yet (no idea, no waiting state): give the space back so the idea of the day sits right
   under the button. The room is reserved again as soon as an idea or the waiting state appears. */
.output:not(:has(.idea:not([hidden]), .status:not([hidden]))) { margin-top: 0; min-height: 0; }

/* Waiting state: small, muted, with spinner and progress bar. */
.status {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.status[hidden], .idea[hidden] { display: none; }

.spinner {
    width: 0.9rem;
    height: 0.9rem;
    border: 2px solid var(--border);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.progress {
    flex-basis: 100%;
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
}

.progress span.run { animation: fill 5s linear forwards; }

/* Result state: prominent card. */
.idea {
    background: var(--idea-bg);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    animation: reveal 0.35s ease-out;
    box-shadow: var(--shadow);
}

.idea-label {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.idea-text {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    line-height: 1.35;
}

/* Idea of the day */
.day {
    margin-top: 2rem;
    padding: 1rem 1.25rem;
    text-align: center;
    background: rgba(var(--bg-rgb), 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
}

.day-label {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.day-text { margin: 0 0 0.5rem; font-weight: 600; }
.day-link { font-size: 0.85rem; color: var(--accent); }

/* "How it works": a pill that opens a card with the steps, plus a short always-visible blurb */
.how { margin-top: 1.25rem; text-align: center; }
.how-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: rgba(var(--bg-rgb), 0.7);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem 0.35rem 0.5rem;
    cursor: pointer;
}
.how-toggle:hover { border-color: var(--accent); }
.how-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.how-icon {
    display: inline-grid;
    place-items: center;
    width: 1.3rem;
    height: 1.3rem;
    border-radius: 50%;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.8rem;
    font-weight: 700;
}
.how-chevron { transition: transform 0.2s; }
.how-toggle[aria-expanded="true"] .how-chevron { transform: rotate(180deg); }
.how-panel {
    margin-top: 0.75rem;
    padding: 0.5rem 1.25rem;
    text-align: left;
    background: rgba(var(--bg-rgb), 0.85);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.how-panel[hidden] { display: none; }
.how-panel ol { margin: 0.5rem 0; padding-left: 1.25rem; }
.how-panel li { margin: 0.4rem 0; }

.blurb {
    margin: 1.25rem 0 0;
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    color: var(--muted);
    background: rgba(var(--bg-rgb), 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.blurb p { margin: 0; }

/* Share row inside the result card */
.share {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.share[hidden] { display: none; }

.share-label {
    margin-right: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.share a, .share button {
    font: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    cursor: pointer;
}

.share button[hidden] { display: none; }
.share a:hover, .share button:hover { border-color: var(--accent); color: var(--accent); }
.share a:focus-visible, .share button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ad { margin: 2rem 0 0; min-height: 100px; } /* room for the ad, so the page does not jump when it loads */
.ad:has(ins[data-ad-status="unfilled"]) { display: none; } /* no ad served (for example before AdSense approves the site): give the space back */

/* Side unit (wide screens only): in the margin right of the 42rem page column, scrolls with the page. */
.ad-side { display: none; }
@media (min-width: 1100px) {
    .ad-side { display: block; position: absolute; top: 9rem; left: calc(50% + 21rem + 1.5rem); width: 160px; height: 600px; }
}

/* Language blocks on the Privacy / About / Contact pages */
.t-en, .t-es, .t-pt, .t-de, .t-fr { display: none; }
html[lang|="en"] .t-en, html[lang|="es"] .t-es, html[lang|="pt"] .t-pt, html[lang|="de"] .t-de, html[lang|="fr"] .t-fr { display: revert; }

.toolbar .home-link {
    margin-right: auto;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.prose {
    background: rgba(var(--bg-rgb), 0.85);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 2rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(6px);
}

.prose h1 { font-size: 1.8rem; color: var(--title); margin-bottom: 0.25rem; }
.prose h2 { font-size: 1.1rem; margin: 1.5rem 0 0.4rem; }
.prose p, .prose li { color: var(--text); }
.prose .updated { color: var(--muted); font-size: 0.85rem; margin-top: 0; }
.prose a { color: var(--accent); }

.footer-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.25rem 1.1rem; margin-bottom: 0.6rem; }
.footer-links a, .footer-links button {
    font: inherit;
    font-size: 0.85rem;
    color: var(--muted);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-decoration: none;
}
.footer-links a:hover, .footer-links button:hover { color: var(--accent); }
.footer-links button[hidden] { display: none; }

.donate {
    display: inline-block;
    margin-bottom: 0.8rem;
    padding: 0.35rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    border: 1px solid var(--accent);
    border-radius: 999px;
}
.donate:hover { background: var(--accent); color: var(--accent-text); }


/* Background photo: sits behind everything; the gradient keeps text readable in both themes. */
.bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.bg.loaded { opacity: 1; }

.bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        rgba(var(--bg-rgb), 0.88) 0%,
        rgba(var(--bg-rgb), 0.68) 45%,
        rgba(var(--bg-rgb), 0.92) 100%);
}

.version { margin-left: 0.4rem; padding: 0.05rem 0.45rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.75rem; }

.credit { margin-bottom: 0.5rem; font-size: 0.75rem; }
.credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.credit a:hover { color: var(--accent); }

.site-footer {
    padding: 1.5rem 1rem;
    text-align: center;
    font-size: 0.85rem;
    color: var(--muted);
    border-top: 1px solid var(--border);
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fill { to { width: 100%; } }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 480px) {
    h1 { font-size: 1.7rem; }
    .idea-text { font-size: 1.2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .spinner, .idea { animation: none; }
}

/* Link from a freshly generated idea to its own page */
.idea-page-link { display: inline-block; margin-top: 0.6rem; font-size: 0.9rem; color: var(--accent); }
.idea-page-link[hidden] { display: none; }

/* Idea pages: previous / random / next, more ideas, breadcrumbs */
.idea-nav { margin-top: 1.5rem; text-align: center; }
.idea-nav-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.idea-nav-title { font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 1.5rem 0 0.5rem; }
.more-ideas { list-style: none; margin: 0; padding: 0; text-align: left; }
.more-ideas li { padding: 0.55rem 0.9rem; margin: 0.4rem 0; background: rgba(var(--bg-rgb), 0.7); border: 1px solid var(--border); border-radius: 10px; }
.more-ideas a { color: var(--text); text-decoration: none; }
.more-ideas a:hover { color: var(--accent); }
.more-ideas .all-ideas { text-align: center; background: none; border: 0; }
.more-ideas .all-ideas a { color: var(--accent); font-size: 0.9rem; }
.crumbs { margin: 1rem 0 0; font-size: 0.8rem; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* Ideas hub */
.hub .crumbs { margin: 0 0 0.75rem; }
.hub .muted { color: var(--muted); font-size: 0.85rem; }
.hub-list { padding-left: 2.2rem; }
.hub-list li { margin: 0.45rem 0; }
.hub-list a { color: var(--text); text-decoration: none; }
.hub-list a:hover { color: var(--accent); text-decoration: underline; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; margin-top: 1.25rem; }
.pager a, .pager span { min-width: 2rem; padding: 0.3rem 0.6rem; text-align: center; border: 1px solid var(--border); border-radius: 8px; color: var(--text); text-decoration: none; }
.pager a:hover { border-color: var(--accent); color: var(--accent); }
.pager [aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* "More from Pragmify" line in the footer */
.more-from { margin: 0 0 0.6rem; font-size: 0.8rem; color: var(--muted); }
.more-from a { color: var(--muted); }
.more-from a:hover { color: var(--accent); }
