/* InkTree Daily Care — Family letter
   ------------------------------------------------------------------
   A warm editorial letter, not a product landing.
   Ground: cream paper. Ink: warm charcoal. One rust accent.
   Display: Fraunces (variable, SOFT axis dialed for warmth).
   Body: system serif stack — the Substack reading grain.
   ------------------------------------------------------------------ */

:root {
    /* Warm cream paper — a shade off pure white, biased amber not gray */
    --ground: #f7f1e6;
    /* One tone deeper for surface hairlines and rest */
    --ground-shade: #efe7d6;
    /* Warm charcoal ink for body text */
    --ink: #2b2418;
    /* Softer ink for meta / secondary — tinted from the ground, never gray */
    --ink-muted: #6b5f4b;
    --ink-quiet: #a2937b;
    /* One accent: warm terracotta — for the pulse, links, and section marks */
    --accent: #a94b2a;
    --accent-soft: #d38867;
    /* Hairlines: thin, warm, low-contrast */
    --rule: #d9cdb4;
    --rule-quiet: #e6dcc4;
    /* Focus ring in the accent hue */
    --focus: #a94b2a;

    --measure: 40rem;         /* ~640px — book column */
    --measure-wide: 46rem;    /* video figure — a little wider than the text */

    /* System serif stack — Substack's own reading grain. Iowan Old Style on
       Apple platforms, Charter as its close cousin, Palatino/Georgia on
       Windows. This is calmer and warmer than any Google Font, and honest to
       the letter form. */
    --serif-display: 'Iowan Old Style', 'Charter', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
    --serif-body: 'Iowan Old Style', 'Charter', 'Palatino Linotype', Palatino, Georgia, 'Times New Roman', serif;
    --sans-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* Reset that keeps the browser surfaces theme-able */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Browser surfaces — theme the parts we didn't draw */
::selection {
    background: var(--accent);
    color: var(--ground);
}
html {
    accent-color: var(--accent);
    caret-color: var(--accent);
    color-scheme: light;
    scroll-behavior: smooth;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb {
    background: var(--rule);
    border: 3px solid var(--ground);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-quiet); }

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

html,
body {
    background: var(--ground);
    color: var(--ink);
}

body {
    font-family: var(--serif-body);
    font-size: 1.125rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
    /* iPhone notch — keep content off the safe-area edges */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Lock light — some browsers auto-invert when a user is in dark mode and the
   page doesn't declare a strong preference. This block re-asserts every
   color explicitly so the cream paper never flips. */
@media (prefers-color-scheme: dark) {
    html,
    body {
        background: var(--ground);
        color: var(--ink);
    }
    .form-embed { background: #fff; }
    .video-frame { background: var(--ink); }
}

/* Skip link — visible only on focus */
.skip-link {
    position: absolute;
    left: 1rem;
    top: 1rem;
    background: var(--ink);
    color: var(--ground);
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    font-family: var(--sans-ui);
    font-size: 0.875rem;
    border-radius: 3px;
    transform: translateY(-200%);
    transition: transform 200ms ease;
    z-index: 100;
}
.skip-link:focus {
    transform: translateY(0);
}

/* ------------------------------------------------------------------
   Masthead — small, quiet, top of the letter
   ------------------------------------------------------------------ */

.masthead {
    padding: 2rem 1.5rem 1rem;
}

.masthead-inner {
    max-width: var(--measure);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--ink);
    font-family: var(--serif-display);
    font-weight: 400;
    font-size: 1.1875rem;
    letter-spacing: -0.005em;
}

.wordmark img {
    width: 26px;
    height: 26px;
    display: block;
}

.masthead-meta {
    font-family: var(--sans-ui);
    font-size: 0.8125rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-muted);
    font-weight: 500;
}

/* ------------------------------------------------------------------
   Letter — the main article column
   ------------------------------------------------------------------ */

.letter {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 3rem 1.5rem 5rem;
}

/* --- Lede --- */

.lede {
    margin-bottom: 3.5rem;
}

.lede h1 {
    font-family: var(--serif-display);
    font-size: clamp(2.125rem, 4.6vw, 3.25rem);
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 400;
    color: var(--ink);
    text-wrap: balance;
    margin-bottom: 1.75rem;
    /* Enable the ligatures and old-style figures that ship with Iowan Old
       Style and Charter — the small typographic details that separate a
       book face from a UI font. */
    font-feature-settings: "kern", "liga", "onum" 1, "ss01" 1;
}

.standfirst {
    font-family: var(--serif-body);
    font-size: 1.1875rem;
    line-height: 1.6;
    color: var(--ink-muted);
    max-width: 34rem;
}

/* --- Video figure --- */

.video-figure {
    margin: 3rem calc(-1rem) 2.5rem;
}

.video-frame {
    position: relative;
    background: var(--ink);
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    /* Never taller than the viewport, even if aspect-ratio calculation flakes
       on a browser that doesn't fully support it. */
    max-height: 70vh;
    /* A single hairline instead of a shadow. The paper doesn't lift, it lies flat. */
    box-shadow: 0 0 0 1px var(--rule);
}

.video-frame video,
.video-frame iframe {
    width: 100%;
    height: 100%;
    display: block;
    border: 0;
}

.video-caption {
    font-family: var(--sans-ui);
    font-size: 0.875rem;
    color: var(--ink-quiet);
    text-align: center;
    margin-top: 1rem;
    font-style: italic;
}

/* --- Scroll cue --- */

.scroll-cue {
    font-family: var(--serif-body);
    font-style: italic;
    text-align: center;
    color: var(--ink-quiet);
    margin: 3rem 0 2rem;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 600ms ease, transform 600ms ease;
    font-size: 1rem;
}
.scroll-cue.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ------------------------------------------------------------------
   Form section — the second half of the letter
   ------------------------------------------------------------------ */

.form-section {
    scroll-margin-top: 2rem;
    padding-top: 2.5rem;
    /* One quiet hairline where the letter turns to its second beat */
    border-top: 1px solid var(--rule);
    transition: border-color 800ms ease;
}

.form-heading {
    margin-bottom: 2rem;
    text-align: left;
}

.form-heading h2 {
    font-family: var(--serif-display);
    font-size: clamp(1.625rem, 3vw, 2.125rem);
    font-weight: 400;
    letter-spacing: -0.015em;
    line-height: 1.15;
    color: var(--ink);
    margin-bottom: 1rem;
    font-feature-settings: "kern", "liga", "onum" 1;
}

.form-lede {
    font-family: var(--serif-body);
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--ink-muted);
    max-width: 32rem;
}

/* --- Google Form embed ---
   Full width of the letter column. A single hairline instead of a card. */

.form-embed {
    background: #fff;
    border: 1px solid var(--rule);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 2rem;
    /* The pulse target — a warm halo that arrives when the video finishes */
    transition: box-shadow 900ms ease, border-color 900ms ease;
}

.form-embed iframe {
    display: block;
    width: 100%;
    min-height: 1600px;
    background: #fff;
}

/* Pulse — one authored moment, arriving when the video ends.
   Not a hard neon flash; a warm terracotta glow that swells and fades. */
.form-section.pulse {
    border-top-color: var(--accent);
}
.form-embed.pulse {
    box-shadow: 0 0 0 1px var(--accent-soft), 0 12px 40px -12px rgba(169, 75, 42, 0.28);
    border-color: var(--accent-soft);
    animation: warm-glow 2400ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes warm-glow {
    0%   { box-shadow: 0 0 0 1px var(--rule), 0 0 0 0 rgba(169, 75, 42, 0); }
    30%  { box-shadow: 0 0 0 1px var(--accent-soft), 0 18px 60px -8px rgba(169, 75, 42, 0.35); }
    100% { box-shadow: 0 0 0 1px var(--rule), 0 12px 40px -20px rgba(169, 75, 42, 0); }
}

/* ------------------------------------------------------------------
   Closing — the signature
   ------------------------------------------------------------------ */

.closing {
    margin-top: 4rem;
    padding-top: 2.5rem;
    border-top: 1px solid var(--rule-quiet);
    text-align: left;
}

.signature {
    font-family: var(--serif-body);
    font-style: italic;
    font-size: 1.0625rem;
    color: var(--ink);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.signer {
    font-style: normal;
    font-family: var(--serif-display);
    font-weight: 400;
    font-size: 1.25rem;
    letter-spacing: -0.01em;
}

.fine-print {
    font-family: var(--sans-ui);
    font-size: 0.8125rem;
    color: var(--ink-quiet);
    line-height: 1.5;
}

.closing a,
.fine-print a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: var(--accent-soft);
    transition: text-decoration-color 200ms ease;
}
.closing a:hover,
.fine-print a:hover {
    text-decoration-color: var(--accent);
}

/* ------------------------------------------------------------------
   Responsive
   ------------------------------------------------------------------ */

@media (max-width: 640px) {
    .masthead { padding: 1.5rem 1.25rem 0.5rem; }
    .letter { padding: 2rem 1.25rem 3.5rem; }

    /* Bleed the video slightly past the text column on mobile so it feels
       like an embed rather than a boxed thumbnail */
    .video-figure { margin: 2.5rem -1.25rem 2rem; }
    .video-frame { border-radius: 0; box-shadow: none; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }

    .form-embed iframe { min-height: 100vh; }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .scroll-cue { transition: opacity 1ms; }
    .form-section, .form-embed { transition: none; }
    .form-embed.pulse { animation: none; }
}
