/* ==========================================================================
   WASHTROUGH.CSS — Wash Trough Configurator Styles
   toilet-cubicle.co.uk — A Paneltech brand (see docs/brand/BRAND.md)
   ========================================================================== */

/* -------------------------------------------------------------------------
   Page Layout
   ------------------------------------------------------------------------- */

.wt-page {
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  background-color: var(--color-off-white);
}

/* -------------------------------------------------------------------------
   Hero strip — kicker, h1, product sentence, CAD download link
   ------------------------------------------------------------------------- */

.wt-hero {
  background-color: var(--color-white);
  border-bottom: 1px solid var(--color-border);
}

.wt-hero__inner {
  max-width: var(--container-max);
  margin-inline: auto;
  padding: var(--sp-3) var(--sp-3);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
}

.wt-hero__title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-extrabold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
  color: var(--color-grey-900);
  margin-bottom: var(--sp-1);
}

.wt-hero__lede {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-normal);
  max-width: 58ch;
  margin-bottom: 0;
}

.wt-hero__cad {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: 44px;
  padding: 0 var(--sp-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-petrol);
  text-decoration: none;
  white-space: nowrap;
}

.wt-hero__cad:hover {
  color: var(--color-petrol-dark);
  text-decoration: underline;
}

.wt-hero__cad:focus-visible {
  outline: 2px solid var(--color-petrol);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------------
   Configurator grid — drawing front-and-centre, options panel right
   ------------------------------------------------------------------------- */

.wt-configurator {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

/* Grid children must be allowed to shrink below their content width so a
   wide spec strip or readout can wrap rather than force horizontal scroll. */
.wt-configurator > .wt-viewport,
.wt-configurator > .wt-sidebar {
  min-width: 0;
}

@media (min-width: 1024px) {
  .wt-configurator {
    grid-template-columns: minmax(0, 1fr) 400px;
    align-items: stretch;
  }
}

/* -------------------------------------------------------------------------
   SVG Viewport
   ------------------------------------------------------------------------- */

.wt-viewport {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  padding-top: calc(var(--sp-3) + 56px); /* clear the floating view toggle */
  background-color: var(--color-white);
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  min-height: 440px;
}

@media (min-width: 1024px) {
  .wt-viewport {
    padding: var(--sp-4);
    padding-top: calc(var(--sp-4) + 56px);
    min-height: calc(100vh - var(--header-height) - 160px);
    min-height: calc(100dvh - var(--header-height) - 160px);
  }
}

.wt-viewport svg {
  width: 100%;
  flex: 1 1 auto;
  min-height: 300px;
  max-height: 62vh;
}

/* View toggle buttons */
.wt-view-toggle {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  display: flex;
  gap: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-grey-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  z-index: 2;
}

.wt-view-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-right: 1px solid var(--color-grey-200);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.wt-view-btn:last-child {
  border-right: none;
}

.wt-view-btn:hover:not(.active) {
  background-color: var(--color-grey-100);
  color: var(--color-text-primary);
}

.wt-view-btn:focus-visible {
  outline: 2px solid var(--color-petrol);
  outline-offset: -2px;
}

.wt-view-btn.active {
  color: var(--color-white);
  background-color: var(--color-petrol);
}

/* -------------------------------------------------------------------------
   Specification strip + readout — mono figures under the drawing
   ------------------------------------------------------------------------- */

.wt-spec {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1) var(--sp-3);
  padding: var(--sp-1) var(--sp-2);
  margin-inline: auto;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-grey-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
}

.wt-readout {
  font-family: var(--font-mono);
  font-weight: var(--weight-medium);
  color: var(--color-charcoal);
  white-space: nowrap;
}

.wt-spec__item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-grey-600);
  white-space: nowrap;
}

.wt-spec__chip {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 3px;
  border: 1px solid var(--color-grey-300);
  background-color: var(--color-white);
}

.wt-caption {
  text-align: center;
  font-size: var(--text-2xs);
  color: var(--color-grey-600);
  line-height: var(--leading-snug);
  max-width: 72ch;
  margin: 0 auto;
}

/* -------------------------------------------------------------------------
   Sidebar
   ------------------------------------------------------------------------- */

.wt-sidebar {
  background-color: var(--color-white);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

/* Sidebar header — title + mobile close button */
.wt-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--color-grey-100);
  flex-shrink: 0;
}

.wt-sidebar__title {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  margin-bottom: 0;
}

.wt-sidebar__close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--color-grey-600);
  background: var(--color-grey-100);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.wt-sidebar__close:hover {
  background-color: var(--color-grey-200);
  color: var(--color-grey-900);
}

.wt-sidebar__close:focus-visible {
  outline: 2px solid var(--color-petrol);
  outline-offset: 2px;
}

/* Tabs */
.wt-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-grey-50);
  position: sticky;
  top: 0;
  z-index: 2;
}

.wt-tabs [role="tab"] {
  flex: 1;
  min-height: 44px;
  padding: var(--sp-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast);
  text-align: center;
}

.wt-tabs [role="tab"]:hover {
  color: var(--color-text-primary);
}

.wt-tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--color-petrol);
  outline-offset: -2px;
}

.wt-tabs [role="tab"][aria-selected="true"] {
  color: var(--color-petrol);
  border-bottom-color: var(--color-petrol);
  background-color: var(--color-white);
}

/* Tab panels */
.wt-sidebar [role="tabpanel"] {
  padding: var(--sp-3);
  flex: 1;
}

/* Fieldsets */
.wt-sidebar fieldset {
  border: none;
  padding: 0;
  margin: 0 0 var(--sp-4) 0;
}

.wt-sidebar fieldset:last-child {
  margin-bottom: 0;
}

/* Kicker legends — shared recipe from components.css; just normalise legend box */
.wt-sidebar legend.kicker {
  display: inline-flex;
  width: 100%;
  padding: 0;
  border: none;
}

/* -------------------------------------------------------------------------
   Stepper — − / mono value / + (BRAND.md §4)
   ------------------------------------------------------------------------- */

.wt-stepper {
  display: flex;
  align-items: stretch;
  background-color: var(--color-white);
  border: 1px solid var(--color-grey-300);
  border-radius: var(--radius);
  overflow: hidden;
}

.wt-stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  min-height: 44px;
  flex-shrink: 0;
  color: var(--color-petrol);
  background-color: var(--color-grey-50);
  border: none;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.wt-stepper__btn:first-child {
  border-right: 1px solid var(--color-grey-200);
}

.wt-stepper__btn:last-child {
  border-left: 1px solid var(--color-grey-200);
}

.wt-stepper__btn:hover:not(:disabled) {
  background-color: var(--color-petrol-tint);
  color: var(--color-petrol-dark);
}

.wt-stepper__btn:focus-visible {
  outline: 2px solid var(--color-petrol);
  outline-offset: -2px;
}

.wt-stepper__btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.wt-stepper__value {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--color-grey-900);
  white-space: nowrap;
}

/* -------------------------------------------------------------------------
   Radio group — Mounting
   ------------------------------------------------------------------------- */

.wt-radio-group {
  display: flex;
  gap: var(--sp-1);
}

.wt-radio-group label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 10px 12px;
  margin-bottom: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  background-color: var(--color-grey-50);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

/* Selected state — teal-tint bg + petrol border (BRAND.md §1, §4) */
.wt-radio-group label.wt-radio-group--selected {
  color: var(--color-petrol-dark);
  font-weight: var(--weight-semibold);
  background-color: var(--color-teal-tint);
  border-color: var(--color-petrol);
  box-shadow: 0 0 0 1px var(--color-petrol);
}

.wt-radio-group input[type="radio"] {
  /* Visually hidden but accessible */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.wt-radio-group label:has(input:focus-visible) {
  outline: 2px solid var(--color-petrol);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------------
   Tap count display
   ------------------------------------------------------------------------- */

.wt-tap-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 10px 12px;
  font-size: var(--text-sm);
  background-color: var(--color-grey-50);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-primary);
}

.wt-tap-display__label {
  color: var(--color-text-secondary);
}

.wt-tap-display__value {
  font-weight: var(--weight-medium);
  font-family: var(--font-mono);
}

/* -------------------------------------------------------------------------
   Overview / Stepper strip
   ------------------------------------------------------------------------- */

.wt-overview {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-grey-50);
}

.wt-overview__steps {
  display: flex;
  gap: var(--sp-2);
}

.wt-overview__step {
  flex: 1;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  padding-top: var(--sp-1);
  border-top: 3px solid var(--color-grey-200);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.wt-overview__step--complete {
  color: var(--color-petrol);
  border-top-color: var(--color-petrol);
}

/* -------------------------------------------------------------------------
   Action Buttons
   ------------------------------------------------------------------------- */

.wt-actions {
  padding: var(--sp-2) var(--sp-3);
  border-top: 1px solid var(--color-border);
  background-color: var(--color-white);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  position: sticky;
  bottom: 0;
}

/* -------------------------------------------------------------------------
   Mobile drawer machinery — hidden by default; the mobile layout below
   adopts the cubicle reference's INLINE STACKED pattern (no off-canvas
   drawer), so the toggle, backdrop and close button stay out of the way.
   ------------------------------------------------------------------------- */

.wt-sidebar-toggle {
  display: none;
}

.wt-sidebar-backdrop {
  display: none;
}

/* =========================================================================
   MOBILE / TABLET — below 1024px
   Stacked layout mirroring the cubicle configurator: the page itself
   scrolls, the drawing is capped to half the viewport, and the sidebar
   flows inline beneath it so every control is reached by scrolling — no
   drawer, no backdrop, no scroll-lock. (See css/configurator.css.)
   ========================================================================= */

@media (max-width: 1023px) {
  /* Let the document scroll; undo any desktop pane locking. */
  .wt-page {
    min-height: auto;
    overflow: visible;
  }

  .wt-configurator {
    grid-template-columns: minmax(0, 1fr);
  }

  /* On phones the drawing must fill the FULL available width and stay
     legible — never the thin centred column that a short height cap +
     "meet" letterboxing produced (the trough viewBox is near-square, so a
     short box letterboxes it narrow). Drop the height cap and give the SVG
     a tall, fixed, width-driven box so WIDTH governs and the drawing spans
     the column. If that makes the page tall it just scrolls (this whole
     layout is the inline-scroll stack). Tighter top band for the toggle. */
  .wt-viewport {
    min-height: 0;
    max-height: none;
    padding-top: calc(var(--sp-3) + 52px);
  }

  .wt-viewport svg {
    width: 100%;
    height: 120vw;
    flex: 0 0 auto;
    min-height: 0;
    max-height: 80vh;
  }

  /* Sidebar flows in the normal document flow below the drawing. */
  .wt-sidebar {
    position: static;
    transform: none;
    visibility: visible;
    border-left: none;
    border-top: 1px solid var(--color-grey-100);
    max-width: none;
    overflow: visible;
    box-shadow: none;
  }

  /* Tabs no longer stick to a scrolling drawer body; the page scrolls. */
  .wt-tabs {
    position: static;
  }

  /* Actions flow inline rather than pinning to a fixed drawer bottom. */
  .wt-actions {
    position: static;
  }

  /* Inline stack needs none of the drawer chrome. */
  .wt-sidebar__close {
    display: none;
  }

  .wt-sidebar-backdrop {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wt-sidebar {
    transition: none;
  }
}
