/* TuBalda · identidad visual: papel, tinta y ocre. Contrastes verificados (ver manual de marca). */
:root {
  --bg: #faf8f5;              /* Marfil */
  --surface: #ede7e1;         /* Crema */
  --text: #2c2623;            /* Tinta */
  --text-muted: #70635b;      /* Marrón */
  --border: #e0d8d0;
  --accent: #c27d38;          /* Ocre: símbolo, botones, iconos (no para texto en claro) */
  --accent-text: #8a5a22;     /* Ocre texto, 5,6:1 sobre marfil */
  --on-accent: #181615;       /* Carbón sobre ocre, 5,4:1 (el blanco solo da 3,3:1) */
  --favorite: #d9534f;        /* Coral: solo gráficos */
  --danger-text: #a93733;     /* Coral para texto y errores, 6:1 */
  --radius: 6px;
  --serif-title: 'Playfair Display', Georgia, 'Times New Roman', serif;
  --serif-body: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --label: 'Cinzel', 'Playfair Display', Georgia, serif;
  --shadow: 0 8px 24px rgba(44, 38, 35, 0.12);
  /* Portadas sin imagen: color por tipo de obra */
  --ph-movie-bg: #e8d2b5; --ph-movie-fg: #5b3a12;
  --ph-series-bg: #d9d2ca; --ph-series-fg: #2c2623;
  --ph-book-bg: #c9bdb1; --ph-book-fg: #2c2623;
  --ph-song-bg: #ebc4c1; --ph-song-fg: #6b2220;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181615;            /* Carbón */
    --surface: #262220;       /* Piedra */
    --text: #e8e3df;          /* Hueso */
    --text-muted: #b5aaa2;
    --border: #3a332f;
    --accent-text: #d69a5c;   /* Ocre claro, 7,4:1 sobre carbón */
    --danger-text: #e8736f;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --ph-movie-bg: #4a3520; --ph-movie-fg: #e9c9a0;
    --ph-series-bg: #35302d; --ph-series-fg: #e8e3df;
    --ph-book-bg: #3e3631; --ph-book-fg: #e8e3df;
    --ph-song-bg: #4f2b29; --ph-song-fg: #f0cfcc;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--serif-body); }
body { min-height: 100vh; line-height: 1.55; display: flex; flex-direction: column; }
h1, h2, h3 { font-family: var(--serif-title); font-weight: 600; margin: 0 0 .5rem; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); }
h2 { font-size: 1.35rem; margin-top: 2rem; }
h3 { font-size: 1.02rem; }
p { margin: .4rem 0; text-wrap: pretty; }
a { color: var(--accent-text); }
.muted { color: var(--text-muted); font-family: var(--sans); font-size: .875rem; }
.error { color: var(--danger-text); font-family: var(--sans); font-size: .9rem; }
.small { font-family: var(--sans); font-size: .85rem; }
.kicker { font-family: var(--label); font-weight: 600; font-size: .75rem; letter-spacing: .22em; text-transform: uppercase; color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--text); color: var(--bg); padding: .6rem 1rem; z-index: 20; font-family: var(--sans); }
.skip:focus { left: 0; }
main:focus { outline: none; }

/* Marca: símbolo + nombre */
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--text); margin-right: auto; }
.brand img { width: 34px; height: 34px; display: block; }
.wordmark { font-family: var(--serif-title); font-weight: 600; letter-spacing: -0.01em; line-height: 1; white-space: nowrap; color: var(--text); }
.wordmark .tu { font-style: italic; font-weight: 500; color: var(--accent-text); }
.brand .wordmark { font-size: 1.45rem; }

/* Cabecera y pie */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.topbar:empty { display: none; }
.topbar nav { display: flex; gap: 1.1rem; flex-wrap: wrap; font-family: var(--sans); font-size: .92rem; }
.topbar nav a { color: var(--text-muted); text-decoration: none; padding: .3rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--text); }
.topbar nav a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.site-footer { margin-top: auto; padding: 1.5rem 1.25rem 2rem; border-top: 1px solid var(--border); text-align: center; }
.site-footer p { margin: .2rem auto; max-width: 62ch; font-family: var(--sans); font-size: .78rem; color: var(--text-muted); }

.container { width: 100%; max-width: 980px; margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; flex: 1 0 auto; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 1.5rem; max-width: 460px; margin: 2.5rem auto; }
.center { text-align: center; }

/* Portada de bienvenida */
.hero { max-width: 560px; margin: 3rem auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: .9rem; }
.hero img { width: 112px; height: 112px; }
.hero .wordmark { font-size: 3.2rem; }
.hero .tagline { font-family: var(--serif-title); font-style: italic; font-size: 1.35rem; margin: 0; }
.hero p { max-width: 44ch; }

/* Formularios y botones */
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; font-family: var(--sans); font-size: .9rem; }
input, select, textarea {
  font: inherit; font-family: var(--sans); font-size: .95rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .5rem .6rem;
}
textarea { min-height: 80px; resize: vertical; font-family: var(--serif-body); }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.btn {
  font-family: var(--sans); font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 1.1rem; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--on-accent);
}
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; color: var(--accent-text); border-color: var(--accent-text); font-weight: 500; }
.btn.danger { background: transparent; color: var(--danger-text); border-color: var(--danger-text); font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; filter: none; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .card:focus-visible, .chip:focus-visible, a:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-text); outline-offset: 2px;
}

/* Filtros */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  font-family: var(--sans); font-size: .85rem; padding: .35rem .9rem; border-radius: 999px; min-height: 36px;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--surface); color: var(--text); border-color: var(--accent); }

/* Diario: tarjetas */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.2rem 1.1rem; }
.card { text-align: left; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; font: inherit; border-radius: var(--radius); }
.cover { position: relative; width: 100%; aspect-ratio: 2 / 3; border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: .5rem; }
.cover.square { aspect-ratio: 1 / 1; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif-title); font-weight: 600; font-size: 1.9rem; letter-spacing: .04em;
  background: var(--surface); color: var(--text-muted);
}
.ph-movie { background: var(--ph-movie-bg); color: var(--ph-movie-fg); }
.ph-series { background: var(--ph-series-bg); color: var(--ph-series-fg); }
.ph-book { background: var(--ph-book-bg); color: var(--ph-book-fg); }
.ph-song { background: var(--ph-song-bg); color: var(--ph-song-fg); }
.card h3 { font-size: .95rem; margin-bottom: .15rem; }
.card .meta { font-family: var(--sans); font-size: .8rem; color: var(--text-muted); margin: .15rem 0 0; }
.fav { color: var(--danger-text); }
.stars { color: var(--accent-text); }

/* Perfil */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; font-family: var(--sans); font-size: .9rem; }
.stat { background: var(--surface); border-radius: var(--radius); padding: .85rem; }
.top-block { margin-bottom: 1.5rem; }
.top-slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
.top-slots select { width: 100%; font-size: .85rem; }

/* Modal */
dialog.modal {
  width: min(560px, calc(100vw - 2rem)); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem;
  background: var(--bg); color: var(--text); box-shadow: var(--shadow);
}
dialog.modal::backdrop { background: rgba(20, 16, 14, .5); }
.results { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; max-height: 50vh; overflow: auto; }
.result {
  display: grid; grid-template-columns: 48px 1fr; gap: .75rem; align-items: center; width: 100%;
  text-align: left; padding: .5rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; font: inherit;
}
.result .thumb { width: 48px; height: 48px; border-radius: 4px; overflow: hidden; background: var(--border); }
.result .thumb img { width: 100%; height: 100%; object-fit: cover; }
.result strong { display: block; font-size: .95rem; }
.result span { font-family: var(--sans); font-size: .8rem; color: var(--text-muted); }
.kind-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .75rem; }
.checkbox { display: flex; align-items: center; gap: .4rem; font-family: var(--sans); font-size: .9rem; }
.modal-head { display: grid; grid-template-columns: 64px 1fr; gap: .75rem; align-items: center; margin-bottom: 1rem; }
.modal-head .cover { margin: 0; }
.modal-actions { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }

/* Listas */
.row.between { justify-content: space-between; }
.filters-row { margin: 1rem 0; }
.filters-row input[type="search"] { flex: 1 1 220px; }
.lists-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.list-card { display: block; color: inherit; text-decoration: none; border-radius: var(--radius); }
.list-card:hover h3 { color: var(--accent-text); }
.mosaic {
  display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; aspect-ratio: 1 / 1;
  border-radius: var(--radius); overflow: hidden; background: var(--border); margin-bottom: .5rem;
}
.mosaic .tile { background: var(--surface); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mosaic .tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.mosaic .tile.ph-movie { background: var(--ph-movie-bg); color: var(--ph-movie-fg); }
.mosaic .tile.ph-series { background: var(--ph-series-bg); color: var(--ph-series-fg); }
.mosaic .tile.ph-book { background: var(--ph-book-bg); color: var(--ph-book-fg); }
.mosaic .tile.ph-song { background: var(--ph-song-bg); color: var(--ph-song-fg); }
.tile-initials { font-family: var(--serif-title); font-weight: 600; }
.vote[aria-pressed="true"] { background: var(--surface); }
.list-items { list-style: none; padding: 0; margin: 1.25rem 0; display: grid; gap: 1rem; counter-reset: item; }
.list-item { display: grid; grid-template-columns: 84px 1fr; gap: 1rem; align-items: start; counter-increment: item; }
.list-item .cover { margin: 0; }
.list-item h3::before { content: counter(item) ". "; color: var(--text-muted); font-family: var(--sans); }
.list-item input { width: 100%; margin: .4rem 0; }
.annotation { font-style: italic; }
.btn.small { min-height: 36px; padding: 0 .7rem; font-size: .8rem; }
.report { margin-top: 2rem; font-family: var(--sans); font-size: .9rem; }
.report summary { cursor: pointer; color: var(--text-muted); }
.report .row { margin-top: .5rem; }
.report input { flex: 1 1 220px; }

@media (max-width: 560px) {
  .top-slots { grid-template-columns: 1fr 1fr; }
  .topbar nav { order: 3; width: 100%; }
  .hero .wordmark { font-size: 2.6rem; }
}

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