/* Xiao Liu — personal site. Monochrome editorial design with section color accents (see CLAUDE.md). */
:root {
    --black: #111;
    --white: #fff;
    --gray: #555;
    --muted: #888;
    --rule: #e0e0e0;
    --light-gray: #f7f7f7;
    --deep-blue: #005594;
    --sky-blue: #4398D3;
    --orange: #EE8D3D;
    --red: #C5362F;
    --header-h: 64px;
    --page-padding: 4vw;
    --max-width: 1200px;
    --content-width: 860px;
}

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

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--white);
    color: var(--black);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1, h2 { font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }

/* Section color accents: a short colored tick before small uppercase labels */
.accent-blogs { --accent: var(--sky-blue); }
.accent-presentations { --accent: var(--orange); }
.accent-apps { --accent: var(--deep-blue); }

.label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.label::before {
    content: '';
    width: 4px;
    height: 14px;
    background: var(--accent, var(--black));
}

/* ============================================================
   HEADER — white and sticky; transparent over the home hero
   ============================================================ */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-h);
    padding: 0 var(--page-padding);
    background: var(--white);
    border-bottom: 1px solid #eee;
    position: sticky;
    top: 0;
    z-index: 200;
    transition: background 0.25s, border-color 0.25s, color 0.25s;
}
header.overlay {
    background: transparent;
    border-bottom-color: transparent;
    color: var(--white);
}

.brand { font-weight: 600; white-space: nowrap; }

header nav { display: flex; gap: 4px; }
header nav a { padding: 4px 10px; font-size: 15px; transition: opacity 0.15s; }
header nav a:hover { text-decoration: none; opacity: 0.6; }
header nav a.active { text-decoration: underline; text-underline-offset: 4px; }

/* Phone menu button: three bars that turn into an X when open */
.menu {
    display: none;
    position: relative;
    z-index: 2;
    flex-direction: column;
    gap: 5px;
    padding: 6px 4px;
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
}
.menu span { display: block; width: 22px; height: 2px; background: currentColor; transition: transform 0.2s, opacity 0.2s; }
header.open .menu { color: var(--black); }
header.open .menu span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
header.open .menu span:nth-child(2) { opacity: 0; }
header.open .menu span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

main {
    flex: 1;
    width: 100%;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 5vw var(--page-padding) 6vw;
}

footer {
    border-top: 1px solid var(--rule);
    padding: 2.5rem var(--page-padding);
    text-align: center;
}
.footer-nav { display: flex; justify-content: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.footer-nav a { padding: 0 0.5rem; font-size: 0.9rem; }
.footer-nav .sep { color: var(--gray); font-size: 0.9rem; }
.footer-copy { font-size: 0.82rem; color: var(--gray); }

/* ============================================================
   HOME — dark hero + grid of section cells
   ============================================================ */
.hero {
    position: relative;
    display: flex;
    align-items: flex-end;
    min-height: 80vh;
    margin-top: calc(-1 * var(--header-h));
    padding: calc(var(--header-h) + 4vw) var(--page-padding) 6vw;
    /* Dark scrim, heaviest at the bottom where the text sits, over NASA's Earth limb photo */
    --hero-scrim: linear-gradient(to top, rgba(0, 0, 0, 0.72) 0%, rgba(0, 0, 0, 0.3) 55%, rgba(0, 0, 0, 0.15) 100%);
    background:
        var(--hero-scrim),
        url('img/hero-earth.jpg') center 30% / cover no-repeat,
        var(--black);
    color: var(--white);
}
/* Daily NASA APOD photo (set by the page script): start black, fade the photo in once it has loaded,
   and fall back to the Earth photo if it can't load */
.hero[data-apod]:not(.apod-off) { background: var(--hero-scrim), var(--black); }
.hero[data-apod]::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--hero-scrim), var(--hero-photo, none) center / cover no-repeat;
    opacity: 0;
    transition: opacity 0.8s ease;
}
.hero.apod-ready::before { opacity: 1; }
.hero-credit {
    position: absolute;
    z-index: 1;
    right: var(--page-padding);
    bottom: 1rem;
    max-width: min(60ch, calc(100% - 2 * var(--page-padding)));
    overflow: hidden;
    font-size: 0.72rem;
    white-space: nowrap;
    text-overflow: ellipsis;
    opacity: 0.6;
}
.hero-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.hero-inner { position: relative; z-index: 1; width: 100%; max-width: calc(var(--max-width) - 2 * var(--page-padding)); margin: 0 auto; }
.hero h1 { font-size: clamp(2.4rem, 5vw, 4.4rem); margin-bottom: 1.25rem; animation: fade-up 1s cubic-bezier(0.22, 1, 0.36, 1) both; }
.hero p { max-width: 600px; font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.55; opacity: 0.85; animation: fade-up 1s 0.15s cubic-bezier(0.22, 1, 0.36, 1) both; }

@keyframes fade-up {
    from { opacity: 0; transform: translateY(24px); }
}
@media (prefers-reduced-motion: reduce) {
    .hero h1, .hero p { animation: none; }
    .hero[data-apod]::before { transition: none; }
}

.section-heading { margin-bottom: 2rem; font-size: clamp(1.6rem, 3vw, 2.4rem); }

/* Ask Xiao: a question box with suggested questions; the answer appears below */
.ask { --accent: var(--deep-blue); max-width: var(--content-width); margin: 0 auto 4.5vw; }
.ask .label { color: var(--gray); }
.ask .section-heading { margin: 0.6rem 0 0.45rem; }
.ask-intro { color: var(--gray); }
.ask-form { display: flex; margin-top: 1.2rem; border: 1px solid #aaa; }
.ask-form:focus-within { border-color: var(--black); }
.ask-form textarea {
    flex: 1;
    min-width: 0;
    padding: 14px 16px;
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--black);
    background: transparent;
    border: none;
    resize: vertical;
}
.ask-form textarea:focus { outline: none; }
.ask-form button {
    align-self: flex-end;
    margin: 7px;
    padding: 0.52rem 1rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--white);
    background: var(--black);
    border: 1px solid var(--black);
    cursor: pointer;
}
.ask-form button:hover { color: var(--black); background: var(--white); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.suggestions button {
    padding: 6px 10px;
    font: inherit;
    font-size: 0.78rem;
    color: var(--gray);
    background: transparent;
    border: 1px solid #ccc;
    cursor: pointer;
}
.suggestions button:hover { color: var(--black); border-color: var(--black); }
.answer { margin-top: 1.25rem; padding: 1rem 1.2rem; border: 1px solid var(--rule); border-left: 3px solid var(--deep-blue); }
.answer p { margin-top: 0.45rem; line-height: 1.65; }
.answer a { text-decoration: underline; text-underline-offset: 3px; }
.ask-note { margin-top: 12px; font-size: 0.72rem; color: var(--muted); }
.ask-check:empty { display: none; }
.ask-check { margin-top: 1rem; }
.answer.thinking p { color: var(--muted); }
.ask-more { margin-top: 0.6rem; padding: 0; border: 0; background: none; font: inherit; font-size: 0.82rem; color: var(--gray);
            text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.ask-more:hover { color: var(--black); }

/* Currently: text on the left, photo on the right */
.now {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 5vw;
    align-items: start;
    padding-top: 2rem;
    border-top: 1px solid var(--rule);
    scroll-margin-top: var(--header-h);
}
.now .section-heading { margin-bottom: 1.25rem; }
.now p { margin-bottom: 1rem; font-size: 0.98rem; line-height: 1.7; }
.now p a { text-decoration: underline; text-underline-offset: 3px; }
.now .actions { margin-top: 1.5rem; }
.now-photo img { display: block; width: 100%; }
.now-photo .img-placeholder { display: flex; align-items: center; justify-content: center; aspect-ratio: 4 / 3; }
.now .caption { margin: 0.5rem 0 0; font-size: 0.82rem; color: var(--gray); }

/* Explore: a compact strip linking to each section */
.latest-heading { margin-bottom: 1rem; font-size: 1.25rem; }
.doors {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    margin-bottom: 4.5vw;
    border-top: 1px solid var(--rule);
}
.door {
    display: flex;
    flex-direction: column;
    padding: 1.1rem 1.5rem;
    border-right: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}
.door:first-child { padding-left: 0; }
.door:last-child { border-right: none; padding-right: 0; }
.door-count { margin-left: auto; font-weight: 600; color: var(--muted); }
.door-latest { display: block; margin-top: 0.6rem; font-size: 1.02rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.door-date { margin-top: 0.2rem; font-size: 0.82rem; color: var(--gray); }
.door-empty { margin-top: 0.6rem; color: var(--muted); }
.door-all { margin-top: auto; padding-top: 0.6rem; font-size: 0.85rem; font-weight: 500; }

/* Popular: the most liked and discussed items, filled in by social.js from /api/ranking */
.popular { margin-bottom: 4.5vw; }
.popular-list { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.popular-item { display: flex; flex-direction: column; padding: 1.1rem 1.5rem; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.popular-item:first-child { padding-left: 0; }
.popular-item:last-child { border-right: none; padding-right: 0; }
.popular-title { margin-top: 0.6rem; font-size: 1.02rem; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; }
.popular-meta { margin-top: 0.2rem; font-size: 0.82rem; color: var(--gray); }

/* ============================================================
   SECTION PAGES — title + rows divided by rules
   ============================================================ */
.page-title { max-width: var(--content-width); margin-bottom: 2.5rem; }
.page-title h1 { margin-top: 0.75rem; font-size: clamp(2.2rem, 4.5vw, 3.6rem); }
.page-title p { margin-top: 1rem; font-size: 1.05rem; color: var(--gray); }
.page-title p a { text-decoration: underline; text-underline-offset: 3px; }
.page-title .label { color: var(--gray); }

.rows { max-width: var(--content-width); border-top: 1px solid var(--rule); }
.row { padding: 2.25rem 0; border-bottom: 1px solid var(--rule); }
.meta { font-size: 0.88rem; color: var(--gray); }
.row h2 { margin-top: 0.35rem; font-size: clamp(1.3rem, 2.2vw, 1.6rem); letter-spacing: -0.01em; line-height: 1.2; }
.row p { margin-top: 0.6rem; line-height: 1.7; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 1.25rem; }
.empty { padding: 2rem 0; color: var(--muted); }

/* Outlined buttons that fill black on hover */
.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--black);
    background: transparent;
    border: 1px solid var(--black);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn:hover { background: var(--black); color: var(--white); text-decoration: none; }
.btn-quiet { border-color: #ccc; color: var(--gray); }
.btn-quiet:hover { border-color: var(--black); }
.btn-static, .btn-static:hover { cursor: default; color: var(--muted); background: transparent; border-color: #ccc; }

/* ============================================================
   BLOG POST — one readable column
   ============================================================ */
.post { max-width: var(--content-width); font-size: 17px; line-height: 1.75; }
.back { display: inline-block; margin-bottom: 2rem; font-size: 0.9rem; color: var(--gray); }
.post > h1 { margin: 0.5rem 0 2.5rem; font-size: clamp(2rem, 4vw, 3rem); }
.post h2 { margin: 3rem 0 1rem; font-size: 1.6rem; }
.post h3 { margin: 2rem 0 0.5rem; font-size: 1.2rem; font-weight: 600; letter-spacing: -0.01em; }
.post p, .post ul, .post ol, .post blockquote, .post pre, .post .table-wrap { margin: 0 0 1.25rem; }
.post ul, .post ol { padding-left: 1.6rem; }
.post li { margin: 0.3rem 0; }
.post li > ul, .post li > ol, .post li > pre { margin: 0.5rem 0; }
.post a { text-decoration: underline; text-underline-offset: 3px; }
.post a:hover { opacity: 0.6; }
.post code {
    font-family: 'Cascadia Code', Consolas, 'SF Mono', monospace;
    font-size: 0.86em;
    padding: 1px 5px;
    background: var(--light-gray);
    border: 1px solid #eee;
}
.post pre { padding: 1rem 1.25rem; background: var(--black); overflow-x: auto; line-height: 1.55; }
.post pre code { padding: 0; background: none; border: none; color: #f2f2f2; font-size: 14px; }
.post blockquote { padding: 0.25rem 0 0.25rem 1.1rem; border-left: 3px solid var(--black); }
.post blockquote p { margin: 0; }
.post .table-wrap { overflow-x: auto; }
.post table { width: 100%; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.post th, .post td { padding: 0.7rem 0.75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
.post th { font-weight: 600; border-bottom-color: var(--black); }
.post img { max-width: 100%; }
.post a.btn { text-decoration: none; }
.post a.btn:hover { opacity: 1; }

/* A talk's Discuss page: title, summary, Open deck, then comments */
.discuss > h1 { margin-bottom: 1rem; }
.post .discuss-summary { margin-bottom: 1.75rem; font-size: 1.1rem; color: var(--gray); }
.discuss .post-actions { margin-top: 0; }
.img-placeholder {
    display: block;
    padding: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--muted);
    border: 1.5px dashed #ccc;
}

/* ============================================================
   READING AIDS (builder/reading.py) AND MOTION (js/motion.js)
   Still and complete without the script; motion only adds an entrance.
   ============================================================ */
/* Posts use two open-licence fonts served from fonts/ (no third-party requests): Source Serif 4 for
   display type, Inter for reading. Latin subsets, variable weight; system fonts stand in while they load. */
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 400 700; font-display: swap;
             src: url(fonts/source-serif-4-latin-v15.woff2) format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap;
             src: url(fonts/inter-latin-v20.woff2) format('woff2'); }

:root {
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ink: #2b2b2b;
    --paper: #faf9f5;            /* warm ivory, easier on the eyes than pure white for long reading */
    --sage: #4a7561;             /* the reading accent in posts: calm, and 4.5:1 on the paper */
    --sage-tint: #edf2ec;
    --sage-line: #d3dfd5;
    --serif: 'Source Serif 4', 'Iowan Old Style', Charter, 'Sitka Heading', Cambria, Georgia, serif;
    --sans-read: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    /* Icons (Lucide-style line icons), drawn in the current text color with mask-image */
    --icon-note: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4M12 8h.01'/%3E%3C/svg%3E");
    --icon-tip: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 18h6M10 22h4M12 2a7 7 0 0 0-4 12.7c.6.5 1 1.3 1 2.1V17h6v-.2c0-.8.4-1.6 1-2.1A7 7 0 0 0 12 2z'/%3E%3C/svg%3E");
    --icon-important: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m12 2 3.1 6.3 6.9 1-5 4.9 1.2 6.8-6.2-3.2-6.2 3.2L7 14.2 2 9.3l6.9-1z'/%3E%3C/svg%3E");
    --icon-warning: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0zM12 9v4M12 17h.01'/%3E%3C/svg%3E");
    --icon-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14M13 6l6 6-6 6'/%3E%3C/svg%3E");
    --icon-play: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M8 5v14l11-7z' fill='black'/%3E%3C/svg%3E");
}

/* A post page: ivory paper (header included), Inter for reading, sage instead of the section color */
body:has(.post-layout), body:has(.post-layout) header { background: var(--paper); }
.post-layout { font-family: var(--sans-read); }
.post-layout, .post-layout [class*="accent-"], .progress[class*="accent-"] { --accent: var(--sage); }

/* Display type in the serif */
.post > h1, .post-body h2, .post-body > .lede, .pull-quote blockquote { font-family: var(--serif); }
.post > h1 { font-weight: 600; letter-spacing: -0.015em; line-height: 1.12; }
.post-body h2 { font-weight: 600; letter-spacing: -0.01em; }

/* The post and, on wide screens, "In this post" beside it */
.post-layout { display: grid; grid-template-columns: minmax(0, var(--content-width)) minmax(0, 1fr); gap: 4.5rem; }
.toc { position: sticky; top: calc(var(--header-h) + 3rem); align-self: start; max-height: calc(100vh - var(--header-h) - 5rem); overflow-y: auto; }
.toc .label { color: var(--gray); }
.toc ol { list-style: none; margin-top: 1rem; border-left: 1px solid var(--rule); }
.toc a { display: grid; grid-template-columns: 2rem 1fr; padding: 0.45rem 0 0.45rem 1rem; margin-left: -1px; font-size: 0.88rem; line-height: 1.4;
         color: var(--muted); border-left: 2px solid transparent; transition: color 0.35s var(--ease), border-color 0.35s var(--ease); }
.toc a span { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; padding-top: 0.1rem; }
.toc a:hover { color: var(--black); text-decoration: none; }
.toc a.on { color: var(--black); font-weight: 600; border-left-color: var(--accent); }

/* Reading progress: a thin line in the section color under the sticky header */
.progress { position: fixed; z-index: 150; top: var(--header-h); left: 0; right: 0; height: 3px; pointer-events: none; }
.progress span { display: block; height: 100%; background: var(--accent, var(--black)); transform: scaleX(0); transform-origin: 0 50%; }

/* Body text a step softer than the headings; links underlined in the section color */
.post-body { color: var(--ink); }
.post-body h2, .post-body h3, .post-body strong { color: var(--black); }
.post-body a { text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.post-body a:hover { opacity: 1; color: var(--black); text-decoration-color: var(--black); }

/* The opening line, set larger */
.post-body > .lede { margin-bottom: 2.25rem; font-size: clamp(1.2rem, 2vw, 1.45rem); line-height: 1.5; color: var(--gray); letter-spacing: -0.01em; }
.post-body > .lede::after { content: ""; display: block; width: 48px; height: 3px; margin-top: 1.75rem; background: var(--accent); }

/* Sections: a "01 / 05" label, a bigger heading over a rule, and a # link on hover */
.post-body h2 { position: relative; margin: 3.25rem 0 1rem; padding-top: 1.75rem; border-top: 1px solid var(--rule);
                font-size: clamp(1.7rem, 3vw, 2.3rem); scroll-margin-top: calc(var(--header-h) + 1rem); }
.post-body h2 .label { margin-bottom: 0.75rem; color: var(--gray); font-family: var(--sans-read); }
.post-body h2 .anchor { margin-left: 0.4em; color: var(--rule); text-decoration: none; opacity: 0; transition: opacity 0.2s; }
.post-body h2:hover .anchor, .post-body h2 .anchor:focus-visible { opacity: 1; }
.post-body h2 .anchor:hover { color: var(--black); opacity: 1; }
.post-body h3 { scroll-margin-top: calc(var(--header-h) + 1rem); }

/* Three or more subsections sit side by side: a rule over each, no boxes */
.steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem 2.75rem; margin: 1.5rem 0 0.5rem; }
.step { padding-top: 1.1rem; border-top: 2px solid var(--black); font-size: 16px; line-height: 1.7; }
.post-body .step h3 { margin: 0 0 0.6rem; font-size: 1.15rem; line-height: 1.3; }
.post-body .step p, .post-body .step ol, .post-body .step ul { margin-bottom: 1rem; }

/* Numbered steps: a large numeral in the section color over the heading */
.post-body h3.numbered { font-weight: 700; }
.post-body h3.numbered .num { display: block; margin-bottom: 0.4rem; font-size: clamp(2rem, 3.4vw, 2.6rem); font-weight: 800; line-height: 1;
                              letter-spacing: -0.04em; color: var(--accent); transition: color 0.8s var(--ease) 0.25s; }

/* "**How:** ..." paragraphs: a callout with a rule in the section color and an arrow before its label */
.post-body .callout { padding: 0.15rem 0 0.15rem 1rem; border-left: 3px solid var(--accent); }
.callout-label { display: flex; align-items: center; gap: 0.35rem; margin-bottom: 0.1rem; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.callout-label::before { content: ""; width: 13px; height: 13px; background: var(--accent);
                         -webkit-mask: var(--icon-arrow) no-repeat center / contain; mask: var(--icon-arrow) no-repeat center / contain; }

/* Alerts ("> [!TIP] Title"): a tinted box with an icon; square, like the rest of the site */
.post-body .alert { margin: 1.75rem 0 2rem; padding: 1.1rem 1.35rem 0.2rem; background: rgba(232, 230, 222, 0.55); border: 1px solid #e4e1d8; }
.post-body .alert-title { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.45rem; font-weight: 700; color: var(--black); }
.alert-title::before { content: ""; flex: none; width: 1.15em; height: 1.15em; background: var(--alert-color, var(--gray));
                       -webkit-mask: var(--alert-icon) no-repeat center / contain; mask: var(--alert-icon) no-repeat center / contain; }
.post-body .alert p { margin-bottom: 0.9rem; }
.alert-note { --alert-icon: var(--icon-note); }
.alert-tip { --alert-icon: var(--icon-tip); --alert-color: var(--sage); }
.post-body .alert-tip, .post-body .alert-important { background: var(--sage-tint); border-color: var(--sage-line); }
.alert-important { --alert-icon: var(--icon-important); --alert-color: var(--sage); }
.post-body .alert-important { border-left: 4px solid var(--sage); }
.alert-warning { --alert-icon: var(--icon-warning); --alert-color: var(--orange); }
.post-body .alert-warning { background: #fdf4ec; border-color: #f6dcc4; }

/* Pull quote: a large serif line between rules, with its source */
.post-body .pull-quote { margin: 2.5rem 0; padding-top: 1.5rem; border-top: 3px solid var(--accent); }
.pull-quote blockquote { padding: 0; border: none; font-size: clamp(1.45rem, 2.6vw, 1.9rem); line-height: 1.3; color: var(--black); letter-spacing: -0.01em; }
.post-body .pull-quote blockquote p { margin: 0; }
.post-body .pull-quote figcaption { margin-top: 0.9rem; font-size: 0.9rem; font-weight: 600; color: var(--gray); }
.post-body .pull-quote figcaption::before { content: "— "; }

/* Tables: a header of small labels over a black rule, rows divided by thin rules, the first column bold */
.post-body .table-wrap { margin: 1.5rem 0 2rem; }
.post-body table { font-size: 15px; line-height: 1.5; }
.post-body th { padding: 0 0.9rem 0.6rem 0; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gray); border-bottom: 2px solid var(--black); }
.post-body td { padding: 0.8rem 0.9rem 0.8rem 0; }
.post-body td:first-child { font-weight: 600; color: var(--black); white-space: nowrap; }

/* Figures: full column width with a caption; a video card opens YouTube */
.post-body figure { margin: 2rem 0 2.25rem; }
.post-body figure img { display: block; width: 100%; max-width: 680px; height: auto; }
.post-body figcaption { margin-top: 0.75rem; font-size: 0.88rem; line-height: 1.5; color: var(--gray); }
.post-body .video a { display: flex; align-items: center; gap: 1.25rem; padding: 1rem; border: 1px solid var(--rule); color: var(--black);
                      text-decoration: none; transition: border-color 0.2s; }
.post-body .video a:hover { opacity: 1; border-color: var(--black); }
.video-tile { flex: none; display: grid; place-items: center; width: 64px; height: 64px; background: var(--black); }
.video-tile::after { content: ""; width: 26px; height: 26px; background: var(--white);
                     -webkit-mask: var(--icon-play) no-repeat center / contain; mask: var(--icon-play) no-repeat center / contain; }
.video-text { display: grid; gap: 0.2rem; flex: 1; min-width: 0; }
.video-title { font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.video-meta { font-size: 0.88rem; color: var(--gray); }
.video-btn { flex: none; }
.video a:hover .video-btn { background: var(--black); color: var(--white); }

/* Keep reading: other posts, before Follow along and the comments */
.keep-reading { margin-top: 3.5rem; padding-top: 1.75rem; border-top: 1px solid var(--black); }
.keep-reading .label { color: var(--gray); margin-bottom: 0.5rem; }
.post .next { display: block; padding: 1.25rem 0; border-bottom: 1px solid var(--rule); text-decoration: none; }
.post .next:hover { opacity: 1; }
.next .meta { display: block; }
.next-title { display: block; margin-top: 0.25rem; font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
.next-title span { display: inline-block; transition: transform 0.3s var(--ease); }
.next:hover .next-title span { transform: translateX(6px); }
.comments { scroll-margin-top: calc(var(--header-h) + 1rem); }

/* Motion: words rise from a mask (the title on load, section headings when reached); other blocks fade up.
   .pending is set only by js/motion.js, only on blocks still below the screen. */
.rise .w { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.rise .w > span { display: inline-block; transition: transform 1s var(--ease); transition-delay: calc(var(--i) * 55ms); }
.post > h1.rise .w > span { animation: rise 1.1s var(--ease) both; animation-delay: calc(var(--i) * 55ms + 0.1s); }
.rise.pending .w > span { transform: translateY(110%); }
@keyframes rise { from { transform: translateY(110%); } }
.post-body > *, .post-body .step, .keep-reading { transition: opacity 0.9s var(--ease), transform 1s var(--ease); }
.post-body .pending:not(.rise), .keep-reading.pending { opacity: 0; transform: translateY(24px); }
.post-body .pending .num { color: var(--rule); }

@media (max-width: 1100px) {
    .post-layout { grid-template-columns: minmax(0, 1fr); }
    .toc { display: none; }
}
@media (max-width: 700px) {
    .steps { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
    .post-body .video a { flex-wrap: wrap; gap: 0.9rem 1rem; }
    .video-tile { width: 52px; height: 52px; }
    .video-text { flex-basis: calc(100% - 52px - 1rem); }
    .video-btn { width: 100%; text-align: center; }
    .post-body td:first-child { white-space: normal; }
}
@media (prefers-reduced-motion: reduce) {
    .post > h1.rise .w > span { animation: none; }
    .rise .w > span, .post-body > *, .post-body .step, .keep-reading, .toc a, .post-body h3.numbered .num, .next-title span { transition: none; }
}
@media print {
    .progress, .toc { display: none; }
}

/* ============================================================
   LIKES, COPY LINK AND COMMENTS — filled in by social.js
   ============================================================ */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.post-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: -1.25rem 0 2.5rem; }
.like {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.6rem 1rem;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--black);
    background: transparent;
    border: 1px solid #ccc;
    cursor: pointer;
    transition: border-color 0.15s;
}
.like:hover:not(:disabled) { border-color: var(--black); }
.like:disabled { cursor: default; color: var(--muted); }
.like .heart { color: #888; font-size: 1rem; line-height: 1; transition: color 0.15s, transform 0.15s; }
.like.liked .heart { color: var(--red); }
.like.liked:active .heart { transform: scale(1.25); }
.like .like-count:empty { display: none; }

.comments { margin-top: 4rem; padding-top: 2rem; border-top: 1px solid var(--rule); }
.comments .comments-heading { margin: 0 0 1.25rem; font-size: 1.4rem; }
.comments p { margin: 0; }
.comments ol { margin: 0; padding: 0; list-style: none; }

.c-check:empty { display: none; }
.c-sort { display: flex; gap: 1.1rem; margin-top: 2rem; font-size: 0.85rem; }
.c-sort[hidden] { display: none; }
.c-sort button { padding: 0 0 2px; font: inherit; color: var(--gray); background: none; border: none; border-bottom: 1px solid transparent; cursor: pointer; }
.c-sort button:hover { color: var(--black); }
.c-sort button[aria-pressed="true"] { color: var(--black); font-weight: 600; border-bottom-color: var(--black); }
.c-sort + .comment-list { margin-top: 0.75rem !important; }

.c-form { display: grid; gap: 0.6rem; }
.c-form input, .c-form textarea {
    width: 100%;
    padding: 0.7rem 0.8rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--black);
    border: 1px solid #ccc;
    border-radius: 0;
}
.c-form textarea { resize: vertical; min-height: 5.5rem; line-height: 1.55; }
.c-form input:focus, .c-form textarea:focus { outline: none; border-color: var(--black); }
.c-form input { max-width: 320px; }
.c-form-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.c-counter { margin-right: auto; font-size: 0.8rem; color: var(--muted); }
.comments .c-error { font-size: 0.85rem; color: var(--red); }
.c-form-row .btn { padding: 0.5rem 1.2rem; }

.comment-list { margin-top: 2rem !important; }
.comment { padding: 1.5rem 0; border-top: 1px solid var(--rule); }
.c-replies { margin-left: 1.5rem !important; }
.c-replies .comment { padding: 1rem 0 0.25rem; border-top: none; }
.c-reply-slot .c-form { margin: 1rem 0 0 1.5rem; }
.c-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.6rem; font-size: 0.92rem; }
.c-head strong { min-width: 0; overflow-wrap: anywhere; }
.c-badge { padding: 1px 6px; font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--white); background: var(--black); }
.c-meta { font-size: 0.82rem; color: var(--muted); }
.comments .c-body { margin-top: 0.35rem; font-size: 1rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.c-actions { display: flex; gap: 1.1rem; margin-top: 0.5rem; }
.c-actions button { padding: 0; font: inherit; font-size: 0.82rem; color: var(--gray); background: none; border: none; cursor: pointer; }
.c-actions button:hover { color: var(--black); }
.c-vote { display: inline-flex; gap: 5px; filter: grayscale(1) brightness(0.6); }
.c-vote.voted { filter: none; opacity: 1; font-weight: 600; color: var(--black) !important; }
.c-actions .c-delete { color: var(--red); }
.c-empty { padding: 1.5rem 0; color: var(--muted); border-top: 1px solid var(--rule); }

/* ============================================================
   PHONES
   ============================================================ */
/* ============================================================
   FOLLOW ALONG — the Subscribe line, and the Subscribe page
   ============================================================ */
.follow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    margin: 0 0 4.5vw;
    padding: 1.25rem 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
}
.follow p { margin: 0; font-size: 0.98rem; line-height: 1.6; }
.post .follow { margin: 3.5rem 0 0; }
.rows + .follow { max-width: var(--content-width); margin: 0; padding: 2rem 0; border-top: none; }
.post .follow + .comments { margin-top: 2.5rem; border-top: none; }

.subscribe { max-width: var(--content-width); }
.sub-way { padding: 2rem 0; border-top: 1px solid var(--rule); }
.sub-way h2 { margin-bottom: 0.75rem; font-size: 1.25rem; letter-spacing: -0.01em; }
.sub-way p { margin-bottom: 0.75rem; line-height: 1.65; }
.sub-way code {
    font-family: 'Cascadia Code', Consolas, 'SF Mono', monospace;
    font-size: 0.9em;
    padding: 2px 6px;
    background: var(--light-gray);
    border: 1px solid #eee;
    overflow-wrap: anywhere;
    font-variant-ligatures: none;     /* Cascadia Code draws "//" as a wide ligature */
}
details.sub-note { margin-top: 1rem; }
details.sub-note summary { cursor: pointer; }
#agent-ask { margin-top: 0.5rem; padding: 10px 12px; background: var(--light-gray); border: 1px solid #eee; line-height: 1.6; }
.sub-form { display: flex; flex-wrap: wrap; gap: 10px; margin: 1.25rem 0 0.75rem; }
.sub-form[hidden] { display: none; }
.sub-form input {
    flex: 1 1 260px;
    max-width: 420px;
    padding: 0.6rem 0.8rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--black);
    border: 1px solid #ccc;
    border-radius: 0;
}
.sub-form input:focus { outline: none; border-color: var(--black); }
.sub-check:empty { display: none; }
.sub-check { flex-basis: 100%; }
.sub-status { font-size: 0.92rem; color: var(--gray); }
.sub-status.error { color: var(--red); }
.sub-status.done { color: var(--black); font-weight: 600; }
.sub-status:empty { display: none; }
.sub-note { font-size: 0.82rem; color: var(--muted); }
.sub-way .actions + .sub-note { margin-top: 1.25rem; }

/* Connect page: "Send a message" (js/contact.js), then the "Follow along" ways above */
.connect-part { margin-top: 0.5rem; padding-top: 2rem; border-top: 1px solid var(--rule); scroll-margin-top: 80px; }
.connect-part + .connect-intro { margin: 0.6rem 0 0.5rem; color: var(--gray); }
.connect-part ~ .sub-way:first-of-type, .connect-intro + .sub-way { border-top: none; }
#message { scroll-margin-top: 80px; }
.contact-form { display: grid; gap: 0.5rem; max-width: 640px; margin: 1.25rem 0 0.75rem; }
.contact-form[hidden] { display: none; }
.contact-form label { font-size: 0.85rem; font-weight: 600; }
.contact-form label span { font-weight: 400; color: var(--muted); }
.contact-form textarea, .contact-form input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--black);
    border: 1px solid #ccc;
    border-radius: 0;
}
.contact-form textarea { resize: vertical; min-height: 7.5rem; line-height: 1.55; }
.contact-form textarea:focus, .contact-form input:focus { outline: none; border-color: var(--black); }
.contact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem 12px; margin-top: 0.5rem; }
.contact-row > div { display: grid; gap: 0.5rem; align-content: start; }
.contact-check:empty { display: none; }
.contact-form .btn { justify-self: start; margin-top: 0.75rem; }
@media (max-width: 600px) { .contact-row { grid-template-columns: 1fr; } }

@media (max-width: 768px) {
    .menu { display: flex; }
    header nav {
        display: none;
        position: fixed;
        inset: 0;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        background: var(--white);
        color: var(--black);
    }
    header.open nav { display: flex; }
    header nav a { font-size: 1.3rem; }

    .now { grid-template-columns: minmax(0, 1fr); gap: 2.5rem; }
    .now-photo .img-placeholder { aspect-ratio: 16 / 9; }
    .doors { grid-template-columns: 1fr; }
    .door, .door:first-child, .door:last-child { padding: 1rem 0; border-right: none; }
    .popular-list { grid-template-columns: 1fr; }
    .popular-item, .popular-item:first-child, .popular-item:last-child { padding: 1rem 0; border-right: none; }
    main { padding: 2.5rem var(--page-padding) 3.5rem; }
    .hero { min-height: 60vh; padding-bottom: 3rem; }  /* room for the photo credit under the intro */
}
