/* base.css: variables, tipografía y layout comunes a todo el sitio.
   Cada app solo redefine --color-primary y --color-on-primary en su app-<nombre>.css. */

/* ---------- Fuentes (Roboto, SIL OFL 1.1, ver assets/fonts/OFL.txt) ---------- */

@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Roboto";
  src: url("../fonts/roboto-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ---------- Variables ---------- */

:root {
  color-scheme: light dark;

  /* Colores de marca de cada app (los mismos que en las apps). */
  --color-stairo: #8a5a2b;
  --color-terrao: #4e6b2f;
  --color-rakkora: #e07b00;
  --color-vanvolto: #1e6a8d;

  /* Color neutro de la portada; cada app lo sustituye. */
  --color-primary: #3a4a5c;
  --color-on-primary: #ffffff;

  --color-bg: #fbfaf8;
  --color-surface: #ffffff;
  --color-text: #1c1b1a;
  --color-text-muted: #55524e;
  --color-border: #d9d5cf;
  --color-focus: #1a73e8;

  /* Semáforo (clasificador de daños, comprobaciones). */
  --color-ok: #1e7d32;
  --color-warn: #a35a00;
  --color-bad: #b3261e;

  /* Espaciado en múltiplos de 4 px. */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;

  /* Tipografía fluida: mínimo en móvil, máximo en escritorio. */
  --font-family: "Roboto", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-size-small: 0.875rem;
  --font-size-body: clamp(1rem, 0.96rem + 0.2vw, 1.125rem);
  --font-size-h2: clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);
  --font-size-h1: clamp(1.75rem, 1.5rem + 1.25vw, 2.5rem);
  --font-size-result: clamp(2.5rem, 2rem + 2.5vw, 4rem);

  /* Objetivo táctil mínimo recomendado (WCAG 2.5.5 y Material Design). */
  --touch-target: 48px;

  --radius: 0.5rem;
  --content-width: 42rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #151413;
    --color-surface: #1f1e1c;
    --color-text: #ecebe8;
    --color-text-muted: #b3afa9;
    --color-border: #3b3936;
    --color-focus: #8ab4f8;

    --color-ok: #81c995;
    --color-warn: #f6ae55;
    --color-bad: #f28b82;
  }
}

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

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-family);
  font-size: var(--font-size-body);
  line-height: 1.5;
}

h1,
h2,
h3 {
  line-height: 1.2;
  font-weight: 700;
  margin: 0 0 var(--space-4);
}

h1 {
  font-size: var(--font-size-h1);
}

h2 {
  font-size: var(--font-size-h2);
  margin-top: var(--space-8);
}

p,
ul,
ol {
  margin: 0 0 var(--space-4);
}

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

a {
  color: inherit;
  text-underline-offset: 0.15em;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Oculto hasta que recibe el foco con el teclado. */
.skip-link {
  position: absolute;
  left: var(--space-4);
  top: calc(-1 * var(--space-12));
  z-index: 1;
  padding: var(--space-2) var(--space-4);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius);
}

.skip-link:focus {
  top: var(--space-2);
}

/* ---------- Layout ---------- */

.wrapper {
  width: 100%;
  max-width: var(--content-width);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

main {
  flex: 1;
  padding-block: var(--space-8);
}

.site-header {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

.site-header .wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-header a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  text-decoration: none;
}

.site-name {
  font-weight: 700;
}

.lang-switch {
  display: flex;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.lang-switch a {
  min-width: var(--touch-target);
  justify-content: center;
  border-radius: var(--radius);
}

.lang-switch a[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
}

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
  padding-block: var(--space-6);
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
}

/* ---------- Tarjetas (lista de apps) ---------- */

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: block;
  height: 100%;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: var(--space-1) solid var(--card-color, var(--color-primary));
  border-radius: var(--radius);
  text-decoration: none;
}

.card--stairo { --card-color: var(--color-stairo); }
.card--terrao { --card-color: var(--color-terrao); }
.card--rakkora { --card-color: var(--color-rakkora); }
.card--vanvolto { --card-color: var(--color-vanvolto); }

.card:hover {
  border-color: var(--card-color, var(--color-primary));
}

.card h2 {
  margin: 0 0 var(--space-2);
}

.card p {
  margin: 0;
  color: var(--color-text-muted);
}

/* ---------- Formularios y resultado (calculadoras) ---------- */

form {
  display: grid;
  gap: var(--space-4);
}

label {
  display: grid;
  gap: var(--space-1);
  font-weight: 500;
}

input,
select,
button {
  font: inherit;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-6);
  border: 0;
  border-radius: var(--radius);
  background: var(--color-primary);
  color: var(--color-on-primary);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}

.result {
  display: block;
  font-size: var(--font-size-result);
  font-weight: 700;
  line-height: 1.1;
}

.result-label {
  color: var(--color-text-muted);
}

/* ---------- Movimiento reducido ---------- */

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

/* ---------- Páginas legales ---------- */

.updated {
  color: var(--color-text-muted);
  font-size: var(--font-size-small);
}

/* ---------- Página de app ---------- */

.tagline {
  margin-top: calc(-1 * var(--space-2));
  color: var(--color-text-muted);
  font-size: var(--font-size-h2);
}

.store-status {
  font-weight: 500;
}

.app-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-6);
  padding: 0;
  list-style: none;
}

.app-links a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
}
