/*
 * «El rollo 目録» — hoja 2/9: la tapa (表紙), la hoja (本紙) y el arranque del registro.
 * El orden de carga de las 9 hojas —y la razón de ese orden— está en la cabecera de
 * rollo-base.css.
 */
/* ── Tapa (表紙): tela índigo con la etiqueta, la búsqueda y el acceso ── */

.tapa {
    position: relative;
    z-index: 20;
    color: var(--papel-claro);
}

.tapa__marco,
.hoja {
    width: min(100% - 2 * var(--margen), var(--ancho));
    margin-inline: auto;
}

.tapa__marco {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(1rem, 2.5vw, 2.5rem);
    padding-block: 1.25rem 1.125rem;
}

.tapa :focus-visible {
    outline-color: var(--kin-claro);
}

/* Etiquetas de papel pegadas en la tela (daisen): filete impreso a 3px del borde */
.daisen,
.acceso__etiqueta {
    background: var(--papel-claro) url("/img/rollo/fibras-kozo.svg") 0 0 / 480px 480px;
    color: var(--sumi);
    text-decoration: none;
    box-shadow:
        inset 0 0 0 3px var(--papel-claro),
        inset 0 0 0 4px rgb(31 27 23 / 0.72);
    transition: background-color 0.2s var(--curva);
}

.daisen {
    display: inline-flex;
    /* Se deja encoger y envolver: a texto grande la marca envuelve dentro de su etiqueta
       en vez de ensanchar la tapa (WCAG 1.4.4, crítica 04-11) */
    flex: 0 1 auto;
    min-width: 0;
    flex-wrap: wrap;
    overflow-wrap: anywhere;
    align-items: center;
    gap: 0.375rem 0.75rem;
    padding: 0.45rem 0.5rem 0.45rem 1rem;
}

.daisen:hover,
.acceso__etiqueta:hover {
    background-color: var(--papel-hondo);
    box-shadow:
        inset 0 0 0 3px var(--papel-hondo),
        inset 0 0 0 4px rgb(31 27 23 / 0.72);
}

.daisen__titulo {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 1.125rem;
    font-weight: 800;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

/* Sello (hanko): el bloque base (.sello/.sello--marca) vive en base.css, compartido con el taller.
   La firma del colofón sigue acá: el taller no tiene colofón. */

.busqueda {
    position: relative;
    display: flex;
    flex: 1 1 22rem;
    min-width: 0;
    max-width: 36rem;
    margin-inline: auto;
}

.busqueda__lupa {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    width: 1.125rem;
    height: 1.125rem;
    color: var(--usuzumi);
    translate: 0 -50%;
    pointer-events: none;
}

.busqueda input {
    flex: 1 1 0;
    width: 0;
    min-width: 0;
    height: 2.875rem;
    padding: 0 0.75rem 0 2.6rem;
    border: 0;
    border-radius: 0;
    background: var(--papel) url("/img/rollo/fibras-kozo.svg") 0 0 / 480px 480px;
    color: var(--sumi);
    font: 400 1rem / 1 var(--mincho);
    caret-color: var(--sumi);
    appearance: none;
}

.busqueda input::placeholder {
    color: var(--usuzumi);
    opacity: 1;
}

.busqueda__boton {
    flex: none;
    height: 2.875rem;
    padding: 0 1.15rem;
    border: 0;
    border-radius: 0;
    background: var(--sumi);
    color: var(--papel-claro);
    font: 700 1rem / 1 var(--mincho);
    cursor: pointer;
    transition: background-color 0.2s var(--curva);
}

.busqueda__boton:hover {
    background: var(--sumi-pleno);
}

/* El buscador hero de la apertura: la misma tira global en escala de documento, pegada a la
   hoja como papel clarito con filete de tinta. Mismo combobox, desplegable y estados que la tapa */
.busqueda--hero {
    grid-area: consulta;
    flex: none;
    justify-self: stretch;
    max-width: none;
    margin: clamp(1.25rem, 2.5vw, 1.5rem) 0 0;
}

.busqueda--hero input {
    height: 3.5rem;
    padding: 0 0.875rem 0 2.85rem;
    border: 1px solid var(--hilo);
    background: var(--papel-claro) url("/img/rollo/fibras-kozo.svg") 0 0 / 480px 480px;
    font-size: 1.0625rem;
}

.busqueda--hero .busqueda__lupa {
    left: 0.95rem;
    width: 1.25rem;
    height: 1.25rem;
}

.busqueda--hero .busqueda__boton {
    height: 3.5rem;
    padding: 0 1.5rem;
    font-size: 1.0625rem;
}

/* Desplegable de la búsqueda global (fragmento compartido): hoja de papel que cuelga de la tira */
.busqueda__desplegable {
    position: absolute;
    top: calc(100% + 0.375rem);
    right: 0;
    left: 0;
    z-index: 30;
    background: var(--papel-claro);
    color: var(--sumi);
    box-shadow: var(--sombra-colgante);
}

.busqueda__desplegable:empty,
.busqueda__desplegable[hidden] {
    display: none;
}

/* Mientras htmx consulta, la lupa late: el buscador está trabajando */
.busqueda:has(input.htmx-request) .busqueda__lupa {
    animation: buscando 0.8s ease-in-out infinite alternate;
}

@keyframes buscando {
    to {
        opacity: 0.3;
    }
}

@media (prefers-reduced-motion: reduce) {
    .busqueda:has(input.htmx-request) .busqueda__lupa {
        animation: none;
        opacity: 0.45;
    }
}

.busqueda__desplegable > p {
    margin: 0;
    padding: 0.8rem 1rem 0.35rem;
    color: var(--usuzumi);
    font-size: 0.9375rem;
    font-weight: 700;
}

/* Sin coincidencias: qué se buscó, cómo busca y por dónde seguir */
.busqueda__desplegable > div {
    padding: 0.85rem 1rem 0.7rem;
}

.busqueda__desplegable > div > p:first-child {
    font-weight: 700;
}

.busqueda__desplegable > div > p + p {
    margin-top: 0.2rem;
    color: var(--usuzumi);
    font-size: 0.9375rem;
}

.busqueda__desplegable ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.busqueda__desplegable li a,
.busqueda__desplegable > a {
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-top: 1px solid var(--hilo);
    color: var(--sumi);
    text-decoration: none;
}

.busqueda__desplegable li a > span:first-child,
.busqueda__desplegable > div + ul a,
.busqueda__desplegable > a {
    font-weight: 700;
}

.busqueda__desplegable li a > span + span {
    color: var(--usuzumi);
    font-size: 0.9375rem;
    text-align: right;
}

/* Los enlaces de recuperación (solo existen tras un div explicativo, rama sin resultados)
   tienen que leerse como enlaces: la voz de tinta subrayada del sitio, no texto suelto */
.busqueda__desplegable > div + ul a {
    text-decoration: underline;
    text-decoration-color: var(--hilo);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.28em;
}

.busqueda__desplegable > div + ul a:hover {
    text-decoration-color: currentColor;
}

/* «Ver todas las escuelas» lleva la misma flecha dibujada que «Ver todas» del registro */
.busqueda__desplegable > a {
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
}

.busqueda__desplegable > a svg {
    width: 1.1em;
    height: 1.1em;
}

.busqueda__desplegable a:hover {
    background: var(--papel-hondo);
}

/* La opción activa que el listbox anuncia con aria-selected se ve como la que está bajo el cursor:
   misma mano de papel tratado — el teclado recorre y el ojo sigue (crítica 18-10, P1) */
.busqueda__desplegable li a[aria-selected="true"] {
    background: var(--papel-hondo);
}

.busqueda__desplegable :focus-visible {
    outline-offset: -3px;
}

.acceso {
    display: flex;
    /* Se deja encoger: con flex:none el nav no envolvía jamás (su contenido mandaba) */
    flex: 0 1 auto;
    min-width: 0;
    /* Texto grande (200%): el nav envuelve en vez de ensanchar la tapa (WCAG 1.4.4, crítica 04-11) */
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem 1.25rem;
    align-items: center;
    font-size: 1rem;
}

.acceso__link {
    text-decoration: underline;
    text-decoration-color: var(--hilo-tapa);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.28em;
    transition: text-decoration-color 0.2s var(--curva);
}

.acceso__link:hover {
    text-decoration-color: currentColor;
}

/* El logout es un POST disfrazado de link (auditoría run-2): botón sin cromo de control */
.acceso__salir button {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
}

.acceso__etiqueta {
    display: inline-flex;
    align-items: center;
    min-height: 2.5rem;
    padding: 0.35rem 1rem;
    font-weight: 700;
}

/* ── Hoja (本紙): torinoko con fibras de kozo; arriba, la franja de oro en polvo ── */

.hoja {
    position: relative;
    padding: calc(var(--alto-kin) + clamp(2.25rem, 4.5vw, 4rem)) var(--aire)
        clamp(3.5rem, 7vw, 6rem);
    background: var(--papel) url("/img/rollo/fibras-kozo.svg") 0 0 / 480px 480px;
}

.hoja::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: var(--alto-kin);
    background: var(--kin) url("/img/rollo/kin-sunago.svg") 0 0 / 320px 100% repeat-x;
    box-shadow: inset 0 -1px rgb(31 27 23 / 0.4);
}

.apertura {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto auto 1fr;
    grid-template-areas:
        "titular mokuroku"
        "bajada mokuroku"
        "consulta mokuroku"
        "acciones mokuroku"
        ". mokuroku";
    column-gap: clamp(1rem, 6vw, 7rem);
}

.titular {
    grid-area: titular;
    max-width: 18ch;
    font-size: clamp(2.25rem, 1rem + 3.6vw, 4.25rem);
    font-weight: 800;
    line-height: 1.04;
    letter-spacing: -0.02em;
    text-wrap: balance;
    overflow-wrap: anywhere;
}

.bajada {
    grid-area: bajada;
    text-wrap: pretty;
    max-width: 34ch;
    margin-top: clamp(1rem, 2.5vw, 1.25rem);
    color: var(--usuzumi-hondo);
    font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.3125rem);
    line-height: 1.55;
}

.acciones {
    display: flex;
    flex-wrap: wrap;
    gap: 0.875rem 1rem;
    align-items: center;
}

.apertura .acciones {
    grid-area: acciones;
    margin-top: clamp(1.25rem, 2.5vw, 1.75rem);
}

/* El aviso de cercanía (permiso o error) del acto de apertura: tinta diluida, en la
   fila libre de la grilla, debajo de los sellos */
.apertura__aviso {
    margin-top: 0.9rem;
    color: var(--usuzumi-hondo);
    font-size: 0.9375rem;
}

/* La salida de quien no figura: una línea de tinta diluida pegada a la consulta, no un enlace
   perdido en la FAQ. Ocupa la fila libre de la grilla, debajo del buscador */
.apertura__salida {
    grid-area: acciones;
    margin-top: 0.75rem;
    color: var(--usuzumi-hondo);
    font-size: 0.9375rem;
}

.apertura__salida a {
    color: var(--sumi);
    text-decoration: underline;
    text-decoration-color: var(--hilo);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.28em;
}

.apertura__salida a:hover {
    text-decoration-color: currentColor;
}

/* 武道 a pincel en el margen derecho: el título del rollo anuncia su tema, el camino marcial */
.mokuroku {
    grid-area: mokuroku;
    writing-mode: vertical-rl;
    justify-self: end;
}

.mokuroku__kanji {
    display: block;
    font-family: var(--pincel);
    font-size: clamp(3.75rem, 1rem + 9vw, 9.5rem);
    line-height: 1;
    color: var(--sumi);
}

.mokuroku__lectura {
    display: block;
    margin-inline-start: 0.35rem;
    padding-block-start: 0.4rem;
    color: var(--usuzumi);
    font-size: 0.9375rem;
    letter-spacing: 0.04em;
}

/* El pincel del maestro (public/js/pincel.js): en la primera visita de la sesión escribe 武道
   sobre el mismo cuadro, con el texto transparente debajo para lectores y selección. Hasta que
   el script toma el control, la tinta y los sellos esperan; si el script no llega, aparecen
   igual a los 2,4 s */
[data-pincel="espera"] :is(.mokuroku__kanji, .sello) {
    animation: pincel-respaldo 0.3s 2.4s both;
}

[data-pincel="aguarda"] :is(.mokuroku__kanji, .sello) {
    opacity: 0;
}

@keyframes pincel-respaldo {
    from {
        opacity: 0;
    }
}

.mokuroku__kanji--pincel {
    position: relative;
    color: transparent;
}

/* Los dos cuadros de 1em, uno debajo del otro, donde el navegador pone 武 y 道 */
.mokuroku__pincel {
    position: absolute;
    top: 0;
    left: 0;
    width: 1em;
    height: 2em;
    color: var(--sumi);
}

/* CTA estampada: sello bermellón con filete interior de papel (朱文) */
.sello-cta,
.etiqueta {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 3.25rem;
    padding: 0.7rem 1.5rem;
    font-size: 1.1875rem;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.2s var(--curva);
}

.sello-cta {
    background: var(--shu);
    color: var(--papel-claro);
    font-weight: 800;
}

.sello-cta::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 1px solid rgb(245 239 225 / 0.8);
    pointer-events: none;
}

.sello-cta:hover {
    background: var(--shu-hondo);
}

.etiqueta {
    border: 1px solid var(--sumi);
    background: var(--papel-claro);
    color: var(--sumi);
    font-weight: 700;
}

.etiqueta:hover {
    background: var(--papel-hondo);
}

/* ── Registro: los asientos de las escuelas, por orden de llegada ── */

.registro {
    margin-top: clamp(2.25rem, 4.5vw, 3.5rem);
}
