/* =====================================================================
   pages.css - page-specific overrides
   ===================================================================== */

/* --- Home carousel (section 6.1) ---------------------------------------- */
.carousel {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--color-badge-bg);
  margin: var(--space-3) 0;
}
.carousel__track { display: flex; transition: transform 0.5s ease; }
.carousel__slide { min-width: 100%; position: relative; }
.carousel__slide img {
  width: 100%;
  height: 320px;
  object-fit: cover;
}
.carousel__slide-fallback {
  height: 320px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-accent-tan);
  padding: var(--space-4);
  text-align: center;
}
.carousel__caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
  color: #ffffff;
  padding: var(--space-5) var(--space-3) var(--space-3);
}
.carousel__caption a { color: #ffffff; font-size: 1.125rem; font-weight: 500; }
/* The imageless slide carries the link in its own heading, on tan. */
.carousel__slide-fallback h2 a { color: var(--color-on-accent); }
.carousel__btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-text);
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.carousel__btn--prev { left: 12px; }
.carousel__btn--next { right: 12px; }
.carousel__dots { display: flex; gap: 6px; justify-content: center; padding: var(--space-2); }
.carousel__dots button {
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 0;
  background: var(--color-border);
  padding: 0;
}
.carousel__dots button[aria-current="true"] { background: var(--color-btn-bg); }

@media (max-width: 575px) {
  .carousel__slide img, .carousel__slide-fallback { height: 200px; }
  /* Keep the fallback text clear of the 40px prev/next buttons. */
  .carousel__slide-fallback { padding-left: 58px; padding-right: 58px; }
  .carousel__caption { padding: var(--space-4) var(--space-3) var(--space-3); }
}

/* --- Listing pages -------------------------------------------------------- */
.listing-head {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  flex-wrap: wrap;
}
.listing-head__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-badge-bg);
  flex: 0 0 72px;
}
.listing-head__icon img { width: 100%; height: 100%; object-fit: cover; }
.listing-head h1 { margin: 0; }

/* --- Scheme detail -------------------------------------------------------- */
.scheme-byline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: var(--space-3);
}
.scheme-byline__author { display: flex; align-items: center; gap: var(--space-2); font-size: 0.875rem; color: var(--color-text-muted); }
.scheme-byline__avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--color-badge-bg);
  flex: 0 0 40px;
}
.scheme-byline__right { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.scheme-banner { width: 100%; border-radius: var(--radius-md); margin: var(--space-3) 0; }
.scheme-section { scroll-margin-top: 90px; }
.scheme-body h2 { border-bottom: 1px solid var(--color-border); padding-bottom: 6px; }
.scheme-body a { color: var(--color-link); }
/* ...but a button is not body copy. `.scheme-body a` above matches the same
   specificity as `a.btn-primary` in components.css and wins on load order,
   which painted the "Join the discussion forum" label link-blue on its black
   pill. Buttons keep their own colours. */
.scheme-body a.btn-primary,
.scheme-body a.btn-primary:hover { color: var(--color-btn-text); }
.scheme-body a.btn-outline { color: var(--color-btn-outline-border); }
.scheme-body a.btn-outline:hover { color: #ffffff; }
.external-glyph { font-size: 0.75rem; margin-left: 4px; }
.documents-note { font-style: italic; font-size: 0.875rem; color: var(--color-text-muted); }
.file-list { list-style: none; padding: 0; }
.file-list li { margin-bottom: var(--space-1); }

/* --- Wizards --------------------------------------------------------------- */
.wizard { max-width: 720px; }
.wizard__summary {
  background: var(--color-table-stripe);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}
.wizard__summary dl { margin: 0; display: grid; grid-template-columns: 200px 1fr; gap: 6px var(--space-3); }
.wizard__summary dt { font-weight: 500; }
.wizard__summary dd { margin: 0; }
@media (max-width: 575px) {
  .wizard__summary dl { grid-template-columns: 1fr; }
  .wizard__summary dt { margin-top: var(--space-2); }
}

/* --- Contact page ---------------------------------------------------------- */
.contact-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-3); margin: var(--space-3) 0 var(--space-5); }
.contact-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}
.contact-card h3 { margin-top: 0; font-size: 1.125rem; }
.contact-card p { margin-bottom: var(--space-1); }
@media (max-width: 991px) { .contact-cards { grid-template-columns: 1fr; } }

.recorder { border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: var(--space-3); }
.recorder__row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.recorder__timer { font-variant-numeric: tabular-nums; font-weight: 500; }
.recorder audio { width: 100%; margin-top: var(--space-2); }

/* --- Auth pages ------------------------------------------------------------- */
.auth-wrap { max-width: 460px; margin: 0 auto; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); flex-wrap: wrap; }
.auth-tabs a {
  padding: 10px var(--space-3);
  text-decoration: none;
  color: var(--color-nav-link);
  border-bottom: 3px solid transparent;
  font-size: 0.95rem;
}
.auth-tabs a[aria-current="page"] { border-bottom-color: var(--color-btn-bg); font-weight: 500; }
.social-login { margin-top: var(--space-4); border-top: 1px solid var(--color-border); padding-top: var(--space-3); }
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  font-weight: 500;
}

/* --- Dashboard --------------------------------------------------------------- */
.dashboard { display: grid; grid-template-columns: 220px 1fr; gap: var(--space-4); align-items: start; }
.dashboard__nav { list-style: none; padding: 0; margin: 0; border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
.dashboard__nav li + li { border-top: 1px solid var(--color-border); }
.dashboard__nav a { display: block; padding: 12px var(--space-3); color: var(--color-nav-link); text-decoration: none; }
.dashboard__nav a[aria-current="page"] { background: var(--color-accent-tan); font-weight: 500; }
.danger-zone { border: 2px solid var(--color-danger); border-radius: var(--radius-md); padding: var(--space-3); margin-top: var(--space-5); }
.danger-zone h3 { margin-top: 0; color: var(--color-danger); }
@media (max-width: 767px) { .dashboard { grid-template-columns: 1fr; } }

/* --- Static prose pages -------------------------------------------------------- */
.prose { max-width: 780px; }
.prose h2 { font-size: 1.5rem; }
.prose ul { padding-left: 20px; margin-bottom: var(--space-3); }

/* =====================================================================
   Polish layer for individual pages.
   ===================================================================== */

/* --- Home carousel ------------------------------------------------------ */
.carousel { border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.carousel__btn {
  box-shadow: var(--shadow-card);
  transition: background-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.carousel__btn:hover { background: #ffffff; transform: translateY(-50%) scale(1.06); }
.carousel__caption { padding: var(--space-6) var(--space-4) var(--space-4); }
.carousel__caption a { text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5); }
.carousel__dots button { transition: background-color var(--speed) var(--ease), transform var(--speed) var(--ease); }
.carousel__dots button:hover { transform: scale(1.25); }
.carousel__dots button[aria-current="true"] { width: 22px; border-radius: var(--radius-pill); }

/* --- Listing headers ----------------------------------------------------- */
.listing-head {
  padding: var(--space-4);
  background: var(--color-surface-sunken);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
}
.listing-head__icon {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 4px var(--color-border-soft), var(--shadow-card);
}
.listing-head h1 { letter-spacing: -0.02em; }

/* --- Scheme detail --------------------------------------------------------- */
.scheme-byline {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--color-border-soft);
  border-bottom: 1px solid var(--color-border-soft);
}
.scheme-byline__avatar { box-shadow: 0 0 0 1px var(--color-border-soft); }
.scheme-banner { box-shadow: var(--shadow-card); }
.scheme-body h2 {
  border-bottom: 0;
  padding-bottom: 0;
  position: relative;
  padding-left: 14px;
}
/* A quiet accent bar reads better than a full rule under every heading. */
.scheme-body h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  bottom: 0.18em;
  width: 4px;
  border-radius: var(--radius-pill);
  background: var(--color-accent-tan-hover);
}
.check-list li, .step-list li { line-height: 1.62; }
.file-list a { display: inline-block; padding: 4px 0; }

/* --- Wizards ----------------------------------------------------------------- */
.wizard__summary { border-radius: var(--radius-lg); border-color: var(--color-border-soft); }

/* --- Contact ------------------------------------------------------------------ */
.contact-card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border-color: var(--color-border-soft);
  transition: box-shadow var(--speed) var(--ease), transform var(--speed) var(--ease);
}
.contact-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.recorder { border-radius: var(--radius-md); background: var(--color-surface-sunken); border-color: var(--color-border-soft); }

/* --- Auth ---------------------------------------------------------------------- */
.auth-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5);
}
.auth-tabs a { transition: color var(--speed) var(--ease), border-color var(--speed) var(--ease); }
.auth-tabs a:hover { color: var(--color-link); }
.btn-google { transition: box-shadow var(--speed) var(--ease), border-color var(--speed) var(--ease); }
.btn-google:hover { box-shadow: var(--shadow-card); border-color: var(--color-border-strong); }

/* --- Dashboard ------------------------------------------------------------------ */
.dashboard__nav { border-radius: var(--radius-lg); box-shadow: var(--shadow-card); border-color: var(--color-border-soft); }
.dashboard__nav a { transition: background-color var(--speed) var(--ease), padding-left var(--speed) var(--ease); }
.dashboard__nav a:hover { background: var(--color-surface-sunken); padding-left: 20px; }
.danger-zone { border-radius: var(--radius-lg); background: #fffafa; }

/* --- Prose ------------------------------------------------------------------------ */
.prose { line-height: 1.7; }
.prose h2 { margin-top: var(--space-5); }

/* Attribution line under a state portrait.

   Constrained on purpose. Credit text comes from whatever the image source
   recorded, which is occasionally a very long unbroken string; without a
   width cap and a break rule one of those stretches the flex header and
   pushes the layout out of shape. */
.photo-credit {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin: var(--space-1) 0 0;
  line-height: 1.4;
  max-width: 52ch;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* The TEXT column of a listing header must be allowed to shrink. A flex item
   defaults to min-width:auto, which refuses to go narrower than its longest
   word, and that is what lets a long credit widen the whole card.

   Scoped with :not() on purpose. The portrait is also a direct div child, and
   an unscoped ".listing-head > div" hands it flex:1 1 320px, which stretches
   the 72px circle into a wide ellipse. */
.listing-head > div:not([class*="listing-head__icon"]) {
  min-width: 0;
  flex: 1 1 320px;
}

/* Belt and braces: the portrait keeps its exact square whatever else claims
   to style it, so the border-radius always renders as a circle. One
   variable drives every dimension, so they cannot drift apart. */
.listing-head { --portrait: 96px; }
.listing-head__icon {
  flex: 0 0 var(--portrait) !important;
  width: var(--portrait);
  height: var(--portrait);
  min-width: var(--portrait);
  max-width: var(--portrait);
  aspect-ratio: 1 / 1;
}
.listing-head__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}
.listing-head h1 { overflow-wrap: anywhere; }

/* Same guard in the credits table. */
.data-table td .photo-credit { max-width: none; }

/* A 96px hero portrait is too heavy on a phone. */
@media (max-width: 575px) {
  .listing-head { --portrait: 68px; }
  .listing-head { padding: var(--space-3); gap: var(--space-3); }
}

/* On the category and central pages the heading is a direct flex child
   rather than sitting in a wrapper div, so it needs the same shrink rule. */
.listing-head > h1 { min-width: 0; flex: 1 1 320px; }
