/*
 * Structural layer shared by both themes.
 *
 * Colours, fonts and decoration come from theme-classic.css or
 * theme-retro.css via custom properties — this file only lays things out.
 */

/* ---------- reset ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body,
h1,
h2,
h3,
p,
ol,
ul,
dl,
dd,
figure,
fieldset,
legend {
  margin: 0;
  padding: 0;
}

ol[class],
ul[class] {
  list-style: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

fieldset {
  border: 0;
}

/* ---------- defaults ---------- */

:root {
  --measure: 34rem;
  --page-max: 68rem;
  --space: 1rem;
  --radius: 4px;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
}

a {
  color: var(--link);
}

/*
 * Available to assistive technology, invisible on screen. Used where a
 * sighted visitor reads a value from a graphic and a screen reader needs the
 * same fact as text.
 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/*
 * The skip link gets its own colour pair rather than reusing ink-on-paper:
 * in the retro theme "paper" is navy and "ink" is black, which would have
 * made the one control a keyboard user meets first unreadable.
 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  background: var(--skip-bg, #1c1b18);
  color: var(--skip-fg, #ffffff);
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/*
 * Two rings, not one: the outline carries the contrast against light
 * surfaces and the halo against dark ones, so the focused element is visible
 * wherever it happens to sit. This matters most in the retro theme, where the
 * mouse cursor is hidden and the ring is all a keyboard user has.
 */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus-halo, transparent);
}

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--header-bg);
}

.site-header__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}

.brand {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 0.65rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.brand__kanji {
  grid-row: 1 / 3;
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  color: var(--accent);
  /* Three characters, one line — never broken across two. */
  white-space: nowrap;
}

.brand__name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1.2;
}

.brand__dates {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.1rem;
  margin-left: auto;
}

/* Every link is a finger-sized target, not just a line of text — the
   shortest label, "Info", would otherwise be barely a fingertip wide. */
.nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.nav a:hover,
.nav a[aria-current='page'] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.nav__cta,
.nav a.nav__cta {
  padding: 0.4rem 0.9rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
}

.nav a.nav__cta:hover {
  background: var(--accent);
  color: var(--paper);
  border-bottom-color: var(--accent);
}

.theme-toggle button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 44px;
  padding: 0.4rem 0.8rem;
  background: transparent;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  font-size: 0.85rem;
  white-space: nowrap;
}

.theme-toggle button:hover {
  border-style: solid;
  color: var(--ink);
}

/*
 * Below this width the brand cannot share a line with six navigation items
 * and a mood toggle. The brand takes the first row on its own; the
 * navigation and the toggle then share the second, instead of the Register
 * button and the toggle each dropping onto a line of their own.
 */
@media (max-width: 52rem) {
  .site-header__inner {
    padding: 0.75rem 1rem;
    gap: 0.5rem 0.75rem;
  }

  .brand {
    flex: 1 0 100%;
  }

  /* `1 1 0` rather than `auto`: the navigation has to be willing to shrink,
     otherwise its natural width claims the whole row and the toggle drops
     onto a line of its own again. */
  .nav {
    flex: 1 1 0;
    min-width: 0;
    margin-left: 0;
    column-gap: 0.8rem;
    row-gap: 0;
  }

  .nav a {
    font-size: 0.95rem;
  }

  /* Pushed to the far end of the row the navigation is sharing. */
  .theme-toggle {
    margin-left: auto;
  }

  .theme-toggle button {
    padding: 0.35rem 0.55rem;
    font-size: 0.78rem;
  }
}

/* ---------- page shell ---------- */

.page {
  --page-gap: 3.5rem;

  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: var(--page-gap);
}

.page-head h1,
.hero__title {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
}

.page-head h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
}

.page-head__lead {
  margin-top: 0.75rem;
  max-width: var(--measure);
  color: var(--ink-soft);
}

/* ---------- hero ---------- */

.hero {
  padding: 1rem 0 0;
}

.hero__eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero__title {
  margin: 0.6rem 0 1rem;
  font-size: clamp(2.2rem, 7vw, 3.4rem);
}

/*
 * Intro text and countdown sit side by side while there is room, and stack
 * below each other when there is not.
 */
.hero__body {
  margin-top: 1.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2.5rem 3rem;
  align-items: start;
}

@media (max-width: 54rem) {
  .hero__body {
    grid-template-columns: 1fr;
  }
}

.hero__intro {
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  font-size: 1.08rem;
  color: var(--ink-soft);
}

.hero__actions {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ---------- countdown ---------- */

.countdown {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: flex-start;
}

.countdown__title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

/* Two by two in the hero column; one row wherever there is more space. */
.countdown__units {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.countdown__unit {
  min-width: 5rem;
  padding: 0.7rem 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.countdown__unit[hidden] {
  display: none;
}

.countdown__value {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.countdown__label {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.countdown__date {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

/* ---------- prose ---------- */

.prose {
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.prose--centered {
  margin: 0 auto;
}

.prose h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  line-height: 1.15;
}

.prose h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin-top: 1.25rem;
}

.prose ul,
.prose ol {
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lead {
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.deflist {
  display: grid;
  /* `minmax(0, …)` on the first track: without it a long term refuses to
     shrink and pushes the whole page wider than the phone it is read on. */
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 0.4rem 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.deflist dt {
  color: var(--ink-soft);
}

.deflist dd {
  overflow-wrap: anywhere;
}

/* Two columns stop being readable long before the term stops fitting. */
@media (max-width: 30rem) {
  .deflist {
    grid-template-columns: 1fr;
    gap: 0 0;
  }

  .deflist dd {
    margin-bottom: 0.6rem;
  }
}

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 1rem;
}

.card {
  padding: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card h2 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin-bottom: 0.4rem;
}

.card p {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

/* ---------- callout ---------- */

.callout {
  padding: 1.75rem;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-start;
}

.callout h2 {
  font-family: var(--font-display);
  font-size: 1.3rem;
}

/* ---------- schedule ---------- */

.schedule {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.schedule__day {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin-top: 1.5rem;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid var(--accent);
}

/* The subject of the day, sitting just under its heading. */
.schedule__topic {
  margin-top: 0.4rem;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.schedule__list {
  display: flex;
  flex-direction: column;
}

.schedule__list li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--line);
}

.schedule__time {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* ---------- sensei ---------- */

/*
 * Sensei page only. The rule at the top of the biography reads as a line under
 * the page head rather than as the start of a section, so the full 3.5rem gap
 * between the head and the first section leaves far more air above the rule
 * than the 0.75rem the column keeps below it. Pulling the section up by the
 * difference balances the two sides; every other page keeps the shared gap.
 */
.bio--tight-top {
  margin-top: calc(0.75rem - var(--page-gap));
}

/*
 * The portrait floats inside the running text rather than sitting in a column
 * of its own, so the biography is one block box the text runs the width of.
 */
.bio__portrait {
  float: left;
  width: 40%;
  max-width: 17rem;
  min-width: 12rem;
  margin: 0 1.5rem 1rem 0;
}

.bio__portrait img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

/*
 * The bio figures float inside the running text, so the column they sit in
 * has to be a block box — floats are ignored on flex items.
 *
 * The rule that opens the biography belongs to the column: the portrait floats
 * at the top of it, so a border on the first heading instead would start to the
 * right of the photo rather than spanning the column.
 */
.bio .prose {
  display: block;
  max-width: 52rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

/*
 * The last figure in the column floats, and nothing follows it to clear the
 * float, so the column has to close over its own floats.
 */
.bio .prose::after {
  content: '';
  display: table;
  clear: both;
}

.bio .prose > * {
  margin-bottom: 1rem;
}

.bio .prose > *:last-child {
  margin-bottom: 0;
}

.bio__figure {
  clear: both;
  width: 45%;
  min-width: 11rem;
}

.bio__figure--left {
  float: left;
  margin-right: 1.25rem;
}

.bio__figure--right {
  float: right;
  margin-left: 1.25rem;
}

/*
 * Panoramic group shots are wasted at 45% of the column: run them the full
 * width instead, on their own line, with the paragraph rhythm around them.
 */
.bio__figure--wide {
  float: none;
  clear: both;
  width: 100%;
  margin-right: 0;
  margin-left: 0;
  margin-bottom: 1rem;
}

.bio__figure img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.bio__figure figcaption {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

/*
 * Fukui sensei's words, set apart from the paragraph that introduces them.
 * The indent is a border rather than a quotation mark: the two themes draw
 * their own type, and a glyph sized for one of them is wrong in the other.
 *
 * It clears the floats above it for the same reason the figures do — a quote
 * that starts halfway down the side of a photograph reads as a caption.
 */
.bio__quote {
  clear: both;
  border-left: 2px solid var(--line);
  padding-left: 1rem;
  color: var(--ink-soft);
  font-style: italic;
}

@media (max-width: 46rem) {
  .bio__portrait,
  .bio__figure,
  .bio__figure--left,
  .bio__figure--right {
    float: none;
    width: 100%;
    max-width: none;
    margin-right: 0;
    margin-left: 0;
  }
}

/* ---------- buttons ---------- */

.button {
  display: inline-block;
  padding: 0.65rem 1.3rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  border-color: var(--ink);
}

.button--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button--primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

/* ---------- forms ---------- */

.form {
  max-width: var(--measure);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field > label,
.field legend {
  font-weight: 600;
  font-size: 0.95rem;
}

.field input[type='text'],
.field input[type='email'],
.field select,
.field textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--input-bg);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--accent);
}

.field input[aria-invalid='true'],
.field select[aria-invalid='true'],
.field textarea[aria-invalid='true'] {
  border-color: var(--error);
}

.field textarea {
  resize: vertical;
}

.field__hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.field__error {
  font-size: 0.88rem;
  color: var(--error);
  font-weight: 600;
}

.field--radio {
  gap: 0.5rem;
}

/* The label is what a finger hits, so it — not the 13px dot inside it —
   has to be big enough to hit. */
.radio {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.radio:hover {
  border-color: var(--line-strong);
}

/* The default 13px dot is a hard thing to hit; the label around it is the
   real target, but the dot itself may as well be aimable too. */
.radio input {
  width: 1.15rem;
  height: 1.15rem;
  flex: none;
}

.req {
  color: var(--accent);
}

.opt {
  font-weight: 400;
  color: var(--ink-soft);
}

.form__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.form__privacy {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.alert {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--error);
  background: var(--error-soft);
  color: var(--error);
  font-weight: 600;
}

/*
 * The list of everything that went wrong, at the top of the form. The thick
 * left edge is the same device the admin uses for its warning, so the two
 * halves of the site flag a problem the same way.
 */
.error-summary {
  max-width: var(--measure);
  padding: 1rem 1.1rem;
  border: 2px solid var(--error);
  border-left-width: 6px;
  border-radius: var(--radius);
  background: var(--error-soft);
}

.error-summary__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--error);
}

.error-summary__list {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.error-summary__list a {
  color: var(--error);
  font-weight: 600;
}

/* Jumping here from the error summary should not leave the field flush
   against the top edge of the window. */
.field input,
.field select,
.field textarea,
.field--radio .radio:first-of-type {
  scroll-margin-top: 1.5rem;
}

/* Honeypot — off-screen rather than display:none, which some bots detect. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--header-bg);
  margin-top: auto;
}

.site-footer__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 2rem;
}

.site-footer__block h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 0.4rem;
}

.site-footer__block p {
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.site-footer__legal {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ---------- hit counter ---------- */

.odometer {
  display: inline-flex;
  gap: 2px;
}

.odometer__digit {
  display: inline-block;
  min-width: 1.1em;
  padding: 0.15em 0.1em;
  text-align: center;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
