/* Palabras — a typographic specimen for the word collection.
   Self-contained, like beliefs.css: this page carries its own type scale and
   palette so it can be a little louder than the rest of the site. */

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

:root {
    color-scheme: light dark;

    --pl-bg: #fbfaf8;
    --pl-bg-sunk: #f3f1ec;
    --pl-fg: #1a1a19;
    --pl-fg-muted: #5c584f;
    /* Dim carries the small uppercase labels, so it has to clear 4.5:1
       against the paper even though it reads as a whisper. */
    --pl-fg-dim: #767065;
    --pl-ghost: #d9d4c7;
    --pl-rule: #e2ded4;
    --pl-rule-soft: #ebe7de;
    /* Gold, shared with Beliefs — the two special pages read as siblings.
       Darkened here to clear 4.5:1 against the paper. */
    --pl-accent: #8a6a24;

    --pl-serif: 'Source Serif 4', Georgia, serif;
    --pl-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --pl-gutter: clamp(20px, 5vw, 80px);
    --pl-measure: 1180px;

    --pl-ease: cubic-bezier(0.23, 1, 0.32, 1);
    --pl-dur: 200ms;

    /* Height of the sticky control bar, for anything that has to clear it.
       Without JS the bar never appears, so zero is correct; .pl-js carries the
       estimate, and JS overwrites it with the measured height. Keep the two in
       step if the bar gains or loses a row. */
    --pl-stick: 0rem;
}

/* The bar is a fixed two rows — chips, status — so a rem estimate tracks it
   across font sizes. Chips scroll rather than wrap precisely so this stays
   true at every width. */
.pl-js { --pl-stick: 5.5rem; }

@media (prefers-color-scheme: dark) {
    :root {
        --pl-bg: #111110;
        --pl-bg-sunk: #191816;
        --pl-fg: #e9e6e0;
        --pl-fg-muted: #a29c92;
        --pl-fg-dim: #847e73;
        --pl-ghost: #2d2b28;
        --pl-rule: #262421;
        --pl-rule-soft: #1d1c19;
        --pl-accent: #c9a55a;
    }
}

html {
    /* Fluid, but anchored to the reader's own text-size setting. */
    font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    scroll-behavior: smooth;
}

@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;
    }
}

body {
    font-family: var(--pl-serif);
    font-optical-sizing: auto;
    background: var(--pl-bg);
    color: var(--pl-fg);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

p { text-wrap: pretty; }

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

::selection {
    background: color-mix(in srgb, var(--pl-accent) 26%, transparent);
}

/* ---- Nav ---- */

.pl-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    max-width: var(--pl-measure);
    margin: 0 auto;
    padding: 2rem var(--pl-gutter);
}

.pl-nav-name {
    font-family: var(--pl-sans);
    font-size: 1rem;
    font-weight: 600;
    color: var(--pl-fg);
    text-decoration: none;
}

.pl-nav-links {
    display: flex;
    gap: clamp(1rem, 3vw, 2rem);
}

.pl-nav-links a {
    font-family: var(--pl-sans);
    font-size: 0.875rem;
    color: var(--pl-fg-dim);
    text-decoration: none;
    transition: color var(--pl-dur) var(--pl-ease);
}

@media (hover: hover) and (pointer: fine) {
    .pl-nav-name:hover,
    .pl-nav-links a:hover { color: var(--pl-accent); }
}

/* ---- Shell ---- */

.pl-main {
    max-width: var(--pl-measure);
    margin: 0 auto;
    padding: 0 var(--pl-gutter);
}

/* ---- Hero ---- */

.pl-hero {
    padding: clamp(3rem, 9vw, 7rem) 0 clamp(2.5rem, 5vw, 4rem);
}

.pl-title {
    font-weight: 300;
    /* Source Serif's optical-size axis tops out at 60 — at this scale the
       display cut is the whole point of the page. */
    font-size: clamp(3.75rem, 15vw, 10rem);
    line-height: 0.92;
    letter-spacing: -0.045em;
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.pl-title-word { display: block; }

.pl-title-word > span {
    display: inline-block;
    animation: pl-rise 800ms var(--pl-ease) backwards;
}

/* Letters arrive left to right, quickly enough to read as one gesture. */
.pl-title-word > span:nth-child(1) { animation-delay:   0ms; }
.pl-title-word > span:nth-child(2) { animation-delay:  45ms; }
.pl-title-word > span:nth-child(3) { animation-delay:  90ms; }
.pl-title-word > span:nth-child(4) { animation-delay: 135ms; }
.pl-title-word > span:nth-child(5) { animation-delay: 180ms; }
.pl-title-word > span:nth-child(6) { animation-delay: 225ms; }
.pl-title-word > span:nth-child(7) { animation-delay: 270ms; }
.pl-title-word > span:nth-child(8) { animation-delay: 315ms; }

@keyframes pl-rise {
    from { opacity: 0; transform: translateY(0.18em); }
    to   { opacity: 1; transform: none; }
}

.pl-lede {
    max-width: 34em;
    font-size: clamp(1.05rem, 1.6vw, 1.2rem);
    line-height: 1.65;
    color: var(--pl-fg-muted);
}

.pl-count-line {
    margin-top: 1.5rem;
    font-family: var(--pl-sans);
    font-size: 0.75rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pl-fg-dim);
}

.pl-total {
    color: var(--pl-accent);
    font-weight: 600;
}

/* ---- Controls ---- */

.pl-controls {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    /* Bleed the blurred bar to the gutter edges so text doesn't slide out
       from under it at the margins. */
    margin: 0 calc(var(--pl-gutter) * -1);
    padding: 1rem var(--pl-gutter);
    background: color-mix(in srgb, var(--pl-bg) 86%, transparent);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    border-bottom: 1px solid var(--pl-rule);
}

/* backdrop-filter is widely supported now, but an opaque bar is the correct
   fallback — a translucent one over scrolling text is unreadable. */
@supports not (backdrop-filter: blur(12px)) {
    .pl-controls { background: var(--pl-bg); }
}

.pl-controls[hidden] { display: none; }

.pl-filters {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.4rem;
    /* Scrolling beats wrapping here: it keeps the sticky bar a fixed height
       instead of letting it grow to three rows on a phone. */
    overflow-x: auto;
    scrollbar-width: none;
    /* Room for the focus ring, which would otherwise be clipped by overflow. */
    padding: 3px;
    margin: -3px;
}

.pl-filters::-webkit-scrollbar { display: none; }

.pl-chip {
    font-family: var(--pl-sans);
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--pl-fg-muted);
    background: transparent;
    border: 1px solid var(--pl-rule);
    border-radius: 100px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
    white-space: nowrap;
    transition:
        color var(--pl-dur) var(--pl-ease),
        border-color var(--pl-dur) var(--pl-ease),
        background-color var(--pl-dur) var(--pl-ease);
}

@media (hover: hover) and (pointer: fine) {
    .pl-chip:hover {
        color: var(--pl-fg);
        border-color: var(--pl-fg-dim);
    }
}

.pl-chip.is-active {
    color: var(--pl-bg);
    background: var(--pl-accent);
    border-color: var(--pl-accent);
}

.pl-chip-n {
    opacity: 0.65;
    font-variant-numeric: tabular-nums;
}

.pl-status {
    font-family: var(--pl-sans);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--pl-fg-dim);
    font-variant-numeric: tabular-nums;
    /* Empty until a chip is picked. Hold the line's height so the sticky bar
       doesn't change size — and shift the list — the moment you filter. */
    min-height: 1.2rem;
}

/* ---- List ---- */

.pl-list { padding-top: clamp(2rem, 5vw, 3.5rem); }

.pl-group {
    display: grid;
    grid-template-columns: minmax(0, 4.5rem) minmax(0, 1fr);
    gap: 0 clamp(1rem, 3vw, 2.5rem);
    padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.pl-group[hidden] { display: none; }

.pl-letter {
    font-size: clamp(2.75rem, 6vw, 4.5rem);
    font-weight: 300;
    line-height: 1;
    letter-spacing: -0.03em;
    color: var(--pl-ghost);
    /* Optically align the cap with the first word's baseline block. */
    padding-top: 1.6rem;
    /* Rides along while you read the group. */
    position: sticky;
    top: calc(var(--pl-stick) + 1.25rem);
    align-self: start;
    user-select: none;
}

.pl-entries { min-width: 0; }

/* ---- Entry ---- */

.pl-entry {
    display: grid;
    grid-template-columns: minmax(0, 11.5rem) minmax(0, 1fr);
    gap: 0.5rem clamp(1.5rem, 4vw, 3.5rem);
    padding: 1.75rem 0;
    border-top: 1px solid var(--pl-rule-soft);
    /* Clear the sticky control bar on deep links and random jumps. */
    scroll-margin-top: calc(var(--pl-stick) + 1.5rem);
}

.pl-entry[hidden] { display: none; }

.pl-entry-head { min-width: 0; }

.pl-word {
    font-size: clamp(1.4rem, 2.4vw, 1.7rem);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.015em;
    /* Long entries like "metacognition" shouldn't force the column wider. */
    overflow-wrap: break-word;
}

.pl-word a {
    color: var(--pl-fg);
    text-decoration: none;
    transition: color var(--pl-dur) var(--pl-ease);
}

@media (hover: hover) and (pointer: fine) {
    .pl-word a:hover { color: var(--pl-accent); }
}

.pl-meta {
    margin-top: 0.35rem;
    font-family: var(--pl-sans);
    font-size: 0.68rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--pl-fg-dim);
}

.pl-dot { margin: 0 0.35em; }

.pl-entry-body { min-width: 0; }

.pl-def {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--pl-fg);
    max-width: 46em;
}

.pl-root {
    margin-top: 0.6rem;
    font-size: 0.92rem;
    font-style: italic;
    line-height: 1.55;
    color: var(--pl-fg-muted);
    max-width: 46em;
}

.pl-root-label {
    font-family: var(--pl-sans);
    font-style: normal;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--pl-fg-dim);
    margin-right: 0.4em;
}

.pl-usage {
    margin-top: 0.95rem;
    padding-left: 0.95rem;
    border-left: 2px solid var(--pl-rule);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--pl-fg-muted);
    max-width: 46em;
}

/* ---- Flash (random pick, deep link) ---- */

.pl-entry.is-flash {
    animation: pl-flash 1600ms var(--pl-ease);
}

@keyframes pl-flash {
    0%, 12% { background: color-mix(in srgb, var(--pl-accent) 16%, transparent); }
    100%    { background: transparent; }
}

.pl-entry.is-flash .pl-usage { border-left-color: var(--pl-accent); }

/* ---- Footer ---- */

.pl-footer {
    margin-top: clamp(3rem, 7vw, 5rem);
    padding: 2.5rem 0 3.5rem;
    border-top: 1px solid var(--pl-rule);
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
}

.pl-footer p {
    font-family: var(--pl-sans);
    font-size: 0.8rem;
    color: var(--pl-fg-dim);
}

.pl-footer-links {
    display: flex;
    gap: 1.5rem;
}

.pl-footer-links a {
    color: var(--pl-fg-dim);
    text-decoration: none;
    transition: color var(--pl-dur) var(--pl-ease);
}

@media (hover: hover) and (pointer: fine) {
    .pl-footer-links a:hover { color: var(--pl-accent); }
}

/* ---- Narrow ---- */

@media (max-width: 780px) {
    /* The letter rail and the two-column entry both stop earning their keep
       once the columns get this thin — stack everything. */
    .pl-group {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .pl-letter {
        position: static;
        padding-top: 0;
        margin-bottom: 0.25rem;
        font-size: 2rem;
    }

    .pl-entry {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.75rem;
    }
}

/* Without JS the controls never appear, so nothing here needs a fallback —
   the full list renders and reads fine on its own. */
