/*
  Layout and colours of the website (index.html, aviso-legal.html).
  Type and the brand classes come from identidad.css. This file sets the
  three colour themes, the bands and the page grid. Mobile first.
*/

/* ---------- Themes (ADR 0013, informe §3.2) ----------

  Three sets of colours, chosen with the «Colores» radios in the header:
  «Claro» (default), «Azul marino» and «Verde noche». No JavaScript: the
  radios switch the variables through :root:has(). The choice is not kept
  between pages, and prefers-color-scheme is not followed on purpose (an
  automatic dark theme would flip back to Claro on the next page).

  The identity names are reused, so every class of identidad.css follows
  the theme: --papel background, --tinta text, --gris muted text, --verde
  accent (links, characters, button), --blanco text on the accent,
  --linea rules. New here: --superficie (alternate sections, a step away
  from the page: darker in Claro, lighter in the dark themes), --foco
  (focus ring), --borde-foto, and the band set (--banda…) for the header
  and the footer. Contrast of every pair: the table in
  projects/kungfu/docs/decisiones/0013-voz-y-sin-borrador.md. */

:root {
  --papel: #E7E8E2;
  --superficie: #DCDFD5;
  --tinta: #1A1F1C;
  --tinta-suave: #3D4541;
  --gris: #48514C;
  --verde: #2B5843;
  --verde-oscuro: #1E3A2D;
  --blanco: #FFFFFF;
  --linea: #BFC5BC;
  --hueco: #DADCD5;
  --foco: #1E3A2D;
  --borde-foto: transparent;

  --banda: #1E3A2D;
  --banda-texto: #F2F4EF;
  --banda-gris: #B9CABF;
  --banda-acento: #DCE7A0;
  --banda-acento-texto: #1E3A2D;
  --banda-linea: #4A6658;
  --banda-foco: #F2F4EF;

  color-scheme: light;

  /* Page grid: a reading column, and a wider frame for photos and the
     header. Gutter 16px on a phone, 40px from 40em. */
  --gutter: var(--e-3);
  --col: 44rem;
  --frame: 64rem;
}

@media (min-width: 40em) {
  :root {
    --gutter: var(--e-5);
  }
}

/* «Azul marino»: the club's colours, the navy shirt with its lemon print. */
:root:has(#tema-azul:checked) {
  --papel: #121A2B;
  --superficie: #1B2539;
  --tinta: #EEF0EA;
  --tinta-suave: #AEB7C4;
  --gris: #AEB7C4;
  --verde: #E3D24A;
  --verde-oscuro: #EEF0EA;
  --blanco: #121A2B;
  --linea: #33405A;
  --hueco: #1B2539;
  --foco: #E3D24A;
  --borde-foto: #33405A;

  --banda: #213052;
  --banda-texto: #EEF0EA;
  --banda-gris: #AEB7C4;
  --banda-acento: #E3D24A;
  --banda-acento-texto: #121A2B;
  --banda-linea: #3D4C6B;
  --banda-foco: #E3D24A;

  color-scheme: dark;
}

/* «Verde noche»: the identity's green, at night (the class is at 21:00). */
:root:has(#tema-noche:checked) {
  --papel: #0F1E18;
  --superficie: #172C23;
  --tinta: #ECF1EC;
  --tinta-suave: #A6B9AE;
  --gris: #A6B9AE;
  --verde: #8FD3A9;
  --verde-oscuro: #ECF1EC;
  --blanco: #0B1813;
  --linea: #2C4A3C;
  --hueco: #172C23;
  --foco: #8FD3A9;
  --borde-foto: #2C4A3C;

  --banda: #1D372B;
  --banda-texto: #ECF1EC;
  --banda-gris: #A6B9AE;
  --banda-acento: #8FD3A9;
  --banda-acento-texto: #0B1813;
  --banda-linea: #3A5A4A;
  --banda-foco: #8FD3A9;

  color-scheme: dark;
}

/* The page on --papel; past its ends (overscroll) the band colour, so the
   header and the footer seem to go on. */
html {
  background: var(--banda);
}

body {
  background: var(--papel);
}

:focus-visible {
  outline-color: var(--foco);
}

/* Header and footer: the band. Inside it the identity names point at the
   band colours, so the brand, the schedule, the button and the links need
   no rules of their own. */
.cabecera,
.pie {
  --tinta: var(--banda-texto);
  --tinta-suave: var(--banda-texto);
  --gris: var(--banda-gris);
  --verde: var(--banda-acento);
  --verde-oscuro: var(--banda-texto);
  --blanco: var(--banda-acento-texto);
  --linea: var(--banda-linea);
  --foco: var(--banda-foco);
  background: var(--banda);
  color: var(--banda-texto);
}

/* The seal on a dark ground (informe §3.3): its black ring would vanish,
   so it sits on a white disc with a thin light edge, like a stamp on paper.
   No filter: invert() turns the green mantis purple. */
.marca__seal {
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 0 0 2px var(--banda-texto);
}

/* ---------- Page frame ---------- */

.wrap {
  box-sizing: border-box;
  width: 100%;
  max-width: calc(var(--frame) + 2 * var(--gutter));
  margin: 0 auto;
  padding-inline: var(--gutter);
}

/* Keep fixed groups («21:00–22:30», «Pabellón El Deyre (Otura)») on one line. */
.nobr {
  white-space: nowrap;
}

/* ---------- Colour control ---------- */

/* «Colores: Claro, Azul marino, Verde noche». Native radios, kept for the
   keyboard and screen readers but drawn as the labels; each label is a
   44px target with a small sample of its theme. */
.temas {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0 var(--e-1);
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
  font-size: var(--t-0);
  line-height: 1.2;
}

/* A floated legend is laid out as ordinary content, beside the options. */
.temas > legend {
  float: left;
  margin-right: var(--e-1);
  padding: 0;
  color: var(--banda-gris);
}

.temas > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.temas > label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  min-height: 44px;
  padding: 0 0.5rem;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--banda-gris);
  cursor: pointer;
  white-space: nowrap;
}

/* The sample: the theme's page colour with its accent. */
.temas > label::before {
  content: "";
  flex: none;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--banda-gris);
  background: linear-gradient(135deg, var(--muestra-fondo) 50%, var(--muestra-acento) 50%);
}

.temas > [for="tema-claro"] {
  --muestra-fondo: #F6F7F3;
  --muestra-acento: #1E3A2D;
}

.temas > [for="tema-azul"] {
  --muestra-fondo: #121A2B;
  --muestra-acento: #E3D24A;
}

.temas > [for="tema-noche"] {
  --muestra-fondo: #0F1E18;
  --muestra-acento: #8FD3A9;
}

.temas > label:hover {
  color: var(--banda-texto);
}

.temas > input:checked + label {
  border-color: var(--banda-texto);
  color: var(--banda-texto);
}

.temas > input:focus-visible + label {
  outline: 2px solid var(--banda-foco);
  outline-offset: 2px;
}

/* On a narrow phone the three options share one row from edge to edge,
   down to 320px. The legend stays for screen readers. */
@media (max-width: 26em) {
  .temas {
    display: grid;
    grid-template-columns: repeat(3, auto);
    justify-content: space-between;
  }

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

  .temas > label {
    gap: var(--e-1);
    padding-inline: var(--e-1);
  }

  .temas > label::before {
    width: 0.75rem;
    height: 0.75rem;
  }
}

/* ---------- Header ---------- */

.cabecera > .wrap {
  padding-block: var(--e-1) 0;
}

/* The brand and the colour control share the top: the control in a row
   above the brand on a phone and a tablet, at its right from 54em. */
.cabecera__top {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--e-1);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--linea);
}

.cabecera .marca {
  max-width: none;
}

@media (min-width: 40em) {
  .cabecera > .wrap {
    padding-top: var(--e-3);
  }
}

/* Brand and control side by side only where both fit on one line each. */
@media (min-width: 54em) {
  .cabecera__top {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--e-4);
  }
}

.cabecera h1 {
  margin: 1.25rem 0 0;
  max-width: 18em;
}

.cabecera .lead {
  margin: 0.875rem 0 0;
}

/* «Puedes venir a mirar…»: under the schedule and its button. */
.cabecera__nota {
  margin: var(--e-3) 0 0;
  font-size: var(--t-0);
  line-height: 1.45;
}

/* The group photo closes the band: edge to edge and flush with the band's
   bottom on a phone, the frame width with band below it from 40em. It
   loads first (fetchpriority) because it is the first thing seen after
   the button. */
.foto-grupo {
  margin: var(--e-5) calc(-1 * var(--gutter)) 0;
}

@media (min-width: 40em) {
  .foto-grupo {
    margin-inline: 0;
  }

  .cabecera > .wrap {
    padding-bottom: var(--e-5);
  }
}

/* The one memorable block: the schedule with the characters set upright beside it. */
.horario {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--e-3);
  align-items: start;
  margin-top: 1.25rem;
}

.horario__data {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.horario__data > p {
  margin: 0;
}

.horario__days {
  font-size: var(--t-2);
  font-weight: 600;
  line-height: 1.25;
}

.horario__data > .horario__place {
  margin-top: var(--e-2);
}

.horario .button {
  margin-top: var(--e-3);
}

/* Hover keeps the colours (they are the band's best pair) and underlines. */
.cabecera .button:hover {
  background: var(--verde);
  color: var(--blanco);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

.horario .caracteres {
  --han-size: 2.125rem;
  padding-left: 0.875rem;
  border-left: 1px solid var(--linea);
}

/* The reading beside the characters at body-note size: 13px read sideways
   was too small on a phone. The 34px column is long enough for it. */
.horario .caracteres__reading {
  font-size: var(--t-0);
}

@media (min-width: 60em) {
  .cabecera > .wrap {
    padding-bottom: var(--e-6);
  }

  .cabecera__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 22rem);
    column-gap: var(--e-6);
    align-items: end;
  }

  .cabecera h1 {
    margin-top: var(--e-6);
  }

  .cabecera .lead {
    margin-top: var(--e-4);
    max-width: 34em;
  }

  .horario {
    margin-top: 0;
    gap: var(--e-4);
  }

  .horario .caracteres {
    --han-size: var(--t-5);
    padding-left: var(--e-4);
  }
}

/* The school seal, left of the name (ADR 0012): 56px on a phone, 64px from
   40em. Below that its six characters stop reading. At 320px, 56 + 16 gap +
   the name still fit in 288px. */
.cabecera .marca__seal {
  width: 3.5rem;
  height: 3.5rem;
}

@media (min-width: 40em) {
  .cabecera .marca__seal {
    width: 4rem;
    height: 4rem;
  }
}

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

/* Each section is a full-width band of its own colour, on a grid with a
   reading column («content», 44rem) at the left of a wider frame («wide»,
   64rem, the header's) for photos: the h2 lines up with the h1. Alternate
   sections sit on --superficie. */
.seccion {
  --suelo: var(--papel);
  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [wide-start content-start] min(100% - 2 * var(--gutter), var(--col))
    [content-end] minmax(0, calc(var(--frame) - var(--col)))
    [wide-end] minmax(var(--gutter), 1fr)
    [full-end];
  align-content: start;
  padding-block: var(--e-5);
  background: var(--suelo);
}

.seccion--superficie {
  --suelo: var(--superficie);
}

.seccion > * {
  grid-column: content;
}

/* «Tu primer día» and «Dónde se entrena» are one closing block on the same
   ground; a rule on the column separates them. */
.seccion--superficie + .seccion--superficie {
  padding-top: 0;
}

.seccion--superficie + .seccion--superficie::before {
  content: "";
  grid-column: content;
  margin-bottom: var(--e-5);
  border-top: 1px solid var(--linea);
}

.seccion > h2 {
  margin: 0 0 var(--e-4);
}

.seccion > :last-child {
  margin-bottom: 0;
}

.seccion p {
  margin: 0 0 var(--e-3);
}

@media (min-width: 60em) {
  .seccion {
    padding-block: var(--e-6);
  }

  .seccion--superficie + .seccion--superficie::before {
    margin-bottom: var(--e-6);
  }
}

/* Photos: full width of their box. Each <img> carries width and height,
   so the page does not jump while they load. On the dark themes a 1px
   edge keeps the blue floor of the photos from bleeding into the page. */
.fotos figure,
.foto-linaje {
  margin: 0;
}

.fotos img,
.foto-linaje img,
.foto-grupo img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--hueco);
  outline: 1px solid var(--borde-foto);
  outline-offset: -1px;
}

/* «Cómo es una clase»: three photos across the frame, the first one wide. */
.seccion > .fotos {
  grid-column: wide;
  display: grid;
  gap: var(--e-3);
  margin-top: var(--e-4);
}

@media (min-width: 40em) {
  .fotos {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fotos > :first-child {
    grid-column: 1 / -1;
  }
}

/* ---------- Lineage ---------- */

.fuentes {
  margin: 0 0 var(--e-5);
  padding: 0;
  list-style: none;
  font-size: var(--t-0);
  line-height: 1.45;
  color: var(--gris);
}

.fuentes time,
.fuentes [lang] {
  white-space: nowrap;
}

.fuentes > li + li {
  margin-top: var(--e-2);
}

/* «Quién da la clase»: the text and its sources, with the photo of Zhang
   and Alejandro below on a phone. From 60em the text stays on the left
   and the photo sits at the right edge of the frame. */
.linaje {
  margin-bottom: var(--e-5);
}

@media (min-width: 60em) {
  .seccion > .linaje {
    grid-column: wide;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22rem;
    column-gap: var(--e-5);
    align-items: start;
  }
}

.foto-linaje figcaption {
  margin-top: var(--e-2);
  max-width: var(--measure);
  font-size: var(--t-0);
  line-height: 1.45;
  color: var(--gris);
}

.cadena__label {
  font-size: var(--t-0);
  color: var(--gris);
}

/* The chain of teachers: names joined by one line, in order, never numbered. */
.cadena {
  margin: 0 0 var(--e-5);
  padding: 0;
  list-style: none;
}

.cadena > li {
  position: relative;
  padding: 0 0 var(--e-3) 1.5rem;
  border-left: 1px solid var(--linea);
  margin-left: 0.3125rem;
  line-height: 1.3;
}

.cadena > li:last-child {
  padding-bottom: 0;
  border-left-color: transparent;
  font-weight: 600;
}

.cadena > li::before {
  content: "";
  position: absolute;
  top: 0.4em;
  left: -0.3125rem;
  width: 0.5625rem;
  height: 0.5625rem;
  box-sizing: border-box;
  border: 1px solid var(--verde);
  border-radius: 50%;
  background: var(--suelo, var(--papel));
}

.cadena > li:last-child::before {
  background: var(--verde);
}

.cadena [lang] {
  font-weight: 500;
  color: var(--verde);
}

.historia {
  border-top: 1px solid var(--linea);
  border-bottom: 1px solid var(--linea);
}

.historia > summary {
  display: flex;
  align-items: center;
  gap: var(--e-2);
  min-height: 48px;
  color: var(--verde);
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.historia > summary::-webkit-details-marker {
  display: none;
}

.historia > summary::before {
  content: "+";
  content: "+" / "";
  display: inline-block;
  width: 1ch;
  font-weight: 400;
}

.historia[open] > summary::before {
  content: "−";
  content: "−" / "";
}

.historia > summary:hover {
  color: var(--verde-oscuro);
}

.historia > div {
  padding-bottom: var(--e-3);
}

/* ---------- Places ---------- */

.lugares {
  display: grid;
  gap: var(--e-4);
}

@media (min-width: 40em) {
  .lugares {
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  }
}

.lugar {
  padding-top: var(--e-3);
  border-top: 2px solid var(--verde);
}

.lugar > h3 {
  margin: 0 0 var(--e-2);
}

.lugar > p {
  margin: 0 0 var(--e-1);
}

.lugar > p:last-child {
  margin: var(--e-3) 0 0;
}

.lugar > p:only-of-type {
  margin-top: 0;
}

.lugar__tel {
  font-size: var(--t-2);
  font-weight: 600;
}

.seccion > .lugares__nota {
  margin: var(--e-5) 0 0;
}

/* ---------- Footer ---------- */

.pie > .wrap {
  padding-block: var(--e-5) var(--e-6);
}

.pie__datos {
  margin-top: var(--e-4);
  font-size: var(--t-0);
  line-height: 1.45;
}

.pie__datos > p {
  margin: 0;
}

.pie__datos > p + p {
  margin-top: var(--e-1);
}

.pie__links {
  margin: var(--e-4) 0 0;
  padding: 0;
  list-style: none;
  font-size: var(--t-0);
}

.pie__links > li + li {
  margin-top: var(--e-2);
}

/* ---------- Legal page ---------- */

.legal .cabecera > .wrap {
  padding-bottom: var(--e-5);
}

.legal .cabecera .marca a {
  color: inherit;
  text-decoration: none;
}

/* The name links home: underline on hover so it reads as a link. */
.legal .cabecera .marca a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* ---------- Print: always Claro, no band, no control ---------- */

@media print {
  :root,
  :root:has(#tema-azul:checked),
  :root:has(#tema-noche:checked) {
    --papel: #FFFFFF;
    --superficie: #FFFFFF;
    --tinta: #1A1F1C;
    --tinta-suave: #3D4541;
    --gris: #48514C;
    --verde: #2B5843;
    --verde-oscuro: #1E3A2D;
    --blanco: #FFFFFF;
    --linea: #BFC5BC;
    --hueco: #FFFFFF;
    --borde-foto: transparent;

    --banda: transparent;
    --banda-texto: #1A1F1C;
    --banda-gris: #48514C;
    --banda-acento: #2B5843;
    --banda-acento-texto: #FFFFFF;
    --banda-linea: #BFC5BC;

    color-scheme: light;
  }

  .temas {
    display: none;
  }

  .marca__seal {
    box-shadow: none;
  }
}
