/* Shared styling for the public content pages (/bio-age, /blogs, /blogs/*, /8-habits, /get).
 *
 * Same rules as legal.css, for the same reasons: plain static HTML that renders without JavaScript
 * and without the Wasm app. The palette, outlines, shadows, corners, button motion and focus ring are
 * the design system's (docs/hundrd/design-system/tokens/*.css — Fresh light, Gold dark), copied as
 * values because these pages must not depend on the Wasm bundle. Kept separate from legal.css so a
 * change to a marketing page can never restyle a page App Review reads.
 *
 * The app's own type (CUI-9), the design system's four roles (tokens/typography.css): Archivo Black
 * for page titles (ALL-CAPS), Baloo 2 for card titles, numbers and the wordmark, DM Sans for body,
 * Space Mono for meta caps — the same files the design system ships, served from /fonts. Same-origin on purpose: the page is
 * cross-origin isolated by _headers, so a third-party webfont request would be blocked. A post opened
 * from inside the app should read as the app, not as a different website.
 *
 * In-app mode: the app opens these pages with ?in_app=1, and each page's head script turns that into
 * an `in-app` class on <html> (remembered for the tab, so a link to another post keeps it). Install
 * prompts and the site's own top bar are hidden there (CUI-6) — the reader is already in the app. */

@font-face {
    font-family: "Archivo Black";
    src: url("/fonts/archivoblack_regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Baloo 2";
    src: url("/fonts/baloo2_variable.ttf") format("truetype");
    font-weight: 400 800;
    font-display: swap;
}

@font-face {
    font-family: "DM Sans";
    src: url("/fonts/dmsans_variable.ttf") format("truetype");
    font-weight: 100 1000;
    font-display: swap;
}

@font-face {
    font-family: "Space Mono";
    src: url("/fonts/spacemono_regular.ttf") format("truetype");
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Space Mono";
    src: url("/fonts/spacemono_bold.ttf") format("truetype");
    font-weight: 700;
    font-display: swap;
}

:root {
    color-scheme: light dark;
    --bg: #ffffff;          /* --bg-app (Fresh) */
    --surface: #ffffff;     /* --surface-card */
    --well: #f0f0f0;        /* --surface-well */
    --ink: #141013;         /* --text-strong */
    --muted: #595052;       /* --text-muted */
    --line: #010101;        /* --border-strong: outlines stay black in every theme */
    --shadow: #010101;      /* --shadow-color */
    --yellow: #ffd429;      /* --accent-primary (butter) */
    --yellow-press: #e0bb24;
    --green: #22d97f;       /* --accent-secondary (mint) */
    --pink: #f6a9c2;        /* --tag-pink */
    --blue: #79c6e8;        /* --tag-sky */
    --ease-out: cubic-bezier(.2, .7, .3, 1);
    --ease-emphasized: cubic-bezier(.2, 0, 0, 1);
    --spring-fast: linear(0, .18 6%, .62 16%, .96 26%, 1.08 33%, 1.1 37%, 1.07 44%, 1.01 54%, .99 62%, 1);
    --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-head: "Archivo Black", "DM Sans", Impact, sans-serif;
    --font-display: "Baloo 2", "DM Sans", system-ui, sans-serif;
    --font-mono: "Space Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Gold — the shipped dark default. Outlines and shadows stay black. */
        --bg: #17151a;
        --surface: #2c2a2f;
        --well: #100f12;
        --ink: #ecebec;
        --muted: #9b9a9c;
        --line: #000000;
        --shadow: #000000;
        --green: #3ee594;
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 1.5rem 1.25rem 5rem;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;   /* --type-body: 16/23 at 500 */
    font-weight: 500;
    line-height: 23px;
    -webkit-font-smoothing: antialiased;
}

main {
    max-width: 44rem;
    margin: 0 auto;
}

a {
    color: inherit;
    text-underline-offset: 2px;
}

/* ---- Top bar ---- */

.top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    max-width: 44rem;
    margin: 0 auto 2.5rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem 0.3rem 0.35rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--yellow);
    color: #141013;
    font-family: var(--font-display); /* the lockup: mark + "Hundrd" in Baloo 2 800 */
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1;
    text-decoration: none;
}

.brand img {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 7px;
}

.top nav {
    display: flex;
    gap: 1.1rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.top nav a {
    display: inline-block;
    padding: 0.6rem 0;
    text-decoration: none;
}

.top nav a:hover,
.top nav a[aria-current="page"] {
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 5px;
}

/* ---- Type ---- */

.kicker {
    margin: 0 0 0.5rem;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Archivo Black has one weight; 400 stops the browser faking a bolder one on top of it. */
h1,
h2,
legend {
    font-family: var(--font-head);
    font-synthesis: none;
}

h1 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.9rem, 6vw, 2.6rem);
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

h2 {
    margin: 2.75rem 0 0.5rem;
    font-size: 1.25rem;
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

h3 {
    /* --type-section-title: Baloo 2 20/23 at 700. */
    margin: 1.75rem 0 0.25rem;
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    line-height: 23px;
}

.lede {
    /* --type-body-lg: 18/26. */
    margin: 0 0 1.5rem;
    font-size: 18px;
    line-height: 26px;
}

.small {
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

/* ---- Blocks ---- */

.card {
    margin: 1.5rem 0;
    padding: 1.1rem 1.2rem;
    border: 3px solid var(--line);
    border-radius: 24px; /* the card corner (Look & feel "scaled") */
    background: var(--surface);
    box-shadow: 5px 6px 0 var(--shadow); /* --shadow-md */
}

/* Card titles are --type-card-title: Baloo 2 24/28 at 700, sentence case. ALL-CAPS Archivo Black is
   for page titles and the article's own section headings, never for a card. */
.card h2,
.post-link h2,
.habit h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    line-height: 28px;
    letter-spacing: 0;
    text-transform: none;
}

.card > :first-child {
    margin-top: 0;
}

.card > :last-child {
    margin-bottom: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.5rem;
    border: 3px solid var(--line);
    /* The design system's Button: a butter pill (radius = half its 52px height, a concrete number so
       the morph is a real tween) that sinks into its shadow and squares up to 14px on press, then
       springs back. */
    min-height: 52px;
    border-radius: 26px;
    background: var(--yellow);
    box-shadow: 5px 6px 0 var(--shadow);
    color: #141013;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform 420ms var(--spring-fast), box-shadow 90ms var(--ease-out),
        border-radius 420ms var(--ease-emphasized), background-color 160ms var(--ease-out);
}

.btn:hover {
    background: var(--yellow-press);
}

.btn:active {
    transform: translate(4px, 4px);
    box-shadow: 1px 1px 0 var(--shadow);
    border-radius: 14px;
}

.btn.alt {
    background: var(--well);
    color: var(--ink);
}

.btn.alt:hover {
    background: var(--well);
}

.btn.yellow {
    background: var(--yellow);
}

.btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn:focus-visible,
.top a:focus-visible,
.post-link:focus-visible {
    outline: 3px solid var(--ink); /* keyboard focus: ink, never a coloured glow */
    outline-offset: 3px;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin: 1.25rem 0;
}

footer {
    max-width: 44rem;
    margin: 4rem auto 0;
    padding-top: 1.5rem;
    border-top: 3px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

footer a {
    margin-right: 1rem;
}

/* ---- Social links (footer) ----
 * The design system's IconButton: an outlined tile with the small hard shadow that sinks on press,
 * the glyph inside it. Glyphs are /icons/social/*.svg, drawn to the iconography rule (24px grid,
 * 2px round-cap outline; Lucide's shapes where Lucide has one, the same stroke where it has not —
 * TikTok, Reddit, X). Used as a mask so they take the text colour in light and dark. */

.social {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.25rem 0 0.25rem;
}

footer .social a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 3px 4px 0 var(--shadow);
    color: var(--ink);
    transition: transform 420ms var(--spring-fast), box-shadow 90ms var(--ease-out);
}

footer .social a:active {
    transform: translate(3px, 3px);
    box-shadow: 1px 1px 0 var(--shadow);
}

footer .social a:focus-visible {
    outline: 3px solid var(--ink); /* keyboard focus: ink, never a coloured glow */
    outline-offset: 3px;
}

.social .glyph {
    width: 22px;
    height: 22px;
    background: currentColor;
    -webkit-mask: var(--glyph) center / contain no-repeat;
    mask: var(--glyph) center / contain no-repeat;
}

.social .instagram { --glyph: url("/icons/social/instagram.svg"); }
.social .tiktok { --glyph: url("/icons/social/tiktok.svg"); }
.social .youtube { --glyph: url("/icons/social/youtube.svg"); }
.social .reddit { --glyph: url("/icons/social/reddit.svg"); }
.social .x { --glyph: url("/icons/social/x.svg"); }

@media (prefers-reduced-motion: reduce) {
    footer .social a {
        transition: none;
    }
}

/* ---- Blog index ---- */

.posts {
    margin: 2rem 0 0;
    padding: 0;
    list-style: none;
}

.post-link {
    display: block;
    margin: 0 0 1.5rem;
    padding: 1.2rem 1.3rem;
    border: 3px solid var(--line);
    border-radius: 24px; /* the card corner (Look & feel "scaled") */
    background: var(--surface);
    box-shadow: 5px 6px 0 var(--shadow); /* --shadow-md */
    text-decoration: none;
    transition: transform 420ms var(--spring-fast), box-shadow 90ms var(--ease-out);
}

.post-link:hover {
    /* Wide-screen hover: the card lifts 2px onto the next shadow step (design system Adaptive). */
    transform: translateY(-2px);
    box-shadow: 7px 8px 0 var(--shadow);
}

.post-link h2 {
    margin: 0 0 0.4rem;
}

.post-link p {
    margin: 0;
}

.post-link .more {
    display: inline-block;
    margin-top: 0.75rem;
    font-weight: 800;
    text-decoration: underline;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
    margin: 0 0 2rem;
}

/* ---- Article ---- */

article p,
article li {
    max-width: 40rem;
}

article ul,
article ol {
    padding-left: 1.3rem;
}

article li {
    margin: 0.35rem 0;
}

.zones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
    padding: 0;
    list-style: none;
}

.zones li {
    max-width: none;
    margin: 0;
    padding: 0.9rem 1rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    font-size: 0.95rem;
    line-height: 1.5;
}

.zones strong {
    display: block;
    font-family: var(--font-display); /* a figure: the display voice */
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
}

.refs {
    padding-left: 1.3rem;
    color: var(--muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

.refs li {
    max-width: none;
    margin: 0.5rem 0;
    overflow-wrap: anywhere;
}

/* ---- The 8 free habits (/8-habits) ----
 * One card per habit, numbered by the list itself so the count can never drift from the markup. */

.habits {
    margin: 2rem 0;
    padding: 0;
    list-style: none;
    counter-reset: habit;
}

.habit {
    position: relative;
    margin: 0 0 1.5rem;
    padding: 1.1rem 1.2rem 1.2rem 4.4rem;
    border: 3px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 5px 6px 0 var(--shadow);
    counter-increment: habit;
}

.habit::before {
    content: counter(habit);
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.4rem;
    height: 2.4rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--yellow);
    color: #141013;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
}

.habit:nth-child(even)::before {
    background: var(--green);
}

.habit h2 {
    margin: 0.35rem 0 0.75rem;
}

.habit p {
    margin: 0 0 0.75rem;
}

.habit .label {
    display: block;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.habit .step {
    padding: 0.6rem 0.8rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--well);
}

.habit sup {
    line-height: 0; /* keep the source mark from pushing its line apart */
}

.habit sup a {
    color: var(--muted);
    font-size: 0.75rem;
}

.habit .read {
    display: inline-block;
    padding: 0.4rem 0;
    font-weight: 800;
    text-decoration-thickness: 3px;
    text-underline-offset: 4px;
}

.print-only {
    display: none;
}

@media (max-width: 30rem) {
    .habit {
        padding-left: 1.2rem;
    }

    .habit::before {
        position: static;
        margin-bottom: 0.25rem;
    }
}

/* Save as PDF: one sheet. Two columns of compact cards, light colours, no shadows, no buttons; the
   footer line carries the address instead of the links. */
@media print {
    @page {
        margin: 10mm 12mm;
    }

    :root {
        --bg: #fff;
        --surface: #fff;
        --well: #f0f0f0;
        --ink: #141013;
        --muted: #595052;
    }

    body {
        padding: 0;
        font-size: 8.5pt;
        line-height: 1.35;
    }

    main {
        max-width: none;
    }

    h1 {
        margin-bottom: 0.2rem;
        font-size: 20pt;
    }

    main > .kicker {
        display: none;
    }

    .lede {
        margin-bottom: 0.3rem;
        font-size: 10pt;
        line-height: 1.35;
    }

    .small {
        margin: 0.3rem 0;
        font-size: 7.5pt;
    }

    .top,
    footer,
    .no-print,
    .habit .read,
    #get-app .actions {
        display: none;
    }

    .print-only {
        display: block;
    }

    .habits {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.45rem;
        margin: 0.5rem 0;
    }

    .habit,
    .card {
        box-shadow: none;
        break-inside: avoid;
    }

    .habit {
        margin: 0;
        padding: 0.5rem 0.6rem 0.5rem 2.6rem;
        border-width: 2px;
        border-radius: 14px;
    }

    .habit::before {
        top: 0.5rem;
        left: 0.5rem;
        width: 1.6rem;
        height: 1.6rem;
        border-width: 2px;
        border-radius: 8px;
        font-size: 0.85rem;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .habit h2 {
        margin: 0.1rem 0 0.2rem;
        font-size: 10pt;
    }

    .habit p {
        margin: 0 0 0.25rem;
    }

    .habit .label {
        display: inline;
        margin-right: 0.4em;
    }

    .habit .step {
        margin: 0;
        padding: 0.3rem 0.45rem;
        border-width: 2px;
        border-radius: 8px;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .habit .label {
        font-size: 6.5pt;
    }

    .card {
        margin: 0.6rem 0;
        padding: 0.5rem 0.7rem;
        border-width: 2px;
        border-radius: 14px;
    }

    .card h2 {
        margin-bottom: 0.2rem;
        font-size: 10pt;
    }

    #get-app .small {
        display: none;
    }
}

/* The film's scene tags: a mono-caps pill in one of the four tag colours. */
.tag {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border: 3px solid var(--line);
    border-radius: 999px;
    background: var(--yellow);
    color: #141013;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tag.green {
    background: var(--green);
}

.tag.blue {
    background: var(--blue);
}

.tag.pink {
    background: var(--pink);
}

/* ---- Quiz ---- */

.progress {
    height: 14px;
    margin: 0 0 1.5rem;
    border: 3px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    overflow: hidden;
}

.progress span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--green);
    transition: width 160ms ease;
}

fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

legend {
    margin: 0 0 1rem;
    padding: 0;
    font-size: 1.4rem;
    font-weight: 400;
    line-height: 1.25;
}

.options {
    display: grid;
    gap: 0.75rem;
}

.option {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: 0.7rem 1rem;
    border: 3px solid var(--line);
    border-radius: 14px; /* --radius-md */
    background: var(--surface);
    box-shadow: 3px 4px 0 var(--shadow); /* --shadow-sm */
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: transform 420ms var(--spring-fast), box-shadow 90ms var(--ease-out);
}

.option:active {
    transform: translate(4px, 4px);
    box-shadow: 1px 1px 0 var(--shadow);
}

.option[aria-pressed="true"] {
    background: var(--yellow);
    color: #141013;
}

.option:focus-visible,
.age:focus-visible {
    outline: 3px solid var(--ink); /* keyboard focus: ink, never a coloured glow */
    outline-offset: 3px;
}

.age {
    width: 9rem;
    min-height: 56px;
    padding: 0.4rem 0.9rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
}

/* ---- Email sign-up (/8-habits, /bio-age) ----
 * The design system's text field: a 3px outline on the card surface, 14px corners, 52px tall, the
 * ink focus ring. The checkbox is the browser's own, drawn in ink and sized to the 44px tap rule. */

.field-label {
    display: block;
    margin: 1rem 0 0.4rem;
    font-weight: 700;
}

.field {
    display: block;
    width: 100%;
    max-width: 26rem;
    min-height: 52px;
    padding: 0.5rem 0.9rem;
    border: 3px solid var(--line);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.field:focus-visible,
.check input:focus-visible {
    outline: 3px solid var(--ink); /* keyboard focus: ink, never a coloured glow */
    outline-offset: 3px;
}

.check {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin: 1rem 0 0;
    cursor: pointer;
}

.check input {
    flex: none;
    width: 24px;
    height: 24px;
    margin: 0;
    accent-color: var(--ink);
    cursor: pointer;
}

.check span {
    padding-top: 1px;
}

.captcha:empty {
    display: none;
}

.captcha {
    margin-top: 1rem;
}

.signup-status {
    min-height: 1.5rem;
    margin: 0;
    font-weight: 700;
}

.signup-status.good {
    color: #116c40; /* --mint-deep */
}

.signup-status.bad {
    color: #a81f2c; /* --danger-ink */
}

@media (prefers-color-scheme: dark) {
    .signup-status.good {
        color: var(--green);
    }

    .signup-status.bad {
        color: #ff8f8f;
    }
}

.email-signup.sent .field,
.email-signup.sent .check,
.email-signup.sent .actions {
    display: none;
}

.error {
    min-height: 1.5rem;
    margin: 0.5rem 0 0;
    color: #a81f2c; /* --danger-ink */
    font-weight: 700;
}

@media (prefers-color-scheme: dark) {
    .error {
        color: #ff8f8f;
    }
}

.result-number {
    margin: 0;
    font-family: var(--font-display);
    font-size: clamp(4rem, 22vw, 6.5rem);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.result-verdict {
    display: inline-block;
    margin: 0.75rem 0 0;
    padding: 0.25rem 0.7rem;
    border: 3px solid var(--line);
    border-radius: 999px;
    background: var(--green);
    color: #141013;
    font-weight: 800;
}

.result-verdict.older {
    background: var(--pink);
}

.result-verdict.same {
    background: var(--blue);
}

.rows {
    margin: 0.75rem 0 0;
    padding: 0;
    list-style: none;
}

.rows li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.55rem 0;
    border-bottom: 2px solid var(--line);
}

.rows li:last-child {
    border-bottom: 0;
}

.rows .delta {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.share-preview {
    display: block;
    width: 100%;
    max-width: 22rem;
    height: auto;
    margin: 1rem 0 0;
    border: 3px solid var(--line);
    border-radius: 24px;
    box-shadow: 5px 6px 0 var(--shadow);
}

/* Headings that only take focus from script (so a screen reader announces the new step). They are
   not controls, so they get no ring. */
[tabindex="-1"]:focus {
    outline: none;
}

[hidden] {
    display: none !important;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* ---- In-app mode (CUI-6) ----
 * Already in the app: no install prompt, no store links, and no site bar — the app's own screen
 * carries the way back. */

.in-app #get-app,
.in-app .email-signup,
.in-app .top,
.in-app a[href*="play.google.com"],
.in-app a[href*="apps.apple.com"],
.in-app footer a[href="/"] {
    display: none;
}

.in-app body {
    padding-top: 1rem;
}
