/* Punsaurus — syllable-level rhymes & puns.
   Layout, type and colours come from modern.css; this file only styles the
   parts that are unique to this page. */

.pun-search {
    max-width: 760px;
    margin: 0 auto 34px;
    /* Clicking a chip scrolls back here (scrollToSearch in punsaurus.js). The
       site nav is sticky and 48px tall, so without this the box lands under it. */
    scroll-margin-top: 64px;
}

.pun-search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.pun-search-row input,
.pun-topic-row input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 14px 18px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1rem;
    color: var(--kb-text);
    background: rgb(var(--kb-ink) / 0.05);
    border: 2px solid rgb(var(--kb-ink) / 0.2);
    border-radius: 15px;
    outline: none;
    transition: all 0.3s ease;
}

.pun-topic-row input {
    padding: 10px 18px;
    font-size: 0.95rem;
}

/* The page's accent is the logo dino's green (#3ab54a sampled from
   punsaurus.png) rather than the site teal, so the mascot and the tool read as
   one thing. Text uses lighten it as needed: #4fc45e is 7.1:1 on the page
   background where the raw green is 5.97:1. */
.pun-search-row input:focus,
.pun-topic-row input:focus {
    border-color: #3ab54a;
    background-color: rgb(var(--kb-ink) / 0.08);
}

.pun-search-row button {
    padding: 14px 26px;
    font-family: 'Nunito', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--kb-fill-deep-label);
    background: var(--kb-fill-deep);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pun-search-row button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(61, 154, 150, 0.4);
}

.pun-search-row button:disabled {
    opacity: 0.5;
    cursor: wait;
}

/* ---------------- Results ---------------- */
.pun-results {
    max-width: 760px;
    margin: 0 auto;
}

/* Before a search the page is just a search bar, and More to Explore sitting
   right underneath reads as part of the tool. A rule and some air make it clear
   where the app stops. The empty case gets extra room since there's nothing
   between the bar and the link cards at all. */
.pun-results:empty {
    margin-bottom: 120px;
}

.pun-results + .section-heading {
    margin-top: 0;
    padding-top: 40px;
    border-top: 1px solid rgb(var(--kb-ink) / 0.12);
}

.result-card {
    margin-bottom: 22px;
    padding: 20px 22px;
    background: rgb(var(--kb-ink) / 0.05);
    border: 1px solid rgb(var(--kb-ink) / 0.1);
    border-radius: 14px;
}

.result-title {
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.result-subtitle {
    color: var(--kb-muted);
    font-size: 0.88rem;
    margin-bottom: 12px;
}

.status {
    margin-top: 26px;
    text-align: center;
    color: var(--kb-muted);
    font-style: italic;
    padding: 18px;
}

.status-error {
    color: var(--pun-red);
    background: rgb(var(--kb-accent-2-rgb) / 0.1);
    border: 1px solid rgb(var(--kb-accent-2-rgb) / 0.35);
    border-radius: 12px;
    font-style: normal;
}

/* Partial results: something is missing but the page still works, so this sits
   below the error red and above ordinary body copy. */
.status-warn {
    margin-top: 0;
    margin-bottom: 18px;
    color: var(--pun-amber);
    background: rgba(255, 190, 107, 0.1);
    border: 1px solid rgba(255, 190, 107, 0.32);
    border-radius: 12px;
    font-style: normal;
}

/* ---------------- Copy ---------------- */
.copy-btn {
    font-family: 'Nunito', sans-serif;
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--pun-violet);
    background: rgba(154, 138, 232, 0.14);
    border: 1px solid rgba(154, 138, 232, 0.4);
    border-radius: 12px;
    padding: 3px 11px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.copy-btn:hover {
    background: rgba(154, 138, 232, 0.32);
    color: var(--kb-text);
}

.copy-btn.is-done {
    color: var(--pun-mint);
    border-color: rgba(120, 220, 160, 0.5);
    background: rgba(120, 220, 160, 0.14);
}

/* Section-level button sits under the subtitle, before the grid. */
.result-card > .copy-btn {
    margin-bottom: 14px;
}

/* Per-pun buttons stay in flow, right-aligned. Absolute positioning would sit on
   top of the card text, and revealing them on hover would both shift the grid and
   leave touch users without them. Copy joins the row only once a definition is
   open, since a pun with nothing attached is just a word you could retype. */
.pun-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 8px;
}

/* Define is the payoff, so it reads as the primary action of the two. */
.define-btn {
    color: var(--pun-gold);
    background: rgba(255, 209, 102, 0.14);
    border-color: rgba(255, 209, 102, 0.45);
}

.define-btn:hover {
    background: rgba(255, 209, 102, 0.3);
    color: var(--kb-text);
}

/* ---------------- Syllable breakdown ---------------- */
.syllable-row {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 6px;
}

.syllable-box {
    text-align: center;
    background: rgba(58, 181, 74, 0.12);
    border: 1px solid rgba(58, 181, 74, 0.45);
    border-radius: 12px;
    padding: 10px 18px;
}

/* Only the boxes that have a chip row to jump to get this class, so the cursor
   never promises a jump the page cannot make. */
.syllable-box--jump {
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.syllable-box--jump:hover {
    background: rgba(58, 181, 74, 0.24);
    border-color: #4fc45e;
}

.syllable-box--jump:focus-visible {
    outline: 2px solid #4fc45e;
    outline-offset: 2px;
}

.syllable-chunk {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 1px;
}

.syllable-phones {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.72rem;
    color: var(--pun-sage);
    margin-top: 2px;
}

.syllable-dot {
    color: rgb(var(--kb-ink) / 0.4);
    font-size: 1.4rem;
    font-weight: 900;
}

/* Word boundary inside a phrase: a visible gap where syllables get a dot. */
.syllable-wordgap {
    display: inline-block;
    width: 18px;
}

.ipa-line {
    text-align: center;
    font-family: 'Consolas', 'Courier New', monospace;
    color: var(--kb-muted);
    margin-top: 8px;
}

/* ---------------- Puns ---------------- */
.pun-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    /* Each card sizes to its own content. Without this, grid items stretch to the
       tallest in the row, so closing one definition left the card full height
       while a neighbour was still open. */
    align-items: start;
}

.pun-item {
    background: rgb(var(--kb-ink) / 0.05);
    border: 1px solid rgb(var(--kb-ink) / 0.12);
    border-radius: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.pun-item:hover {
    border-color: rgba(255, 209, 102, 0.55);
}

.pun-item.on-topic {
    background: rgba(58, 181, 74, 0.08);
    border-color: rgba(58, 181, 74, 0.45);
}

.pun-topic {
    color: var(--pun-green);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.pun-def {
    color: var(--kb-muted);
    font-size: 0.85rem;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgb(var(--kb-ink) / 0.18);
}

.pun-word {
    font-size: 1.15rem;
    font-weight: 800;
}

.pun-swap {
    color: var(--pun-gold);
}

.pun-sep {
    color: rgb(var(--kb-ink) / 0.3);
    padding: 0 2px;
}

/* Word boundary in a phrase pun: a real space, wider than the syllable dot. */
.pun-wordgap {
    display: inline-block;
    width: 10px;
}

.pun-how {
    color: var(--kb-muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

/* ---------------- Chips ---------------- */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    font-family: 'Nunito', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--kb-text);
    background: rgba(154, 138, 232, 0.16);
    border: 1px solid rgba(154, 138, 232, 0.45);
    border-radius: 16px;
    padding: 5px 14px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.chip:hover {
    background: rgba(154, 138, 232, 0.35);
}

.syllable-group {
    margin-bottom: 12px;
    /* The padding is here rather than only on the hit state, or the row shifts
       sideways the moment it lights up. */
    padding: 6px 10px;
    margin-left: -10px;
    margin-right: -10px;
    border-radius: 10px;
    transition: background 0.35s ease;
}

/* Where a breakdown box just sent you. Removed again after 1.4s in
   linkSyllableBox; several rows fit on one screen, so without it a jump between
   two neighbours reads as nothing having happened. */
.syllable-group--hit {
    background: rgba(58, 181, 74, 0.18);
}

.syllable-empty {
    color: var(--kb-muted);
    font-size: 0.92rem;
    margin: 0;
}

.syllable-label {
    font-weight: 800;
    color: var(--pun-sage);
    margin-bottom: 6px;
}

/* The "Near rhymes" label inside the Rhymes card follows the perfect-rhyme
   chips directly; without this it sits closer to the chips above it than to
   its own. */
.chip-row + .syllable-label {
    margin-top: 22px;
}

/* ---------------- Definition ---------------- */
.definition-line {
    color: var(--kb-muted);
    margin-bottom: 8px;
}

.definition-pos {
    color: var(--pun-purple);
}

/* Book blue, from the book the logo dino is reading, lightened to 7.6:1 on the
   page background. Blue keeps "this is a link" legible while the green above
   carries the rest of the page. */
.clickable-word {
    color: var(--pun-blue);
    cursor: pointer;
    text-decoration: underline dotted;
}

.clickable-word:hover {
    text-decoration: underline;
}

/* The Datamuse/dictionary credit under the results. Muted on purpose: owed, not featured. */
.pun-credit {
    /* #999 rather than #888, from when the body was the navy gradient: #888 measured
       4.48:1 against its lightest stop, a hair under the 4.5 floor for small text. The
       Arcade background is darker, so both clear it now (5.25 and 6.54) and #999 simply
       stays rather than being re-picked. */
    color: var(--kb-muted);
    font-size: 0.85rem;
    text-align: center;
    margin: 30px 0 0;
}

.pun-credit a {
    color: var(--kb-muted);
}

@media (max-width: 520px) {
    .pun-search-row {
        flex-direction: column;
    }

    /* One column, not two. Two columns dates from when cards were bare words;
       now each carries Define/Copy buttons and can open a definition, which is
       cramped at half of a phone's width. */
    .pun-grid {
        grid-template-columns: 1fr;
    }
}

/* Share row sits above the first result card, right-aligned so it reads as a page
   control rather than a step in the results. Uses the same .copy-btn pill as
   "Copy all puns", since it is the same promise: something goes to your clipboard. */
.pun-share {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 14px;
}

/* ---------------- Keep list ---------------- */
/* Hidden by having no children rather than the hidden attribute, so there is no
   display rule for a [hidden] guard to lose to. */
.pun-keep:empty {
    display: none;
}

.keep-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.keep-head .result-title {
    margin-bottom: 0;
}

.keep-tools {
    display: flex;
    gap: 6px;
}

/* A kept pun reads as a chip in the swap colour, with its own remove control, so
   the basket and the swap highlight on the cards share one meaning. */
.keep-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: 'Nunito', sans-serif;
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--kb-text);
    background: rgba(255, 209, 102, 0.12);
    border: 1px solid rgba(255, 209, 102, 0.4);
    border-radius: 16px;
    padding: 3px 6px 3px 14px;
}

.keep-remove {
    min-width: 26px;
    height: 26px;
    background: none;
    border: 0;
    border-radius: 13px;
    color: rgb(var(--kb-ink) / 0.6);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.keep-remove:hover {
    color: var(--kb-text);
    background: rgb(var(--kb-ink) / 0.1);
}

.keep-btn.is-kept {
    color: var(--pun-gold);
    border-color: rgba(255, 209, 102, 0.5);
    background: rgba(255, 209, 102, 0.16);
}

/* Text colours, pastel on the dark page and dark on paper, where the pastels
   scored under 2:1. Light values are 5.5:1 or better on --kb-bg. */
:root {
    --pun-red: #ff8a8a;
    --pun-amber: #ffd08a;
    --pun-violet: #cfc6f5;
    --pun-mint: #9fe6b4;
    --pun-gold: #ffd166;
    --pun-sage: #a8dcae;
    --pun-green: #4fc45e;
    --pun-purple: #9a8ae8;
    --pun-blue: #8fb3ff;
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --pun-red: #a3192b;
        --pun-amber: #7d4a0c;
        --pun-violet: #513499;
        --pun-mint: #1f6b3a;
        --pun-gold: #7a5200;
        --pun-sage: #2f6b37;
        --pun-green: #23702f;
        --pun-purple: #513499;
        --pun-blue: #1f4fa8;
    }
}
:root[data-theme="light"] {
    --pun-red: #a3192b;
    --pun-amber: #7d4a0c;
    --pun-violet: #513499;
    --pun-mint: #1f6b3a;
    --pun-gold: #7a5200;
    --pun-sage: #2f6b37;
    --pun-green: #23702f;
    --pun-purple: #513499;
    --pun-blue: #1f4fa8;
}
