/* 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;
}

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;
  color: var(--accent);
  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(--border);
  overflow: hidden;
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* --- 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(--border);
  overflow: hidden;
}

.progress-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* --- 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%; }
