/* Bitácora Pirata — estilos globales */

/* Tipografías alojadas en la propia web (licencia SIL OFL 1.1, ver assets/fonts/OFL-*.txt).
   Subconjunto latin: incluye todos los caracteres del español. */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/assets/fonts/inter-latin.woff2") format("woff2");
}
@font-face {
  font-family: "Pirata One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/pirata-one-latin.woff2") format("woff2");
}

:root {
  --bg: #f7f1e3;
  --surface: #fffaf0;
  --surface-2: #efe5cf;
  --text: #1d2433;
  --muted: #5b6475;
  --primary: #0e3b5c;
  --primary-2: #145a8a;
  --accent: #c8402f;
  --gold: #c99a2e;
  --border: #dccfb2;
  --shadow: 0 2px 10px rgba(29, 36, 51, .08);
  --radius: 14px;
  --maxw: 1080px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1520;
    --surface: #142131;
    --surface-2: #1b2b40;
    --text: #e9edf3;
    --muted: #a4afc0;
    --primary: #7cc0f0;
    --primary-2: #a6d5f7;
    --accent: #ff7a66;
    --gold: #e9bf5a;
    --border: #26384f;
    --shadow: 0 2px 12px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
/* Que el atributo hidden gane siempre a display:grid/flex de las clases */
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.65 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
img, svg { max-width: 100%; }
a { color: var(--primary-2); }
a:hover { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; color: var(--text); }
h1, .brand-name { font-family: "Pirata One", Georgia, serif; font-weight: 400; letter-spacing: .5px; }
h1 { font-size: clamp(2.2rem, 6vw, 3.4rem); margin: .2em 0 .3em; }
h2 { font-size: 1.6rem; margin-top: 2em; }
h3 { font-size: 1.15rem; }

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px; z-index: 99; }

/* Header */
.site-header {
  background: var(--primary);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
  box-shadow: var(--shadow);
}
@media (prefers-color-scheme: dark) { .site-header { background: #0a1a2a; } }
.header-inner { display: flex; align-items: center; gap: 16px; padding: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand svg { width: 34px; height: 34px; }
.brand-name { font-size: 1.7rem; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: #e8f1fa; text-decoration: none; padding: 6px 12px; border-radius: 999px; font-size: .95rem;
}
.nav a:hover, .nav a[aria-current="page"] { background: rgba(255,255,255,.14); color: #fff; }

/* Barra de progreso (modo sin spoilers) */
.progress-bar {
  background: var(--gold); color: #1d2433;
  font-size: .92rem;
}
.progress-inner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; flex-wrap: wrap; }
.progress-inner label { font-weight: 600; }
.progress-inner select {
  font: inherit; padding: 4px 8px; border-radius: 8px; border: 1px solid rgba(0,0,0,.25);
  background: #fffaf0; color: #1d2433; max-width: 100%;
}
.progress-hint { opacity: .85; }
.progress-bar.unset { background: #f4c55f; box-shadow: inset 0 -3px 0 #c8402f; }
.progress-bar.unset .progress-hint { opacity: 1; font-weight: 600; }
.progress-bar.unset select { outline: 3px solid #c8402f; outline-offset: 1px; }
.spoiler.hidden:focus-visible, .spoiler-inline.hidden:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Layout */
main { padding: 24px 0 48px; }
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff; border-radius: var(--radius); padding: 40px 28px; margin-top: 8px;
  position: relative; overflow: hidden;
}
@media (prefers-color-scheme: dark) { .hero { background: linear-gradient(135deg, #12304b, #1d4a73); } }
.hero h1 { color: #fff; }
.hero p { font-size: 1.15rem; max-width: 640px; color: #e8f1fa; }
.hero .waves { position: absolute; right: -40px; bottom: -30px; width: 320px; opacity: .18; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 720px; }

.btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: 10px 18px; border-radius: 999px; font-weight: 600; border: 0; cursor: pointer; font: inherit; font-weight: 600;
}
.btn:hover { color: #fff; filter: brightness(1.08); }
.btn.secondary { background: transparent; border: 2px solid currentColor; color: inherit; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card a.stretched { text-decoration: none; color: inherit; display: block; }
.card .tag {
  display: inline-block; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--accent); margin-bottom: 6px;
}
.feature-icon { font-size: 1.8rem; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; }
.calc-fields label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
.calc-fields label.check { flex-direction: row; align-items: center; gap: 8px; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.saga-row td { background: var(--surface-2); font-weight: 700; color: var(--primary-2); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.pill.canon { background: #d8eedd; color: #1e6b34; }
.pill.filler { background: #f6dcd6; color: #9b2c1d; }
.pill.mixed { background: #f4e7c4; color: #7a5a0e; }
@media (prefers-color-scheme: dark) {
  .pill.canon { background: #1f3d2a; color: #8fdca6; }
  .pill.filler { background: #4a2420; color: #ffb3a7; }
  .pill.mixed { background: #43381c; color: #f0d27c; }
}

.callout {
  border-left: 4px solid var(--gold); background: var(--surface); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0;
  margin: 20px 0;
}
.toc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; }
.toc ol { margin: 6px 0 0; padding-left: 20px; }

/* Spoilers */
.spoiler { position: relative; }
.spoiler.hidden .spoiler-content { filter: blur(7px); user-select: none; pointer-events: none; }
.spoiler.hidden { cursor: pointer; }
.spoiler-veil {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center;
  font-size: .9rem; font-weight: 700; color: var(--accent); padding: 8px;
}
.spoiler.hidden .spoiler-veil { display: flex; }
.spoiler-inline { background: var(--surface-2); border-radius: 4px; padding: 0 4px; }
.spoiler-inline.hidden { color: transparent; background: var(--muted); cursor: pointer; user-select: none; }

/* Personajes */
.group-head { margin-top: 2em; }
.character-head { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.character-emoji {
  font-size: 2.6rem; width: 76px; height: 76px; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 3px solid var(--gold); border-radius: 50%;
}
.character th[scope="row"] { width: 38%; }
.story { display: grid; gap: 12px; }
.story-item { padding: 16px 18px; }

/* Comparador de recompensas */
:root { --bar: #145a8a; }
@media (prefers-color-scheme: dark) { :root { --bar: #3d95d6; } }
.bounty-chart {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; display: grid; gap: 2px;
}
.bar-row {
  display: grid; grid-template-columns: minmax(110px, 220px) 1fr 118px; align-items: center; gap: 12px;
  padding: 6px 4px; border-radius: 8px; cursor: default;
}
.bar-row:hover, .bar-row:focus-visible { background: var(--surface-2); outline: none; }
.bar-label { color: var(--text); text-decoration: none; font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label:hover { color: var(--accent); }
.bar-track { min-width: 0; border-left: 1px solid var(--border); }
.bar { height: 14px; min-width: 2px; background: var(--bar); border-radius: 0 4px 4px 0; transition: width .4s; }
.bar-value { font-size: .85rem; color: var(--muted); white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.chart-tip {
  position: absolute; z-index: 5; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: var(--shadow); border-radius: 10px; padding: 10px 14px; font-size: .85rem; max-width: 320px; pointer-events: none;
}
.chart-tip ul { list-style: none; margin: 6px 0 0; padding: 0; }
.chart-tip li { display: flex; gap: 10px; justify-content: space-between; flex-wrap: wrap; }
.chart-tip li span { color: var(--muted); }
.chart-tip li b { font-variant-numeric: tabular-nums; }
.chart-tip li em { width: 100%; color: var(--muted); font-size: .78rem; }
@media (max-width: 640px) {
  .bar-row { grid-template-columns: 1fr auto; gap: 2px 10px; }
  .bar-label { grid-column: 1 / -1; }
}

/* Generador de carteles */
.poster-tool { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 16px; }
.poster-form { display: grid; gap: 14px; }
.poster-form label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; }
.poster-form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; display: inline-flex; margin-right: 14px; }
.poster-form input[type="text"], .poster-form input[type="number"], .poster-form select {
  font: inherit; font-weight: 400; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); width: 100%; min-width: 0;
}
.poster-form input[type="file"] { font: inherit; font-size: .9rem; max-width: 100%; }
.poster-form fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0; }
.poster-form legend { font-weight: 600; font-size: .92rem; padding: 0 4px; }
.poster-form .row { display: flex; gap: 8px; }
.btn.small { padding: 6px 12px; font-size: .88rem; white-space: nowrap; }
.small-note { font-size: .82rem; margin: 6px 0 0; }
.emoji-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; margin-top: 10px; }
.emoji-btn {
  font-size: 1.5rem; line-height: 1; padding: 8px 0; border-radius: 10px; border: 2px solid var(--border);
  background: var(--bg); cursor: pointer;
}
.emoji-btn[aria-checked="true"] { border-color: var(--accent); background: var(--surface-2); }
.emoji-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.poster-preview { position: sticky; top: 130px; }
.poster-preview canvas { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: var(--shadow); }
@media (max-width: 760px) {
  .poster-tool { grid-template-columns: 1fr; }
  .poster-preview { position: static; order: -1; }
}

/* Frutas */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.filters input, .filters select {
  font: inherit; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); flex: 1 1 180px; min-width: 0;
}
.fruit-card .type { font-size: .8rem; font-weight: 700; text-transform: uppercase; }
.type-Paramecia { color: #8a4fc7; }
.type-Zoan { color: #2f8a4a; }
.type-Logia { color: #c8402f; }
@media (prefers-color-scheme: dark) { .type-Paramecia { color: #c49bf2; } .type-Zoan { color: #7fd69a; } }
.fruit-card .meta { font-size: .85rem; color: var(--muted); }
.count { color: var(--muted); font-size: .95rem; }

/* Test */
.quiz { max-width: 680px; margin: 0 auto; }
.quiz-progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 18px; }
.quiz-progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.options { display: grid; gap: 10px; }
.option {
  text-align: left; font: inherit; padding: 14px 16px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.option:hover, .option:focus-visible { border-color: var(--accent); outline: none; }
.result-emoji { font-size: 4rem; line-height: 1; }

/* Ad slot */
.ad-slot {
  margin: 28px 0; min-height: 100px; border: 1px dashed var(--border); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem;
}

/* Footer */
.site-footer { background: var(--surface-2); border-top: 1px solid var(--border); padding: 28px 0; font-size: .92rem; color: var(--muted); }
.footer-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 4px 0; }
.disclaimer { margin-top: 20px; font-size: .82rem; }

.prose { max-width: 760px; }
.prose ul, .prose ol { padding-left: 22px; }
.muted { color: var(--muted); }

@media (max-width: 640px) {
  body { font-size: 16px; }
  .site-header { position: static; }
  .nav { margin-left: 0; width: 100%; }
  .nav a { padding: 4px 10px; }
  .progress-hint { display: none; }
  .progress-bar.unset .progress-hint { display: block; width: 100%; font-size: .85rem; }
  .hero { padding: 28px 18px; }
  th, td { padding: 8px; }
}
