/* ==========================================================================
   Aspect Ratio Calculator — Premium Light UI
   Design system: indigo accent (hue 274), Inter, white cards on soft paper.
   This stylesheet is shared by every pSEO subpage (16-9, 4-3, 21-9, 1-1, 4-5,
   9-16, 3-2, 4k/8k, iphone). Class vocabulary and custom properties are kept
   intact — only restyled to light. Custom properties consumed by subpage inline
   styles (--text, --heading, --primary, --border, --muted, --accent) are all
   defined below so nothing renders unstyled.
   ========================================================================== */

:root {
    /* Core light tokens (accent hue 274 — indigo) */
    --ink: oklch(24% .02 264);
    --muted: oklch(52% .03 264);
    --paper: oklch(97% .008 264);
    --surface: oklch(100% .002 264);
    --line: oklch(90% .015 264);
    --accent: oklch(56% .19 274);
    --accent-dark: oklch(46% .17 274);
    --accent-soft: oklch(94% .04 274);

    /* Stateful UI tokens (copy success + validation) */
    --ok: oklch(52% .13 155);
    --ok-soft: oklch(94% .05 155);
    --danger: oklch(55% .19 25);
    --danger-soft: oklch(95% .04 25);

    /* Aliases consumed by pSEO subpage inline styles — mapped to light tokens */
    --text: var(--ink);
    --heading: var(--ink);
    --primary: var(--accent);
    --border: var(--line);
    /* Light fallbacks for surface vars some subpages consume (self-defining
       subpages override these via their own inline :root; kept here so the
       shared contract is satisfied for every property subpages reference). */
    --bg: var(--paper);
    --section-alt-bg: oklch(95% .01 264);
    --header-bg: oklch(100% .002 264 / .85);

    /* Geometry & motion */
    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px oklch(24% .02 264 / .05), 0 1px 3px oklch(24% .02 264 / .04);
    --shadow-md: 0 4px 12px oklch(24% .02 264 / .06), 0 12px 32px oklch(24% .02 264 / .07);
    --shadow-lg: 0 8px 24px oklch(24% .02 264 / .08), 0 24px 60px oklch(24% .02 264 / .10);
    --ease: cubic-bezier(.16, 1, .3, 1);
    --maxw: 1140px;
}

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

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

body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

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

img { max-width: 100%; height: auto; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem clamp(1rem, 4vw, 2.5rem);
    background: oklch(100% .002 264 / .85);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--line);
}

.logo {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -.02em;
    color: var(--ink);
}
.logo span { color: var(--accent); }

.site-header nav {
    display: flex;
    gap: .35rem;
    align-items: center;
}
.site-header nav a {
    padding: .5rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--muted);
    font-weight: 500;
    font-size: .95rem;
    transition: background-color .2s var(--ease), color .2s var(--ease);
}
.site-header nav a:hover {
    color: var(--ink);
    background: var(--accent-soft);
}

.menu-btn {
    display: none;
    padding: .6rem 1rem;
    min-height: 44px;
    font: inherit;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

/* --------------------------------------------------------------------------
   Layout wrapper + hero
   -------------------------------------------------------------------------- */
.page-wrapper {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: clamp(1.25rem, 4vw, 2.5rem);
}

.hero {
    text-align: center;
    padding: clamp(2rem, 6vw, 4rem) 0 clamp(1.5rem, 4vw, 2.5rem);
}
.hero-chip, .hero-badge {
    display: inline-block;
    padding: .4rem .9rem;
    margin-bottom: 1.25rem;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .01em;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border: 1px solid oklch(56% .19 274 / .18);
    border-radius: var(--radius-pill);
}
.page-title {
    margin: 0 0 1rem;
    font-size: clamp(2.2rem, 6vw, 3.6rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.03em;
    color: var(--ink);
}
.page-sub {
    max-width: 640px;
    margin: 0 auto;
    font-size: clamp(1rem, 2.2vw, 1.2rem);
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   App container — calculator + preview
   -------------------------------------------------------------------------- */
.app-container {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 1.5rem;
    align-items: start;
}

.controls-panel,
.preview-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1.25rem, 3vw, 2rem);
    box-shadow: var(--shadow-md);
}

/* Tabs */
.tabs {
    display: flex;
    gap: .4rem;
    padding: .3rem;
    margin-bottom: 1.5rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.tab-btn {
    flex: 1;
    padding: .7rem .9rem;
    min-height: 44px;
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    color: var(--muted);
    background: transparent;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.active {
    color: var(--accent-dark);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

/* Calc sections — hidden unless active */
.calc-section { display: none; }
.calc-section.active-section { display: block; animation: fade-in .3s var(--ease); }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Inputs */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.input-grid:has(> .input-group:only-child) { grid-template-columns: 1fr; }

.input-group { display: flex; flex-direction: column; gap: .5rem; }
.input-group label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .01em;
}
.input-group input[type="number"],
.dual-input input[type="number"] {
    width: 100%;
    padding: .8rem .9rem;
    min-height: 48px;
    font: inherit;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
    -moz-appearance: textfield;
}
.input-group input[type="number"]:focus,
.dual-input input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px oklch(56% .19 274 / .16);
}

.dual-input {
    display: flex;
    align-items: center;
    gap: .6rem;
}
.dual-input span {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--muted);
}

/* Extraction result */
.extraction-result {
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--accent-soft);
    border: 1px solid oklch(56% .19 274 / .16);
    border-radius: var(--radius);
}
.extraction-result .muted,
.muted { color: var(--muted); }
.ratio-display {
    font-size: clamp(2rem, 8vw, 3rem);
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--accent-dark);
    line-height: 1.1;
}
.math-logic {
    font-size: .88rem;
    color: var(--muted);
    font-weight: 500;
}

/* Presets */
.presets-library h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 .9rem;
}
.preset-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .55rem;
}
.preset-btn {
    padding: .6rem 1rem;
    min-height: 44px;
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: transform .25s var(--ease), border-color .2s var(--ease), color .2s var(--ease), background-color .2s var(--ease), box-shadow .2s var(--ease);
}
.preset-btn:hover {
    transform: translateY(-2px);
    color: var(--accent-dark);
    border-color: oklch(56% .19 274 / .4);
    background: var(--accent-soft);
    box-shadow: var(--shadow-sm);
}
.preset-btn.active {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Preview panel
   -------------------------------------------------------------------------- */
.preview-title,
.preview-panel h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 1rem;
}
.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 1.25rem;
    background: var(--paper);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    margin-bottom: .5rem;
}
.preview-box {
    width: 100%;
    max-width: 320px;
    max-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    transition: aspect-ratio .4s var(--ease);
}
.preview-text {
    font-size: .95rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px oklch(24% .02 264 / .35);
}

/* Clipboard / code boxes */
.css-clipboard label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: .5rem;
}
.code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .6rem .6rem 1rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
}
.code-box code {
    font-family: 'SFMono-Regular', ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
    font-size: .9rem;
    color: var(--ink);
    overflow-x: auto;
    white-space: nowrap;
}
.copy-btn {
    flex-shrink: 0;
    padding: .5rem 1rem;
    min-height: 40px;
    font: inherit;
    font-weight: 600;
    font-size: .85rem;
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color .2s var(--ease), transform .2s var(--ease);
}
.copy-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }

/* Spacing utilities (consumed by main page + subpages) */
.mt-2 { margin-top: .5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 2rem; }
.mb-1 { margin-bottom: .35rem; }

/* --------------------------------------------------------------------------
   SEO / editorial content
   -------------------------------------------------------------------------- */
.seo-doc {
    max-width: 850px;
    margin: clamp(3rem, 8vw, 5rem) auto 0;
}
.seo-doc h2 {
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ink);
    margin: 2.5rem 0 1rem;
}
.seo-doc h3 { font-size: 1.15rem; font-weight: 700; color: var(--ink); margin: 1.5rem 0 .6rem; }
.seo-doc p { color: var(--muted); margin: 0 0 1.1rem; }
.seo-doc code {
    font-family: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
    font-size: .88em;
    padding: .12em .4em;
    color: var(--accent-dark);
    background: var(--accent-soft);
    border-radius: 6px;
}

/* Generic containers used by pSEO subpages */
.dt-container { max-width: 850px; margin: 0 auto; }
.dt-mb-16 { margin-bottom: 2rem; }

/* Resource grid cards */
.dt-resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0 2rem;
}
.dt-resource-card {
    display: block;
    padding: 1.4rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.dt-resource-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: oklch(56% .19 274 / .3);
}
.dt-resource-card h3,
.dt-resource-card .title { margin: 0 0 .5rem; font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.dt-resource-card p,
.dt-resource-card .desc { margin: 0; font-size: .92rem; color: var(--muted); }

/* Tables */
.table-responsive { overflow-x: auto; margin: 1.5rem 0 2rem; border-radius: var(--radius); border: 1px solid var(--line); }
.specs-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: .93rem;
}
.specs-table thead th {
    text-align: left;
    padding: .9rem 1rem;
    font-weight: 700;
    color: var(--ink);
    background: var(--paper);
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
}
.specs-table td {
    padding: .85rem 1rem;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
.specs-table tbody tr:last-child td { border-bottom: none; }
.specs-table tbody tr:hover td { background: var(--accent-soft); }

/* FAQ */
.faq-section { margin-top: 2.5rem; }
.faq-heading { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; color: var(--ink); margin: 0 0 1.25rem; letter-spacing: -.02em; }
.faq-list { display: flex; flex-direction: column; gap: .75rem; }
.faq-item {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0 1.2rem;
    box-shadow: var(--shadow-sm);
    transition: border-color .2s var(--ease);
}
.faq-item[open] { border-color: oklch(56% .19 274 / .3); }
.faq-item summary {
    padding: 1.1rem 0;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-right: 2rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: "+";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.4rem;
    font-weight: 400;
    color: var(--accent);
    transition: transform .25s var(--ease);
}
.faq-item[open] summary::after { transform: translateY(-50%) rotate(45deg); }
.faq-item p, .faq-item .faq-a { margin: 0 0 1.1rem; color: var(--muted); }
.faq-item .faq-q { padding: 1.1rem 0; font-weight: 600; color: var(--ink); }

/* Related tools */
.related-section { margin-top: 2.5rem; }
.related-heading { font-size: clamp(1.4rem, 3.5vw, 1.8rem); font-weight: 800; color: var(--ink); margin: 0 0 1.25rem; letter-spacing: -.02em; }
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
.related-card {
    padding: 1.1rem 1.25rem;
    font-weight: 600;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease), color .2s var(--ease);
}
.related-card:hover {
    transform: translateY(-4px);
    color: var(--accent-dark);
    border-color: oklch(56% .19 274 / .3);
    box-shadow: var(--shadow-md);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    margin-top: clamp(3rem, 8vw, 5rem);
    padding: 2rem clamp(1rem, 4vw, 2.5rem);
    text-align: center;
    color: var(--muted);
    font-size: .9rem;
    border-top: 1px solid var(--line);
}
.site-footer a { color: var(--muted); font-weight: 500; }
.site-footer a:hover { color: var(--accent-dark); }
.footer-links { display: flex; gap: 1.25rem; justify-content: center; margin-top: .75rem; }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    padding: .8rem 1.4rem;
    font-weight: 600;
    font-size: .9rem;
    color: #fff;
    background: var(--ink);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s var(--ease), opacity .35s var(--ease);
    z-index: 100;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* --------------------------------------------------------------------------
   Focus visibility & accessibility
   -------------------------------------------------------------------------- */
:focus-visible {
    outline: 3px solid oklch(56% .19 274 / .5);
    outline-offset: 2px;
    border-radius: 4px;
}

/* --------------------------------------------------------------------------
   Responsive — single column below 900px, 16px inputs to prevent iOS zoom
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .app-container { grid-template-columns: 1fr; }
    .site-header nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        gap: .25rem;
        padding: 1rem clamp(1rem, 4vw, 2.5rem);
        background: var(--surface);
        border-bottom: 1px solid var(--line);
        box-shadow: var(--shadow-md);
    }
    .site-header nav.open { display: flex; }
    .site-header nav a { padding: .8rem 1rem; }
    .menu-btn { display: inline-flex; align-items: center; }
}

@media (max-width: 560px) {
    .input-grid { grid-template-columns: 1fr; }
    .input-group input[type="number"],
    .dual-input input[type="number"] { font-size: 16px; }
    .footer-links { flex-direction: column; gap: .5rem; }
}

/* --------------------------------------------------------------------------
   Stateful tool UI — copy success, validation, reset, howto steps
   -------------------------------------------------------------------------- */
.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;
}

.copy-btn.is-copied {
    background: var(--ok);
}
.copy-btn.is-copied:hover { background: var(--ok); }

.clear-btn {
    display: inline-flex;
    align-items: center;
    padding: .6rem 1.1rem;
    min-height: 44px;
    font: inherit;
    font-size: .88rem;
    font-weight: 600;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: color .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease);
}
.clear-btn:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: var(--danger-soft);
}

.calc-msg {
    margin: 1rem 0 0;
    padding: .7rem .9rem;
    font-size: .86rem;
    font-weight: 600;
    color: var(--danger);
    background: var(--danger-soft);
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
}
.calc-msg[hidden] { display: none; }

.howto-steps {
    margin: 1.2rem 0 1.5rem;
    padding-left: 1.3rem;
    color: var(--muted);
}
.howto-steps li { margin: 0 0 .7rem; }
.howto-steps li strong { color: var(--ink); }

/* --------------------------------------------------------------------------
   Reduced motion — MUST be the final block in this stylesheet
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
