/*
 * /subscribe/ — focused signup page for the Page Street Performance newsletter.
 * Skinned to PSP (2026-11-12), not ivsanz.com: the next steps in the journey
 * (/newsletter/, the beehiiv issues, the app) are all PSP, so this page uses
 * the same tokens as styles.css: DM Sans (self-hosted), app paper, ink, and
 * spark lime for the one CTA only. Values are mirrored here rather than
 * loading styles.css, to keep the page light and collision-free.
 *
 * All selectors are .sub-* prefixed so this file does not collide with
 * the site-global styles.css.
 */

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

/* HTML5 hidden attribute — explicit because .sub-result uses display:flex
   and would otherwise override the user-agent default of display:none. */
[hidden] {
    display: none !important;
}

@font-face {
    font-family: 'DM Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('/fonts/dm-sans.woff2') format('woff2');
}

:root {
    /* Mirrored from styles.css: --bg, --ink, --spark, --forest. */
    --sub-paper:        #f5f5f4;
    --sub-ink:          #1d1d1b;
    --sub-spark:        #e7ff6d;
    --sub-spark-hover:  #d4eb5a;
    --sub-forest:       #218331;
    --sub-text:         #1d1d1b;
    --sub-text-muted:   #57534e;
    --sub-text-faint:   #706a65;
    --sub-border:       #e6e5e1;
    --sub-error:        #b94a3b;

    --sub-font: 'DM Sans', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --sub-transition: 0.18s ease;
    --sub-radius: 14px;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.sub-page {
    background: var(--sub-paper);
    color: var(--sub-text);
    font-family: var(--sub-font);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sub-container {
    flex: 1;
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: 2rem 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
}

/* ================================
   Card — heading, lede, form
   ================================ */

.sub-card {
    display: flex;
    flex-direction: column;
}

.sub-heading {
    font-size: clamp(2rem, 7vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.1;
    color: var(--sub-ink);
    margin-bottom: 0.75rem;
}

.sub-lede {
    font-size: 1.125rem;
    line-height: 1.5;
    color: var(--sub-text-muted);
    max-width: 36ch;
    margin-bottom: 1.75rem;
}

/* Attribution under the default-state lede — grounds the first-person "me"
   as Ivan and names the newsletter for anyone landing here without the
   ivsanz.com context (e.g. a direct/PSP visit). */
.sub-default .sub-lede {
    margin-bottom: 0.4rem;
}

.sub-attribution {
    font-size: 0.9rem;
    color: var(--sub-text-faint);
    margin-bottom: 1.75rem;
}

/* ================================
   Form
   ================================ */

.sub-form {
    display: flex;
    flex-direction: column;
}

.sub-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sub-row {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.sub-input {
    width: 100%;
    padding: 0.95rem 1rem;
    background: #ffffff;
    border: 1px solid var(--sub-border);
    border-radius: var(--sub-radius);
    font-family: inherit;
    font-size: 1rem;
    color: var(--sub-text);
    transition: border-color var(--sub-transition), box-shadow var(--sub-transition);
    -webkit-appearance: none;
    appearance: none;
}

.sub-input::placeholder {
    color: var(--sub-text-faint);
}

.sub-input:focus {
    outline: none;
    border-color: var(--sub-ink);
    box-shadow: 0 0 0 3px rgba(29, 29, 27, 0.10);
}

.sub-input.is-invalid {
    border-color: var(--sub-error);
}

.sub-input:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.sub-button {
    position: relative;
    width: 100%;
    padding: 0.95rem 1.25rem;
    background: var(--sub-spark);
    color: var(--sub-ink);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.005em;
    cursor: pointer;
    transition: background-color var(--sub-transition), border-color var(--sub-transition), transform var(--sub-transition);
}

.sub-button:hover:not(:disabled) {
    background: var(--sub-spark-hover);
    transform: translateY(-1px);
}

.sub-button:active:not(:disabled) {
    transform: translateY(0);
}

.sub-button:focus-visible {
    outline: 2px solid var(--sub-ink);
    outline-offset: 2px;
}

.sub-button:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.sub-button[data-loading="true"] .sub-button-label {
    visibility: hidden;
}

.sub-button-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.1rem;
    height: 1.1rem;
    margin: -0.55rem 0 0 -0.55rem;
    border: 2px solid rgba(29, 29, 27, 0.25);
    border-top-color: var(--sub-ink);
    border-radius: 50%;
    opacity: 0;
    transition: opacity var(--sub-transition);
    animation: sub-spin 0.8s linear infinite;
}

.sub-button[data-loading="true"] .sub-button-spinner {
    opacity: 1;
}

@keyframes sub-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .sub-button-spinner { animation-duration: 2s; }
    .sub-button:hover { transform: none; }
}

/* Honeypot — invisible to humans, present in DOM for bots */
.sub-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* Status message under the form */
.sub-msg {
    margin-top: 0.85rem;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--sub-text-muted);
}

.sub-msg.is-error {
    color: var(--sub-error);
}

/* Fallback link inside the Turnstile-failure message */
.sub-msg a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ================================
   Result states (post-submit)
   ================================ */

.sub-result {
    display: flex;
    flex-direction: column;
}

.sub-result .sub-heading {
    margin-bottom: 0.75rem;
}

.sub-result .sub-lede {
    margin-bottom: 0;
}

/* Decorative accent under success heading (forest: spark is reserved for CTAs) */
.sub-result--success::before {
    content: '';
    display: block;
    width: 2.5rem;
    height: 3px;
    background: var(--sub-forest);
    border-radius: 2px;
    margin-bottom: 1.25rem;
}

/* ================================
   Archive links: a quiet way to read before (or right after) subscribing.
   Default state: its own line between the attribution and the form (not under
   the form: .sub-turnstile reserves 65px of usually-blank space for a challenge).
   Success state: its own line under the lede.
   ================================ */

.sub-aside {
    font-size: 0.9rem;
    color: var(--sub-text-faint);
}

/* Pulls the attribution's 1.75rem gap below the archive line instead. */
.sub-default .sub-attribution {
    margin-bottom: 0.35rem;
}

.sub-aside--lead {
    margin-bottom: 1.75rem;
}

.sub-result .sub-aside {
    margin-top: 1rem;
}

.sub-aside-link {
    white-space: nowrap;
    color: var(--sub-text-muted);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: rgba(29, 29, 27, 0.2);
    transition: color var(--sub-transition), text-decoration-color var(--sub-transition);
}

.sub-aside-link:hover {
    color: var(--sub-ink);
    text-decoration-color: var(--sub-ink);
}

.sub-aside-link:focus-visible {
    outline: 2px solid var(--sub-ink);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ================================
   Footer back-link
   ================================ */

.sub-footer {
    margin-top: 2.5rem;
    text-align: left;
}

.sub-back {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--sub-text-faint);
    text-decoration: none;
    transition: color var(--sub-transition);
}

.sub-back:hover {
    color: var(--sub-text-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.sub-back:focus-visible {
    outline: 2px solid var(--sub-ink);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ================================
   Responsive
   ================================ */

@media (min-width: 640px) {
    .sub-container {
        padding: 3rem 2rem 2rem;
        gap: 2rem;
    }

    .sub-row {
        flex-direction: row;
        gap: 0.75rem;
    }

    .sub-button {
        width: auto;
        flex-shrink: 0;
        padding-left: 1.75rem;
        padding-right: 1.75rem;
    }

    .sub-lede {
        font-size: 1.2rem;
        max-width: 40ch;
    }
}

@media (min-width: 960px) {
    .sub-container {
        padding-top: 4rem;
    }
}

/* Cloudflare Turnstile wrapper — sits between the input row and the message line */
.sub-turnstile {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-start;
    min-height: 65px;
}
