/* ========================================
   Youpi Devoirs — Shared Styles
   ======================================== */

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

/* ---- Theme ---- */

:root {
    color-scheme: dark;
    --bg: #0b0b0c;
    --surface: #161618;
    --border: #262629;
    --text: #f3f3f1;
    --muted: #97979d;
    --accent: #db4b37;
    --accent-hover: #e85b46;
    --on-accent: #ffffff;
    --radius: 10px;
}

[data-theme="light"] {
    color-scheme: light;
    --bg: #f7f6f3;
    --surface: #ffffff;
    --border: #e7e5e0;
    --text: #1a1a1c;
    --muted: #6c6c74;
    --accent: #c63f2c;
    --accent-hover: #ad3320;
}

/* ---- Base ---- */

html, body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.25s ease, color 0.25s ease;
}

::selection {
    background: var(--accent);
    color: var(--on-accent);
}

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

a {
    color: var(--accent);
    text-decoration: none;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
}

a:hover {
    text-decoration: underline;
}

/* ---- Theme Toggle ---- */

.theme-toggle {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 100;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--muted);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ---- Index / Hero ---- */

.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 100vh;
    padding: 2rem 1.5rem;
    max-width: 540px;
    margin: 0 auto;
}

.logo {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 22px;
    margin-bottom: 2.25rem;
}

h1 {
    font-size: clamp(2.1rem, 6vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.035em;
    line-height: 1.1;
    margin-bottom: 0.9rem;
    color: var(--text);
    text-wrap: balance;
}

.subtitle {
    font-size: 1.075rem;
    color: var(--muted);
    line-height: 1.6;
    max-width: 34ch;
    margin: 0 auto 2.75rem;
    text-wrap: balance;
}

/* Download buttons */

.download-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.85rem;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: var(--accent);
    color: var(--on-accent);
    text-decoration: none;
    padding: 14px 26px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.18s ease, transform 0.08s ease;
}

.btn-download:hover {
    background: var(--accent-hover);
    text-decoration: none;
}

.btn-download:active {
    transform: scale(0.985);
}

/* Disabled / coming-soon state */

.btn-download.btn-disabled {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
    cursor: not-allowed;
}

.btn-download.btn-disabled:hover {
    background: var(--surface);
}

.btn-download.btn-disabled:active {
    transform: none;
}

.btn-download.btn-disabled .btn-icon {
    fill: var(--muted);
}

.btn-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: var(--on-accent);
}

.btn-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.15;
}

.btn-label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0.85;
}

.btn-action {
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

/* ---- Loading / availability probe ----
   The static markup is only a fallback (Android ready, iOS coming-soon). Until
   the JS HEAD probe confirms each asset, the button shows a neutral spinner
   instead of a guessed state, so it never flashes from one to the other.
   `html.probing` is set before paint by an inline <head> snippet; app.js adds
   `is-resolved` to each button as its probe settles. No JS = no `probing` class
   = the static markup shows. */

html.probing .btn-download:not(.is-resolved) {
    background: var(--surface);
    color: var(--muted);
    border-color: var(--border);
    cursor: progress;
    pointer-events: none;
}

html.probing .btn-download:not(.is-resolved) .btn-icon {
    fill: var(--muted);
}

html.probing .btn-download:not(.is-resolved) .btn-action {
    color: transparent;
    position: relative;
}

html.probing .btn-download:not(.is-resolved) .btn-action::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid var(--border);
    border-top-color: var(--muted);
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}

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

/* Footer links */

.footer-links {
    margin-top: 3rem;
    display: flex;
    gap: 1.5rem;
    font-size: 0.8rem;
}

.footer-links a {
    color: var(--muted);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--text);
    text-decoration: none;
}

/* ---- Legal Pages (terms, privacy) ---- */

.legal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 56px 20px 80px;
}

.legal-container {
    max-width: 720px;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 3rem 2.75rem;
    border-radius: 12px;
}

.legal-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border);
}

.legal-header .logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    margin-bottom: 1rem;
}

.legal-header h1 {
    font-size: 1.9rem;
    letter-spacing: -0.03em;
    margin-bottom: 0.4rem;
}

.last-updated {
    font-size: 0.85rem;
    color: var(--muted);
}

h2 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--text);
    margin-top: 2.75rem;
    margin-bottom: 0.8rem;
    text-wrap: balance;
}

h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-top: 1.8rem;
    margin-bottom: 0.6rem;
}

p {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--muted);
    margin-bottom: 1rem;
    text-wrap: pretty;
}

ul, ol {
    margin-left: 1.4rem;
    margin-bottom: 1rem;
}

li {
    font-size: 1rem;
    line-height: 1.7;
    color: var(--muted);
    margin-bottom: 0.5rem;
    padding-left: 0.25rem;
}

li::marker {
    color: var(--accent);
}

strong {
    color: var(--text);
    font-weight: 600;
}

/* Back link */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 1.75rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease, gap 0.15s ease;
}

.back-link:hover {
    color: var(--text);
    gap: 9px;
    text-decoration: none;
}

/* Contact box — recessed panel inside the card */

.contact-box {
    background: var(--bg);
    border: 1px solid var(--border);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius);
    margin: 2rem 0;
}

.contact-box p:last-child {
    margin-bottom: 0;
}

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

@media (max-width: 768px) {
    .legal-container {
        padding: 2.25rem 1.5rem;
    }

    .legal-header h1 {
        font-size: 1.6rem;
    }

    h2 {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 1.25rem;
    }

    .logo {
        width: 80px;
        height: 80px;
    }

    .legal-body {
        padding: 32px 14px 56px;
    }

    .legal-container {
        padding: 1.75rem 1.25rem;
    }

    ul, ol {
        margin-left: 1.2rem;
    }

    .btn-download {
        padding: 13px 22px;
    }

    .theme-toggle {
        top: 1rem;
        right: 1rem;
    }
}

/* ---- Motion preferences ---- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

    .btn-download:active { transform: none; }
    .back-link:hover { gap: 6px; }
}
