/* ============================================================
   LeaveTime — Global Stylesheet
   Framework-free, mobile-first, accessible.
   ============================================================ */

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-tint: #dcfce7;
    --primary-soft: rgba(22, 163, 74, 0.08);

    --bg: #f7f9fb;
    --surface: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --danger: #dc2626;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
    --shadow-md: 0 4px 12px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.04);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

img,
svg {
    display: block;
    max-width: 100%;
}

a {
    color: var(--primary-dark);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3,
h4 {
    color: var(--text);
    margin: 0 0 12px;
    line-height: 1.25;
}

h1 {
    font-size: clamp(1.6rem, 2.4vw + 1rem, 2.25rem);
}

h2 {
    font-size: 1.4rem;
    margin-top: 32px;
}

h3 {
    font-size: 1.1rem;
    margin-top: 20px;
}

p {
    margin: 0 0 12px;
}

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

.skip-link {
    position: absolute;
    top: -40px;
    left: 8px;
    background: var(--primary);
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    z-index: 100;
}

.skip-link:focus {
    top: 8px;
}

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}

.narrow {
    max-width: 640px;
}

/* ============================================================
     Header + Nav
     ============================================================ */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.brand:hover {
    text-decoration: none;
}

.brand-icon {
    color: var(--primary);
}

.brand-name {
    font-size: 1.1rem;
}

.primary-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 20px;
}

.primary-nav a {
    color: var(--text);
    font-size: 0.95rem;
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
}

.primary-nav a:hover {
    color: var(--primary-dark);
    text-decoration: none;
    border-color: var(--primary);
}

.primary-nav [aria-current="page"] {
    color: var(--primary-dark);
    border-color: var(--primary);
}

.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    width: 40px;
    height: 40px;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    margin: 4px auto;
    transition: transform .2s ease, opacity .2s ease;
}

@media (max-width: 640px) {
    .nav-toggle {
        display: block;
    }

    .primary-nav {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease;
    }

    .primary-nav.is-open {
        max-height: 320px;
    }

    .primary-nav ul {
        flex-direction: column;
        padding: 12px 20px;
        gap: 4px;
    }

    .primary-nav a {
        display: block;
        padding: 12px 0;
        border: 0;
    }
}

/* ============================================================
     Hero
     ============================================================ */
.hero {
    text-align: center;
    padding: 40px 20px 24px;
}

.hero h1 {
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.hero .lede {
    color: var(--muted);
    font-size: 1.05rem;
    max-width: 520px;
    margin: 0 auto;
}

/* ============================================================
     Card
     ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-md);
}

.card+.card {
    margin-top: 16px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ============================================================
     Form fields
     ============================================================ */
.field {
    margin-bottom: 14px;
}

.field>label,
.field-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.field-icon {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.input-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px;
}

.input-row:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.input-row input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 10px 8px;
    font-size: 1rem;
    color: var(--text);
    min-width: 0;
}

.input-row input:focus {
    outline: none;
}

.input-suffix {
    align-self: center;
    padding: 0 10px;
    color: var(--muted);
    font-size: 0.9rem;
}

.custom-row input {
    min-width: 0;
}

.field-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.field-inline .field-label {
    margin: 0;
}

/* Preset chips */
.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.chip {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.9rem;
    cursor: pointer;
    color: var(--text);
    transition: all .15s ease;
}

.chip:hover {
    border-color: var(--border-strong);
}

.chip.is-active {
    background: var(--primary-tint);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 600;
}

/* Segmented control */
.segmented {
    display: inline-flex;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
}

.segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.segmented label {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--muted);
}

.segmented input:checked+label {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 12px 18px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--bg);
    text-decoration: none;
}

.btn-block {
    width: 100%;
}

.button-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.button-row .btn-primary {
    flex: 1;
}

/* Error */
.error {
    color: var(--danger);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 0.9rem;
    margin: 6px 0 0;
}

/* ============================================================
     Result card
     ============================================================ */
.result-card {
    background: linear-gradient(180deg, #fff, var(--primary-soft));
    border-color: var(--primary-tint);
    text-align: center;
}

.result-label {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.result-time {
    font-size: clamp(1.8rem, 2.5vw + 1rem, 2.4rem);
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.02em;
    margin: 4px 0 8px;
}

.result-remaining {
    color: var(--text);
    font-weight: 500;
    margin-bottom: 10px;
}

.progress {
    height: 8px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0 6px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 999px;
    transition: width .35s ease;
}

.progress-label {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 8px;
}

.result-detail {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
}

/* ============================================================
     Ad slot
     ============================================================ */
.ad-slot {
    margin-top: 28px;
}

.ad-frame {
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 18px;
    text-align: center;
    min-height: 120px;
    /* reserve space to prevent CLS */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.ad-tag {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin-bottom: 8px;
}

.ad-body {
    color: var(--muted);
    font-size: 0.9rem;
}

/* ============================================================
     Prose sections
     ============================================================ */
.prose {
    padding: 32px 20px 4px;
}

.prose h2 {
    border-top: 1px solid var(--border);
    padding-top: 24px;
}

.prose .check-list {
    list-style: none;
    padding: 0;
}

.prose .check-list li {
    padding-left: 26px;
    position: relative;
    margin-bottom: 6px;
}

.prose .check-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: 700;
}

.formula {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.95rem;
}

.example {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
}

.example h3 {
    margin-top: 0;
}

/* FAQ accordion */
.faq-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 10px;
    padding: 4px 16px;
}

.faq-item summary {
    cursor: pointer;
    padding: 12px 0;
    font-weight: 600;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: "+";
    color: var(--muted);
    font-size: 1.4rem;
    line-height: 1;
}

.faq-item[open] summary::after {
    content: "-";
}

.faq-item p {
    padding-bottom: 12px;
    color: var(--muted);
}

/* Contact form */
.contact-form .field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

/* ============================================================
     Footer
     ============================================================ */
.site-footer {
    border-top: 1px solid var(--border);
    background: var(--surface);
    margin-top: 40px;
    padding: 24px 0 32px;
}

.footer-inner {
    text-align: center;
}

.site-footer nav ul {
    list-style: none;
    padding: 0;
    margin: 0 0 8px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
}

.site-footer a {
    color: var(--muted);
    font-size: 0.9rem;
}

.site-footer a:hover {
    color: var(--primary-dark);
}

.copyright {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0;
}

.muted {
    color: var(--muted);
}

/* Print */
@media print {

    .site-header,
    .site-footer,
    .ad-slot,
    .button-row,
    .nav-toggle {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border-color: #999;
    }
}