/*
 * Estilos base de crowdfunding. Los colores, la tipografía y el logo se
 * personalizan desde el backend: una hoja de estilos de tema redefine las
 * variables de :root (fase 4). Sin fuentes externas (privacidad/RGPD).
 */

:root {
    --color-primary: #0f6e66;
    --color-primary-contrast: #ffffff;
    --color-accent: #e8a33d;
    --color-text: #1c2321;
    --color-muted: #59635f;
    --color-bg: #ffffff;
    --color-surface: #f4f6f5;
    --color-border: #d6dcda;
    --color-success: #1d7a46;
    --color-error: #b3261e;
    --color-info: #1f5fa8;

    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-heading: var(--font-body);

    --radius: 12px;
    --radius-sm: 6px;
    --space-1: .25rem;
    --space-2: .5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.5rem;
    --space-6: 4rem;
    --container: 70rem;
    --container-narrow: 42rem;
    --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .06);
}

/* ---------- Reset mínimo ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
main { flex: 1; }
main:focus { outline: none; }
img, svg { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4 { font-family: var(--font-heading); line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: clamp(2rem, 1.4rem + 2.5vw, 3.25rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.25rem); letter-spacing: -.01em; }
h3 { font-size: 1.25rem; }
p, ul, ol { margin: 0 0 var(--space-3); }
a { color: var(--color-primary); text-underline-offset: .2em; }
a:hover { text-decoration-thickness: 2px; }

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

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Utilidades de accesibilidad ---------- */
.skip-link {
    position: absolute;
    left: var(--space-3);
    top: -100px;
    z-index: 100;
    padding: var(--space-2) var(--space-3);
    background: var(--color-text);
    color: #fff;
    border-radius: var(--radius-sm);
}
.skip-link:focus { top: var(--space-3); }

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

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: var(--space-3);
}
.container--narrow { max-width: var(--container-narrow); }

.page { padding-block: var(--space-5); }

/* ---------- Cabecera y pie ---------- */
.site-header {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}
.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 4rem;
}
.site-header__brand {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--color-text);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}
.site-header__brand img { max-height: 2.5rem; width: auto; }

.site-footer {
    margin-top: var(--space-6);
    padding-block: var(--space-4);
    background: var(--color-surface);
    color: var(--color-muted);
    font-size: .9375rem;
}
.site-footer a { color: inherit; }
.site-footer__links {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
}
.site-footer__copy { margin: 0; }

/* ---------- Portada ---------- */
.hero {
    padding-block: var(--space-6);
    background: linear-gradient(180deg, var(--color-surface), var(--color-bg));
}
.hero__inner { max-width: 48rem; }
.hero__title { margin-bottom: var(--space-3); }
.hero__lead { font-size: 1.25rem; color: var(--color-muted); }

/* ---------- Botones ---------- */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-4);
    border: 2px solid var(--color-primary);
    border-radius: 999px;
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: translateY(1px); }
.button--secondary { background: transparent; color: var(--color-primary); }
.button--large { min-height: 3.25rem; padding-inline: var(--space-5); font-size: 1.125rem; }
.button--block { width: 100%; }
.button[disabled] { opacity: .6; cursor: not-allowed; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-4);
    box-shadow: var(--shadow);
}

/* ---------- Alertas ---------- */
.alert {
    margin-block: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-sm);
    border-left: 4px solid currentColor;
    background: var(--color-surface);
}
.alert--success { color: var(--color-success); }
.alert--error { color: var(--color-error); }
.alert--info { color: var(--color-info); }

/* ---------- Formularios ---------- */
.field { margin-bottom: var(--space-4); }
.field label { display: block; font-weight: 600; margin-bottom: var(--space-1); }
.field__required { color: var(--color-error); }
.field__help { margin: 0 0 var(--space-1); color: var(--color-muted); font-size: .9375rem; }
.field__errors {
    list-style: none;
    padding: 0;
    margin: var(--space-1) 0 0;
    color: var(--color-error);
    font-size: .9375rem;
    font-weight: 600;
}

input[type="text"], input[type="email"], input[type="number"], input[type="password"],
input[type="url"], input[type="date"], input[type="datetime-local"], input[type="search"],
select, textarea {
    width: 100%;
    min-height: 2.75rem;
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--color-text);
    font: inherit;
}
textarea { min-height: 8rem; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--color-primary); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--color-error); }

.field--checkbox { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--space-2); align-items: start; }
.field--checkbox input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; accent-color: var(--color-primary); }
.field--checkbox label { font-weight: 400; margin: 0; }
.field--checkbox .field__help, .field--checkbox .field__errors { grid-column: 2; }

/* ---------- Barra de progreso ---------- */
.progress {
    height: .75rem;
    border-radius: 999px;
    background: var(--color-surface);
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: inherit;
}

/* ---------- Navegación de la home ---------- */
.site-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
}
.site-nav a { color: var(--color-text); text-decoration: none; font-weight: 500; }
.site-nav a:hover { color: var(--color-primary); text-decoration: underline; }

/* ---------- Campaña ---------- */
.hero__stats {
    margin-top: var(--space-5);
    max-width: 36rem;
}
.hero__raised { font-size: 1.125rem; margin-bottom: var(--space-2); }
.hero__raised strong { font-size: 2rem; color: var(--color-primary); }
.hero__meta { margin-top: var(--space-2); color: var(--color-muted); font-size: .9375rem; }
.hero--maintenance { min-height: 50vh; display: flex; align-items: center; }

/* Ancho de la barra en pasos del 5 %: la CSP no admite estilos en línea. */
.progress__bar--0 { width: 0%; }
.progress__bar--5 { width: 5%; }
.progress__bar--10 { width: 10%; }
.progress__bar--15 { width: 15%; }
.progress__bar--20 { width: 20%; }
.progress__bar--25 { width: 25%; }
.progress__bar--30 { width: 30%; }
.progress__bar--35 { width: 35%; }
.progress__bar--40 { width: 40%; }
.progress__bar--45 { width: 45%; }
.progress__bar--50 { width: 50%; }
.progress__bar--55 { width: 55%; }
.progress__bar--60 { width: 60%; }
.progress__bar--65 { width: 65%; }
.progress__bar--70 { width: 70%; }
.progress__bar--75 { width: 75%; }
.progress__bar--80 { width: 80%; }
.progress__bar--85 { width: 85%; }
.progress__bar--90 { width: 90%; }
.progress__bar--95 { width: 95%; }
.progress__bar--100 { width: 100%; }

/* ---------- Secciones de contenido ---------- */
.section { padding-block: var(--space-5); }
.section--highlight { background: var(--color-surface); }
.section--highlight h2 { color: var(--color-primary); }

.prose > :last-child { margin-bottom: 0; }
.prose h3 { margin-top: var(--space-4); }
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li + li { margin-top: var(--space-1); }
.prose blockquote {
    margin: var(--space-4) 0;
    padding-left: var(--space-3);
    border-left: 4px solid var(--color-accent);
    color: var(--color-muted);
}

.page__updated { margin-top: var(--space-5); color: var(--color-muted); font-size: .9375rem; }

/* ---------- Botones adicionales ---------- */
.button--danger { background: var(--color-error); border-color: var(--color-error); color: #fff; }

/* ---------- Imagen de campaña ---------- */
.hero__image {
    width: 100%;
    height: auto;
    aspect-ratio: 1200 / 630;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: var(--space-4);
    box-shadow: var(--shadow);
}

/* ---------- Donación ---------- */
.hero__cta { margin-top: var(--space-4); }
.section--cta { text-align: center; }

.donation-form { margin-top: var(--space-4); }
.donation-form .form-section {
    margin: 0 0 var(--space-4);
    padding: 0;
    border: 0;
}
.donation-form .form-section legend {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: var(--space-3);
    padding: 0;
}
.amount-picker__options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(7rem, 1fr));
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}
.amount-option { position: relative; }
.amount-option input {
    position: absolute;
    opacity: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.amount-option label {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    padding: var(--space-2);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-weight: 700;
    text-align: center;
}
.amount-option input:checked + label {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}
.amount-option input:focus-visible + label { outline: 3px solid var(--color-accent); outline-offset: 2px; }

.privacy-info {
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    color: var(--color-muted);
}
.privacy-info p { margin: 0; }
.donation-form__secure { text-align: center; margin-top: var(--space-2); }

/* ---------- Resultado ---------- */
.result { text-align: center; }
.result--paid { border-top: 6px solid var(--color-success); }
.result--failed, .result--cancelled { border-top: 6px solid var(--color-error); }
.result--pending { border-top: 6px solid var(--color-accent); }
.result__reference { font-size: 1.25rem; }
.result form { margin: var(--space-3) 0; }
.result__waiting { font-weight: 600; color: var(--color-primary); }
.result__back { margin-top: var(--space-4); }
