/* TwelveTone application styles.
 *
 * Layout uses CSS logical properties throughout (margin-inline, padding-inline,
 * inset-inline, text-align: start) rather than left/right, so the Arabic RTL
 * layout mirrors automatically without a second stylesheet.
 *
 * Every colour is a theme token from themes.css. No hardcoded hex values below
 * the brand logo, which is deliberately fixed - a logo that restyles per theme
 * stops being a logo.
 */

:root {
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Inter",
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
  --max-w: 1120px;
  --radius: 14px;
}

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

/* The `hidden` attribute must beat any display rule a component sets, or an
   element that sets `display: flex` (the mobile nav drawer, for one) stays
   visible while claiming to be hidden. Without this the drawer is permanently
   open on small screens. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  line-height: 1.5;
  /* Keep content clear of the notch in the mobile shells. */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

a {
  color: inherit;
}

.flex-1 {
  flex: 1;
}

.container-page {
  width: 100%;
  max-width: var(--max-w);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

/* --- Typography ------------------------------------------------------- */

.h1 {
  font-size: clamp(1.9rem, 1.3rem + 2.4vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 1rem;
}

.h2 {
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
}

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

.eyebrow {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  /* Accent as text, so the contrast-checked variant rather than the raw brand
     colour - see the --accent-text note in themes.css. */
  color: var(--accent-text);
  margin: 0 0 0.75rem;
}

.prose p {
  color: var(--fg-muted);
  line-height: 1.7;
  margin-block-end: 1rem;
}

.prose h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-block: 2rem 0.75rem;
}

.prose ul {
  color: var(--fg-muted);
  line-height: 1.7;
  padding-inline-start: 1.5rem;
}

/* --- Components ------------------------------------------------------- */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 10px;
  padding: 0.625rem 1.1rem;
  font-weight: 600;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  /* 44px minimum touch target for the mobile shells. */
  min-height: 44px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}

.btn-primary:hover {
  filter: brightness(0.93);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--fg);
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.input {
  width: 100%;
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.625rem 0.85rem;
  min-height: 44px;
  font-family: inherit;
  /* 16px stops iOS Safari zooming the page on focus. */
  font-size: 1rem;
}

.input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg-muted);
  margin: 0 0 0.35rem;
}

.alert {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-block-end: 0.75rem;
  background: var(--bg-elevated);
}

.alert-error {
  border-color: var(--danger);
}

.alert-success {
  border-color: var(--success);
}

.notice {
  border: 1px solid var(--warning);
  border-radius: 10px;
  padding: 1rem;
  background: var(--bg-elevated);
  font-size: 0.9rem;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-fg);
  padding: 0.75rem 1rem;
}

.skip-link:focus {
  inset-inline-start: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Header ----------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-block-end: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4rem;
}

.logo-link {
  display: flex;
  flex-shrink: 0;
}

.primary-nav {
  display: none;
  align-items: center;
  gap: 0.25rem;
}

.primary-nav a {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.primary-nav a:hover {
  opacity: 0.7;
}

.header-actions {
  display: none;
  align-items: center;
  gap: 0.5rem;
}

.nav-toggle {
  padding: 0.5rem 0.7rem;
}

.mobile-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
  border-block-start: 1px solid var(--border);
  background: var(--bg-elevated);
}

.mobile-nav a {
  padding: 0.75rem;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 500;
}

@media (min-width: 900px) {
  .primary-nav,
  .header-actions {
    display: flex;
  }

  .nav-toggle,
  .mobile-nav {
    display: none;
  }
}

/* --- Footer ----------------------------------------------------------- */

.site-footer {
  margin-block-start: 4rem;
  border-block-start: 1px solid var(--border);
  padding-block: 2.5rem;
}

.footer-grid {
  display: grid;
  gap: 2rem;
}

@media (min-width: 800px) {
  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.footer-blurb {
  max-width: 32ch;
  font-size: 0.875rem;
  line-height: 1.6;
  margin-block-start: 0.75rem;
}

.ams-logo-fallback {
  font-weight: 600;
  margin: 0;
}

.footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.footer-nav a {
  text-decoration: none;
}

.footer-nav a:hover {
  opacity: 0.7;
}

.footer-switchers {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.theme-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
}

.theme-chip.is-active {
  border-color: var(--accent);
  border-width: 2px;
}

.theme-dot {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.language-switcher .input {
  max-width: 220px;
}

.footer-legal {
  margin-block-start: 2.5rem;
  padding-block-start: 1.5rem;
  border-block-start: 1px solid var(--border);
  font-size: 0.875rem;
}

/* --- Grids and swatches ----------------------------------------------- */

.grid {
  display: grid;
  gap: 1.25rem;
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, 1fr); }

@media (min-width: 700px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.sidebar-layout {
  display: grid;
  gap: 2.5rem;
}

@media (min-width: 1000px) {
  .sidebar-layout {
    grid-template-columns: 1fr 340px;
  }
}

.swatch {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 84px;
  padding: 1.5rem 0.65rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: inherit;
  text-align: start;
  cursor: pointer;
  width: 100%;
}

.swatch-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.swatch-hex {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.625rem;
  opacity: 0.85;
}

.swatch.is-copied .swatch-hex::after {
  content: " ✓";
}

.palette-strip {
  display: flex;
  height: 4rem;
  overflow: hidden;
  border-start-start-radius: var(--radius);
  border-start-end-radius: var(--radius);
}

.palette-strip span {
  flex: 1;
}

.season-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* --- Meters ----------------------------------------------------------- */

.axis-track {
  position: relative;
  height: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.axis-marker {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 1.25rem;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--fg);
  box-shadow: 0 0 0 2px var(--bg);
}

.meter-track {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--muted-surface);
  overflow: hidden;
}

/* Primary into secondary. Purely decorative - every meter states its value in
   text as well - but it is what makes two brown themes tell themselves apart. */
.meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
}

/* --- Outfits ---------------------------------------------------------- */

.outfit-bar {
  display: flex;
  height: 7rem;
}

.outfit-block {
  display: flex;
  align-items: flex-end;
  padding: 0.5rem;
  font-size: 0.625rem;
  font-weight: 600;
}

.chip {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-fg);
  font-size: 0.75rem;
  font-weight: 600;
}

/* --- Quiz ------------------------------------------------------------- */

.quiz-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
}

.quiz-option:has(input:checked) {
  border-color: var(--accent);
  border-width: 2px;
  padding: calc(1rem - 1px);
}

.quiz-option input {
  accent-color: var(--accent);
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.quiz-swatches {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.quiz-swatches span {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.progress-track {
  height: 0.375rem;
  border-radius: 999px;
  background: var(--muted-surface);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--secondary));
}

/* --- Tables ----------------------------------------------------------- */

.table-wrap {
  /* Wide tables scroll inside their own container so the page body never
     scrolls horizontally on mobile. */
  overflow-x: auto;
}

table.data {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.data th {
  text-align: start;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg);
}

table.data td {
  padding: 0.75rem 1rem;
  border-block-start: 1px solid var(--border);
}

/* --- Utilities -------------------------------------------------------- */

.stack > * + * { margin-block-start: 1rem; }
.section { padding-block: 3.5rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* ===========================================================================
 * Outfit Studio
 *
 * Logical properties throughout, so the whole widget mirrors under Arabic
 * without a second stylesheet. Every colour is a theme token; the only literal
 * colours are the garment fills, which come from state.
 * ======================================================================== */

.studio-head {
  max-width: 46rem;
  margin-block-end: 2rem;
}

.studio-lead {
  line-height: 1.7;
  margin: 0;
}

.studio-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 900px) {
  .studio-grid {
    /* The figure is fixed-ish; the controls take the slack. */
    grid-template-columns: minmax(300px, 400px) 1fr;
    align-items: start;
  }
}

/* --- Segmented control (Men / Women / Kids) ------------------------------ */

.seg {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elevated);
  margin-block-end: 0.75rem;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
}

.seg-btn.is-active {
  background: var(--accent);
  color: var(--accent-fg);
}

/* --- Preset chips -------------------------------------------------------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-block-end: 1rem;
}

/* Named apart from .chip on purpose. This is a button; .chip further up is the
   solid accent pill the result and outfit pages use as a label, and a second
   rule with the same name silently repainted those as outline buttons. */
.preset-chip {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--fg-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  min-height: 32px;
}

.preset-chip.is-active {
  border-color: var(--accent);
  color: var(--fg);
}

/* --- The figure ---------------------------------------------------------- */

.figure-wrap {
  display: flex;
  justify-content: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.mq-svg {
  width: 100%;
  max-width: 300px;
  height: auto;
}

/* Skin and outline read against any of the six themes because they are drawn
   from tokens rather than fixed greys. */
.mq-skin {
  fill: color-mix(in srgb, var(--fg-muted) 34%, var(--bg-elevated));
}

.mq-garment {
  cursor: pointer;
  stroke: color-mix(in srgb, var(--fg) 45%, transparent);
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: filter 120ms ease;
}

.mq-garment:hover {
  filter: brightness(1.06);
}

.mq-garment.is-selected {
  stroke: var(--accent);
  stroke-width: 3;
}

.mq-garment:focus-visible {
  outline: none;
  stroke: var(--accent);
  stroke-width: 3;
}

.mq-detail {
  fill: none;
  stroke: color-mix(in srgb, var(--fg) 30%, transparent);
  stroke-width: 1.2;
}

.studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-block-start: 1rem;
}

.studio-actions .btn {
  flex: 1 1 auto;
  font-size: 0.8125rem;
  padding-inline: 0.75rem;
}

/* --- Control panel ------------------------------------------------------- */

.studio-panel {
  display: grid;
  gap: 1.25rem;
}

.panel-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  padding: 1rem;
}

.panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-muted);
}

.garment-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.garment-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
}

.garment-tab.is-active {
  border-color: var(--accent);
  border-width: 2px;
  padding: calc(0.4rem - 1px) calc(0.7rem - 1px);
}

.garment-dot {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* --- Colour reading ------------------------------------------------------ */

.reading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-block-end: 0.75rem;
}

.reading-chip {
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border);
}

.reading-meta {
  font-size: 0.75rem;
  color: var(--fg-muted);
}

/* --- Swatch grid --------------------------------------------------------- */

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
  gap: 5px;
  margin-block-end: 1rem;
}

.swatch-btn {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  /* 30px is below the 44px touch guidance, but these are a dense palette grid
     where size would defeat the purpose; the custom picker below is the
     accessible path to any colour. */
  min-width: 30px;
}

.swatch-btn.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.custom-inputs {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.custom-inputs input[type="color"] {
  inline-size: 3rem;
  block-size: 2.75rem;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
}

.custom-inputs .input {
  flex: 1;
}

/* --- Recommendations ----------------------------------------------------- */

.recommendations {
  display: grid;
  gap: 1rem;
  margin-block-start: 1rem;
}

.rec-group {
  border-block-start: 1px solid var(--border);
  padding-block-start: 0.75rem;
}

.rec-group:first-child {
  border-block-start: 0;
  padding-block-start: 0;
}

.rec-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

.rec-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.rec-swatch {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
}

.rec-swatch:hover {
  filter: brightness(1.08);
}

.rec-targets {
  margin-block-start: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.link-btn {
  border: 0;
  background: none;
  color: var(--accent-text);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  text-decoration: underline;
}

.link-btn[aria-pressed="true"] {
  text-decoration: none;
  /* The theme's own accent-light tint rather than a mix computed at render
     time: it is the token the palette defines for exactly this. */
  background: var(--muted-surface);
  border-radius: 5px;
}

/* --- AMS logo, light/dark variants ---------------------------------------
 * The supplied mark has dark navy lettering, which disappears on the Midnight
 * and Graphite themes. Rather than tint it - a logo should not be recoloured -
 * the white-lettering variant is swapped in for those two themes.
 */

.ams-logo {
  /* The wordmark carries "ADVANCED MANAGEMENT SOLUTIONS" as a second line, which
     is unreadable much below this; the file is 800x300, so width follows. */
  height: 44px;
  width: auto;
}

/* Which wordmark shows is a property of the palette, not a list of theme names
   for app.css to keep in step with. themes.css sets these two tokens; a dark
   palette added later flips them there and nothing here changes. */
.ams-logo-light {
  display: var(--ams-logo-light-display);
}

.ams-logo-dark {
  display: var(--ams-logo-dark-display);
}
