/* =========================================================================
 * CATAN — page de règles
 * Reprend la palette de style.css et l'étale sur un document long : fond mer,
 * feuilles de parchemin, et les visuels réellement utilisés par le jeu.
 * ========================================================================= */

html, body { overflow: auto; height: auto; }

body.rules {
  /* style.css coupe la sélection pour le plateau, où elle n'est qu'une gêne au
   * doigt. Ici c'est un document : on doit pouvoir en citer un passage. */
  user-select: text; -webkit-user-select: text;
  -webkit-touch-callout: default;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,190,80,.10), transparent 60%),
    linear-gradient(180deg, #123a52 0%, #0a2233 40%, #06141f 100%);
  background-attachment: fixed;
  padding: 0 0 60px;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; display: flex; gap: 34px; }

/* -------------------------------- En-tête ------------------------------- */

.rhead { text-align: center; padding: 46px 22px 30px; }
.rhead .mlogo { font-size: clamp(2.6rem, 10vw, 4.6rem); }
.rhead .sub { color: #b8cddb; font-style: italic; margin-top: 4px; }
/* Bouton « jouer » : présent en tête ET en pied de page, donc non scopé. */
a.back {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 18px; padding: 9px 22px; border-radius: 24px;
  color: #ffeacb; text-decoration: none; font-family: var(--display); font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #cf3a2c, var(--terracotta) 50%, var(--terracotta-d));
  border: 1px solid #5f1009; box-shadow: 0 3px 0 #5f1009;
}
a.back:active { transform: translateY(3px); box-shadow: 0 0 0 #5f1009; }

/* --------------------------------- Sommaire ------------------------------ */

nav.toc { width: 216px; flex: none; }
nav.toc ol {
  position: sticky; top: 22px;
  list-style: none; margin: 0; padding: 14px 0;
  border-left: 2px solid var(--sea-light);
}
nav.toc li { margin: 0; }
nav.toc a {
  display: block; padding: 6px 14px; font-size: .87em;
  color: #9fb9cb; text-decoration: none; border-left: 2px solid transparent;
  margin-left: -2px;
}
nav.toc a:hover { color: var(--gold-bright); border-left-color: var(--gold); }
nav.toc .num {
  font-family: var(--display); color: var(--sand-line);
  margin-right: 7px; font-size: .9em;
}

/* -------------------------------- Sections ------------------------------- */

main.rbody { flex: 1; min-width: 0; }

section.sheet {
  background: linear-gradient(160deg, rgba(255,255,255,.42), transparent 34%), var(--sand);
  color: var(--ink);
  border: 1px solid var(--sand-line);
  outline: 5px solid var(--sea-panel);
  box-shadow: 0 0 0 7px #0d2c42, 0 18px 44px rgba(0,0,0,.55);
  border-radius: 6px;
  padding: 26px 30px 30px;
  margin: 0 0 40px;
  scroll-margin-top: 16px;
}

section.sheet > h2 {
  font-family: var(--display); font-weight: 700;
  font-size: 1.7em; margin: 0 0 4px; color: var(--terracotta);
  display: flex; align-items: baseline; gap: 12px;
}
section.sheet > h2 .n {
  font-size: .72em; color: var(--sand-line);
  -webkit-text-stroke: .5px var(--ink-soft);
}
section.sheet > h2::after {
  content: ''; flex: 1; height: 2px; background: var(--sand-line); border-radius: 2px;
}
section.sheet h3 {
  font-family: var(--display); font-size: 1.12em; margin: 22px 0 8px; color: #6d3d10;
  display: flex; align-items: center; gap: 9px;
}
section.sheet p { margin: 9px 0; line-height: 1.6; }
section.sheet ul, section.sheet ol { line-height: 1.65; padding-left: 22px; }
section.sheet li { margin-bottom: 5px; }
.lede { font-size: 1.05em; color: #52401f; font-style: italic; margin-bottom: 16px !important; }

.note {
  background: rgba(179, 38, 30, .07);
  border-left: 4px solid var(--terracotta);
  border-radius: 0 6px 6px 0;
  padding: 10px 14px; margin: 16px 0; font-size: .93em;
}
.note b { color: var(--terracotta-d); }

/* --------------------------------- Grilles -------------------------------- */

/* Grille plutôt que flex : les 6 terrains se rangent en 3×2 bien réguliers
 * au lieu de laisser le désert seul sur sa ligne. */
.tiles {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 18px 14px; margin: 16px 0 6px;
}
.tile { text-align: center; }
.tile > img { width: 118px; max-width: 100%; display: block; margin: 0 auto 6px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.3)); }
.tile .tn { font-family: var(--display); font-weight: 700; font-size: 1.02em; }
.tile .tr {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  font-size: .84em; color: var(--ink-soft); margin-top: 2px;
}
.tile .tr img { width: 22px; border-radius: 2px; border: 1px solid var(--sand-line); }

.tokens { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin: 14px 0; }
.tokens img { width: 58px; filter: drop-shadow(0 3px 6px rgba(0,0,0,.28)); }

.pieces { display: flex; flex-wrap: wrap; gap: 22px; margin: 16px 0; align-items: flex-end; }
.piece { text-align: center; }
.piece img { display: block; margin: 0 auto 6px; filter: drop-shadow(0 4px 7px rgba(0,0,0,.3)); }
.piece .pn { font-family: var(--display); font-weight: 700; }
.piece .pd { font-size: .82em; color: var(--ink-soft); }

/* ------------------------------ Coûts de construction --------------------- */

table.costs { width: 100%; border-collapse: collapse; margin: 14px 0; }
table.costs th, table.costs td {
  padding: 11px 10px; text-align: left; vertical-align: middle;
  border-bottom: 1px solid var(--sand-line);
}
table.costs th {
  font-family: var(--display); font-size: .82em; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--ink-soft);
}
table.costs td:first-child { width: 78px; }
table.costs .what { font-family: var(--display); font-weight: 700; font-size: 1.05em; }
table.costs .what small { display: block; font-family: var(--serif); font-weight: 400;
  font-size: .78em; color: var(--ink-soft); letter-spacing: 0; text-transform: none; }
.cost { display: flex; flex-wrap: wrap; gap: 6px; }
.cost .rc { position: relative; }
.cost .rc img {
  width: 38px; border-radius: 3px; border: 1px solid var(--sand-line);
  box-shadow: 0 2px 5px rgba(0,0,0,.25); display: block;
}
.cost .rc b {
  position: absolute; right: -4px; bottom: -4px;
  min-width: 17px; height: 17px; line-height: 17px; text-align: center;
  font-size: .7em; border-radius: 50%;
  background: var(--sea-panel); color: var(--sand); border: 1px solid var(--sand);
}
table.costs .pc { text-align: center; }
table.costs .pc img { height: 40px; }
/* La carte développement n'a pas de pion à montrer : c'est un pictogramme, mis
 * à la même hauteur que les pièces des autres lignes. */
table.costs .pc .pcic { width: 34px; height: 34px; color: #6d3d10; }

/* ---------------------------------- Ports --------------------------------- */

.ports { display: flex; flex-wrap: wrap; gap: 14px; margin: 16px 0; }
/* Hublot : la barque du port, rognée par tools/build_ports.py à 164 px et
 * affichée à 82 — le double sert les écrans fins, et le rond est laissé au CSS
 * pour que le liseré reste net. */
.portbadge {
  width: 82px; height: 82px; border-radius: 50%; overflow: hidden;
  border: 3px solid #8a6f3c;
  box-shadow: 0 4px 10px rgba(0,0,0,.3);
}
.portbadge.spec { border-color: var(--terracotta); }
.portbadge img { display: block; width: 100%; height: 100%; }
.portwrap { text-align: center; }
.portwrap .rt {
  font-family: var(--display); font-weight: 700; font-size: .95em;
  color: #5b4526; margin-top: 6px; line-height: 1.1;
}
.portwrap .rt.spec { color: var(--terracotta); }
.portwrap .pl { font-size: .78em; color: var(--ink-soft); margin-top: 2px; }
/* Vignette de port : rendue à 350 px par tools/build_ports.py et affichée
 * en dessous, jamais au-dessus — l'agrandir la rendrait molle. */
.portshot { width: 300px; max-width: 100%; margin: 18px auto 6px; }
.portshot img {
  display: block; width: 100%; border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0,0,0,.25);
}
.portshot figcaption {
  font-size: .78em; color: var(--ink-soft); text-align: center; margin-top: 7px;
}

/* ------------------------------ Cartes dév. ------------------------------- */

.devs { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0; }
.dev {
  width: 150px;
  background: rgba(255,255,255,.5);
  border: 1px solid var(--sand-line); border-radius: 8px;
  padding: 10px; text-align: center;
}
/* Le rapport est celui des rendus de tools/build_dev.py — les 5 cartes sortent
   toutes en 260×387, rien n'est donc rogné. */
.dev .art {
  width: 100%; aspect-ratio: 260/387; object-fit: cover;
  border-radius: 5px; box-shadow: 0 3px 8px rgba(0,0,0,.25);
  display: block; margin-bottom: 8px;
}
.dev .dn { font-family: var(--display); font-weight: 700; }
.dev .dq { font-size: .78em; color: var(--terracotta); font-weight: 700; }
.dev .dd { font-size: .8em; color: var(--ink-soft); line-height: 1.4; margin-top: 4px; }

/* ------------------------------- Séquence -------------------------------- */

.steps { counter-reset: st; list-style: none; padding: 0; margin: 16px 0; }
.steps > li {
  counter-increment: st;
  position: relative; padding: 12px 0 12px 56px;
  border-bottom: 1px solid rgba(201,180,137,.5);
}
.steps > li:last-child { border-bottom: 0; }
.steps > li::before {
  content: counter(st);
  position: absolute; left: 0; top: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--sea-panel); color: var(--gold-bright);
  font-family: var(--display); font-weight: 700; font-size: 1.15em;
  display: flex; align-items: center; justify-content: center;
}
.steps b { font-family: var(--display); }

.inline { height: 1.25em; vertical-align: -.28em; }
.inline.big { height: 1.7em; vertical-align: -.5em; }

/* --------------------------------- Pied ---------------------------------- */

footer.rfoot {
  max-width: 1180px; margin: 0 auto; padding: 10px 22px;
  color: #7f9db1; font-size: .84em; text-align: center; line-height: 1.7;
}
footer.rfoot a { color: var(--sand-line); }

@media (max-width: 900px) {
  .wrap { flex-direction: column; gap: 0; padding: 0 12px; }
  nav.toc { width: 100%; }
  nav.toc ol {
    position: static; display: flex; flex-wrap: wrap; gap: 4px;
    border-left: 0; border-top: 1px solid var(--sea-light);
    border-bottom: 1px solid var(--sea-light); padding: 10px 0; margin-bottom: 24px;
  }
  nav.toc a { padding: 5px 10px; border: 1px solid var(--sea-light); border-radius: 16px; }
  section.sheet { padding: 20px 18px 24px; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile > img { width: 92px; }
}
