/* ==========================================================================
   Base styles — mobile first.
   Styles are written for phones; `@media (min-width: …)` blocks add the
   wider-screen layout. All colors/sizes come from tokens.css.
   ========================================================================== */

/* --- Reset -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
img, svg, video { display: block; max-width: 100%; height: auto; }
input, button, select, textarea { font: inherit; }
[hidden] { display: none !important; }

/* --- Page --------------------------------------------------------------- */
html { color-scheme: light dark; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: var(--leading-normal);
  overflow-wrap: break-word;
}
main { flex: 1; }
main:focus { outline: none; }

/* --- Typography --------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-heading);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-2); }
h4 { font-size: var(--step-1); }

a { color: var(--color-link); text-underline-offset: 0.15em; }
a:hover { color: var(--color-link-hover); }

:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Spacing between stacked elements inside text blocks */
.flow > * + * { margin-top: var(--space-s); }
.flow > * + :is(h2, h3) { margin-top: var(--space-l); }

.prose { max-width: var(--measure); }
.prose ul, .prose ol { padding-left: 1.25em; }
.lede { font-size: var(--step-1); color: var(--color-text-muted); max-width: var(--measure); }

/* --- Layout ------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Full-width horizontal "bands" that alternate light / dark down the page */
.band { padding-block: var(--space-2xl); }
.band--alt { background: var(--color-bg-alt); }
.band--inverse { background: var(--color-bg-inverse); color: var(--color-text-inverse); }
.band--inverse :is(h1, h2, h3, h4, a) { color: inherit; }

/* Simple responsive grid: 1 column on phones, more as space allows */
.grid {
  display: grid;
  gap: var(--space-m);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
}

.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-m);
  box-shadow: var(--shadow);
}

/* Wide tables scroll inside their own box, never the whole page */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: var(--space-2xs) var(--space-xs); border-bottom: 1px solid var(--color-border); }

/* Definition lists used for "fact" lists (tower details, schedules) */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-3xs) var(--space-s); }
.facts dt { font-weight: 600; }

/* --- Buttons ------------------------------------------------------------ */
.button {
  display: inline-block;
  padding: var(--space-2xs) var(--space-s);
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--color-button-bg);
  color: var(--color-button-text);
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.button:hover { color: var(--color-button-text); filter: brightness(1.1); }
.button--cta { background: var(--color-cta-bg); color: var(--color-cta-text); }
.button--cta:hover { color: var(--color-cta-text); }
.button--outline { background: transparent; border-color: currentColor; color: var(--color-link); }
.button-row { display: flex; flex-wrap: wrap; gap: var(--space-xs); }

/* --- Skip link (visible only when focused with the keyboard) ------------ */
.skip-link {
  position: absolute;
  left: var(--space-s);
  top: -100px;
  z-index: 100;
  padding: var(--space-2xs) var(--space-s);
  background: var(--color-bg);
  border-radius: var(--radius);
}
.skip-link:focus { top: var(--space-s); }

/* --- Header ------------------------------------------------------------- */
/* Without JavaScript the phone menu is simply always shown (below the logo),
   so the header is only sticky on phones once JavaScript has loaded. */
.site-header {
  position: relative;
  z-index: 50;
  background: var(--color-header-bg);
  border-bottom: 1px solid var(--color-border);
}
.js .site-header { position: sticky; top: 0; }

.site-header__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-s);
  padding-block: var(--space-xs);
}

.site-brand {
  flex: 1 1 auto;
  font-family: var(--font-serif);
  font-size: var(--step-1);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-heading);
  text-decoration: none;
}

.site-header__cta { padding: var(--space-3xs) var(--space-xs); font-size: var(--step--1); }

/* Menu toggle button — added by nav.js; hidden on wide screens */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-xs);
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: var(--step--1);
  cursor: pointer;
}
.nav-toggle__icon,
.nav-toggle__icon::before,
.nav-toggle__icon::after {
  display: block;
  width: 1.1em;
  height: 2px;
  background: currentColor;
  position: relative;
}
.nav-toggle__icon::before, .nav-toggle__icon::after { content: ""; position: absolute; }
.nav-toggle__icon::before { top: -0.35em; }
.nav-toggle__icon::after { top: 0.35em; }

/* Navigation: phones (default) */
.site-nav { flex-basis: 100%; }
.site-nav__list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3xs) var(--space-s);
}
.site-nav a {
  display: block;
  padding-block: var(--space-3xs);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}
.site-nav a:hover { color: var(--color-link-hover); }
.site-nav a[aria-current] {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 0.35em;
}

/* With JavaScript, phones get a collapsible menu panel */
@media (max-width: 67.99em) {
  .js .site-nav { display: none; }
  .js .site-nav.is-open { display: block; }
  .js .site-nav__list { flex-direction: column; gap: 0; padding-block: var(--space-2xs); }
  .js .site-nav__list a { padding-block: var(--space-2xs); border-top: 1px solid var(--color-border); }
}

/* Wide screens: everything on one row, no toggle */
@media (min-width: 68em) {
  .site-header__inner { flex-wrap: nowrap; }
  .site-brand { flex: 0 1 auto; margin-right: auto; }
  .nav-toggle { display: none; }
  .site-nav { flex-basis: auto; order: 0; }
  .site-header__cta { order: 1; padding: var(--space-2xs) var(--space-s); font-size: var(--step-0); }
}

/* --- Page intro --------------------------------------------------------- */
.page-intro { padding-block: var(--space-xl); background: var(--color-bg-alt); }
.page-intro .lede { margin-top: var(--space-xs); }

/* Placeholder banner — remove from templates as real content arrives */
.placeholder-note {
  padding: var(--space-xs) var(--space-s);
  background: var(--color-notice-bg);
  border-left: 4px solid var(--color-notice-border);
  border-radius: var(--radius);
  font-size: var(--step--1);
}

/* --- Footer ------------------------------------------------------------- */
.site-footer {
  padding-block: var(--space-xl);
  background: var(--color-bg-inverse);
  color: var(--color-text-inverse);
  font-size: var(--step--1);
}
.site-footer a { color: inherit; }
.site-footer__inner { display: grid; gap: var(--space-m); }
.site-footer__links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-m); }
@media (min-width: 48em) {
  .site-footer__inner { grid-template-columns: 1fr auto; align-items: start; }
}

/* --- Reduced motion ----------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
  a, .button { transition: color var(--duration), filter var(--duration); }
}

/* --- Page content blocks ------------------------------------------------ */

/* Logo in the header */
.site-brand img { height: 2rem; width: auto; }
@media (min-width: 40em) { .site-brand img { height: 2.5rem; } }
/* The logo is purple on transparent: give it a light backing in dark mode */
@media (prefers-color-scheme: dark) {
  .site-brand img { background: var(--neutral-0); padding: 0.25rem 0.5rem; border-radius: var(--radius); box-sizing: content-box; }
}

/* Schedules ("Tuesday Evening Practice: 7:00 – 8:30 PM") */
.schedule { list-style: none; padding: 0; }
.schedule li + li { margin-top: var(--space-2xs); }

/* Our Towers page */
.tower + .tower { margin-top: var(--space-xl); padding-top: var(--space-xl); border-top: 1px solid var(--color-border); }
.tower__photo { float: none; }
.tower__photo img { border-radius: var(--radius); }
.tower__photo figcaption { font-size: var(--step--1); color: var(--color-text-muted); margin-top: var(--space-3xs); }
@media (min-width: 40em) {
  .tower__photo { float: right; margin: 0 0 var(--space-s) var(--space-m); }
  .tower::after { content: ""; display: block; clear: both; }
}

/* Videos & Animations page: animation beside its text, stacked on phones */
.animation { display: grid; gap: var(--space-s); margin-block: var(--space-l); }
.animation img { max-width: 100%; height: auto; }
@media (min-width: 40em) {
  .animation { grid-template-columns: auto 1fr; align-items: start; }
}
.credit { font-size: var(--step--1); font-style: italic; color: var(--color-text-muted); }

/* Contact list */
.contacts > div + div { margin-top: var(--space-s); }
.contacts dt { font-weight: 600; }

/* Keep short phrases (e.g. a time range) on one line */
.nowrap { white-space: nowrap; }

/* ==========================================================================
   Homepage
   ========================================================================== */

/* Buttons inside dark bands keep their own text colors */
.band--inverse .button--cta { color: var(--color-cta-text); }
.band--inverse .button--outline { color: var(--color-text-inverse); }

/* 1. Hero: headline on the left, Ringing Times card on the right (wide screens) */
.hero { padding-block: var(--space-xl); }
.hero__inner { display: grid; gap: var(--space-l); align-items: center; }
.hero__tagline { font-size: var(--step-1); max-width: 36ch; }
@media (min-width: 52em) {
  .hero { padding-block: var(--space-2xl); }
  .hero__inner { grid-template-columns: 1.1fr 1fr; gap: var(--space-xl); }
}
/* The card is light even inside the dark hero */
.hero .hero__card { color: var(--color-text); }
.hero .hero__card :is(h2, h3) { color: var(--color-heading); }
.hero .hero__card a { color: var(--color-link); }
.hero__card h2 { font-size: var(--step-2); }
.hero__card h3 { font-size: var(--step-1); }
.hero__tower + .hero__tower { padding-top: var(--space-s); border-top: 1px solid var(--color-border); }
.hero__tower h3 a { text-decoration: none; }
.hero__tower h3 a:hover { text-decoration: underline; }
.hero__tower .schedule { margin-top: var(--space-2xs); }

/* 2. Notices */
.band--notice { background: var(--color-notice-bg); border-block: 1px solid var(--color-notice-border); padding-block: var(--space-l); }
.notice + .notice { padding-top: var(--space-s); border-top: 1px solid var(--color-notice-border); }

/* 4. Towers at a glance */
.glance { min-width: 20rem; background: var(--color-bg); }
@media (max-width: 39.99em) { .glance th, .glance td { padding: var(--space-2xs); } .glance thead th { font-size: var(--step-0); } .glance tbody th { white-space: normal; } }
.glance th, .glance td { padding: var(--space-xs) var(--space-s); vertical-align: top; }
.glance thead th { font-family: var(--font-serif); font-size: var(--step-1); }
.glance tbody th { white-space: nowrap; color: var(--color-text-muted); font-weight: 600; }
.table-wrap:focus-visible { outline-offset: 4px; }

/* 5. Your path to ringing: numbered steps, side by side on wide screens */
.steps { list-style: none; padding: 0; display: grid; gap: var(--space-m); counter-reset: step; }
.steps__item { position: relative; padding-left: 3.5rem; counter-increment: step; }
.steps__item::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-button-bg); color: var(--color-button-text);
  font-family: var(--font-serif); font-weight: 700; font-size: var(--step-1);
}
.steps__item h3 { font-size: var(--step-1); margin-bottom: var(--space-3xs); }
@media (min-width: 52em) {
  .steps { grid-template-columns: repeat(3, 1fr); gap: var(--space-l); }
  .steps__item { padding-left: 0; padding-top: 3.5rem; }
  /* a thin line joining the numbers */
  .steps__item:not(:last-child)::after {
    content: ""; position: absolute; top: 1.25rem; left: 3rem; right: calc(-1 * var(--space-l) + 0.5rem);
    border-top: 2px solid var(--color-border);
  }
}

/* 6. Explore: icon cards */
.icon-grid {
  list-style: none; padding: 0;
  display: grid; gap: var(--space-s);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 11rem), 1fr));
}
.icon-card {
  display: flex; align-items: center; gap: var(--space-xs);
  height: 100%;
  padding: var(--space-s);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-weight: 600;
  text-decoration: none;
}
.icon-card .icon { flex: none; color: var(--color-heading); }
.icon-card:hover { border-color: var(--color-link); color: var(--color-link); }
@media (min-width: 40em) {
  .icon-card { flex-direction: column; align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .icon-card { transition: border-color var(--duration), color var(--duration); }
}

/* Email links: let them wrap only at the <wbr> after "@" */
a[href^="mailto:"] { overflow-wrap: normal; word-break: normal; }

/* Towers at a glance on phones: short tower names, let times wrap */
.glance__short { display: none; }
@media (max-width: 39.99em) {
  .glance__full { display: none; }
  .glance__short { display: inline; }
  .glance .nowrap { white-space: normal; }
}
@media (max-width: 39.99em) {
  .glance tbody th { white-space: normal; }
  .glance thead th { font-size: var(--step-0); }
}

/* ==========================================================================
   Inner pages (Phase 4)
   ========================================================================== */

.muted { color: var(--color-text-muted); }

/* Feature rows: media on one side, text on the other; alternate sides */
.feature { display: grid; gap: var(--space-m); padding-block: var(--space-l); }
.feature + .feature { border-top: 1px solid var(--color-border); }
.feature__media { justify-self: start; }
@media (min-width: 48em) {
  .feature { grid-template-columns: minmax(0, 16rem) 1fr; gap: var(--space-xl); align-items: start; }
  .feature--reverse { grid-template-columns: 1fr minmax(0, 16rem); }
  .feature--reverse .feature__media { order: 2; justify-self: end; }
  .feature__body { max-width: var(--measure); }
}

/* Animations (see macros/animation.njk) */
.anim img { border-radius: var(--radius); background: var(--neutral-50); }
.anim__motion-link { font-size: var(--step--1); margin-top: var(--space-3xs); }
/* Only offer the "View the animation" link when motion is reduced */
@media (prefers-reduced-motion: no-preference) { .anim__motion-link { display: none; } }

/* Our Towers */
.jump-links ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2xs); }
.jump-links a {
  display: inline-block; padding: var(--space-3xs) var(--space-s);
  border: 1px solid var(--color-border); border-radius: 999px;
  text-decoration: none; font-weight: 600;
}
.jump-links a:hover { border-color: var(--color-link); }
.feature--tower { scroll-margin-top: 5rem; }  /* clear the sticky header when jumped to */
.tower-photo img { border-radius: var(--radius); box-shadow: var(--shadow); }
.tower-photo figcaption { font-size: var(--step--1); color: var(--color-text-muted); margin-top: var(--space-2xs); }
.facts dd { margin: 0; }
@media (max-width: 29.99em) {
  .facts { grid-template-columns: 1fr; }
  .facts dd + dt { margin-top: var(--space-2xs); }
}
.listen { display: flex; gap: var(--space-xs); align-items: flex-start; }
.listen .icon { flex: none; color: var(--color-heading); width: 1.75rem; height: 1.75rem; }
.closing { margin-top: var(--space-l); background: var(--color-bg-alt); box-shadow: none; }

/* Change Ringing: animation beside the text on wider screens */
.aside-figure { max-width: 12rem; }
.aside-figure .credit { margin-top: var(--space-2xs); }
@media (min-width: 40em) {
  .aside-figure { float: right; margin: 0 0 var(--space-m) var(--space-l); }
}
.prose::after { content: ""; display: block; clear: both; }
.steps--stacked { grid-template-columns: 1fr; }
.steps--stacked .steps__item { padding-left: 3.5rem; padding-top: 0; }
.steps--stacked .steps__item::after { display: none; }

/* Videos */
.video-list { list-style: none; padding: 0; display: grid; gap: var(--space-s); grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.video-card {
  display: flex; gap: var(--space-s); align-items: flex-start; height: 100%;
  padding: var(--space-m); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  color: var(--color-text); text-decoration: none;
}
.video-card .icon { flex: none; color: var(--color-heading); }
.video-card strong { display: block; color: var(--color-heading); font-family: var(--font-serif); font-size: var(--step-1); }
.video-card > .flow > * + * { margin-top: var(--space-3xs); }
.video-card__where { display: block; font-size: var(--step--1); color: var(--color-link); text-decoration: underline; }
.video-card:hover { border-color: var(--color-link); }

/* Contact */
.contact-grid { list-style: none; padding: 0; display: grid; gap: var(--space-m); margin-bottom: var(--space-l); }
@media (min-width: 40em) { .contact-grid { grid-template-columns: repeat(2, 1fr); } }
.contact-grid h2 { font-size: var(--step-1); }
.contact-name { font-weight: 600; }

/* ==========================================================================
   Ringing record (Phase 5)
   ========================================================================== */

/* Compositions: monospaced blocks that keep their spacing, scroll if wide */
pre {
  overflow-x: auto;
  padding: var(--space-s);
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: var(--step--1);
  line-height: 1.45;
  tab-size: 4;
}
.composition { padding-block: var(--space-l); scroll-margin-top: 5rem; }
.composition + .composition { border-top: 1px solid var(--color-border); }

/* Performances */
.perf-section { padding-block: var(--space-l); scroll-margin-top: 5rem; }
.perf-section + .perf-section { border-top: 1px solid var(--color-border); }
.perf-year { border: 1px solid var(--color-border); border-radius: var(--radius); background: var(--color-bg); }
.perf-year + .perf-year { margin-top: var(--space-2xs); }
.perf-year summary {
  display: flex; align-items: baseline; gap: var(--space-xs);
  padding: var(--space-xs) var(--space-s);
  cursor: pointer; font-family: var(--font-serif); font-size: var(--step-1); color: var(--color-heading);
}
.perf-year__count { font-family: var(--font-sans); font-size: var(--step--1); color: var(--color-text-muted); }
.perf-year[open] summary { border-bottom: 1px solid var(--color-border); }
.perf-list { list-style: none; padding: 0; }
.perf-year .perf-list { padding: var(--space-2xs) var(--space-s) var(--space-s); }
.perf { padding-block: var(--space-2xs); }
.perf + .perf { border-top: 1px dashed var(--color-border); }
.perf a { font-weight: 600; }
.perf__meta { display: block; font-size: var(--step--1); color: var(--color-text-muted); }
/* Homepage: recent ringing as small cards */
.perf-list--cards { display: grid; gap: var(--space-s); grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); }
.perf-list--cards .perf { padding: var(--space-s); border: 1px solid var(--color-border); border-radius: var(--radius); }
.perf-list--cards .perf + .perf { border-top: 1px solid var(--color-border); }

/* ==========================================================================
   Downloads (Phase 6)
   ========================================================================== */
.download-section { padding-block: var(--space-l); scroll-margin-top: 5rem; }
.download-section + .download-section { border-top: 1px solid var(--color-border); }
.download-list { list-style: none; padding: 0; display: grid; gap: var(--space-2xs) var(--space-s); grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); }
.download {
  display: flex; gap: var(--space-xs); align-items: flex-start; height: 100%;
  padding: var(--space-xs) var(--space-s);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-bg); color: var(--color-text); text-decoration: none;
}
.download .icon { flex: none; width: 1.5rem; height: 1.5rem; color: var(--color-heading); margin-top: 0.1rem; }
.download__title { display: block; font-weight: 600; color: var(--color-link); text-decoration: underline; text-underline-offset: 0.15em; }
.download__desc { display: block; font-size: var(--step--1); }
.download__meta { display: block; font-size: var(--step--1); color: var(--color-text-muted); }
.download:hover { border-color: var(--color-link); }

/* Text for screen readers only */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
