:root {
  --bg: #faf8f4;
  --bg-elev: #ffffff;
  --ink: #0f1e3d;
  --ink-soft: #3a4561;
  --ink-muted: #6a7389;
  --rule: #e4ddcc;
  --accent: #c9423a;
  --score-1: #c9423a;
  --score-2: #e08b3a;
  --score-3: #d4b24c;
  --score-4: #4f8a5e;
  --disclaimer-bg: #ece7d8;

  --adn-blue: #2c4085;
  --gold: #d4b24c;
  --campaign-red: #c9423a;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
    "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue",
    Arial, sans-serif;

  --maxw: 680px;
  --radius: 4px;
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.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 {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
}

.brand__lockup {
  display: block;
  width: 220px;
  height: auto;
  max-width: 100%;
}

.brand__partner {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.brand__partner strong {
  color: var(--ink);
  letter-spacing: 0.14em;
}

/* ---------- Campagne « Mois de la santé mentale » mai 2026 ---------- */

.site-header__lockup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.campaign-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--disclaimer-bg);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  margin: 16px 0 0;
}

.campaign-pill__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.campaign-pill__text {
  display: inline;
}

.campaign-pill .ordinal {
  font-size: 0.65em;
  vertical-align: super;
  line-height: 0;
  margin: 0;
  padding: 0;
  text-transform: lowercase;
  letter-spacing: 0;
}

.campaign-pill + .hero-title {
  margin-top: 12px;
}

.campaign-note {
  background: #fff;
  border-left: 3px solid var(--adn-blue);
  padding: 14px 16px;
  border-radius: var(--radius);
  margin: 0 0 20px;
}

.campaign-note__title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.campaign-note__body {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.55;
}

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

.container {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px 24px 80px;
}

.screen {
  display: none;
}

[data-state="landing"] .screen--landing,
[data-state="processing"] .screen--processing,
[data-state="results"] .screen--results,
[data-state="error"] .screen--error,
[data-state="rate-limited"] .screen--rate-limited,
[data-state="campaign-over"] .screen--campaign-over {
  display: block;
}

/* ---------- Landing ---------- */

.hero-title {
  font-family: var(--serif);
  font-size: 40px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 32px 0 28px;
  text-wrap: balance;
}

.hero-title em {
  color: var(--accent);
  font-style: italic;
}

.analyze-form {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.analyze-form input[type="url"] {
  flex: 1 1 260px;
  min-width: 0;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.analyze-form input[type="url"]::placeholder {
  color: var(--ink-muted);
}

.analyze-form input[type="url"]:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 30, 61, 0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 22px;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease,
    border-color 0.15s ease;
}

.btn--primary {
  background: var(--ink);
  color: var(--bg);
}

.btn--primary:hover,
.btn--primary:focus-visible {
  background: var(--accent);
}

.btn--secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}

.btn--secondary:hover,
.btn--secondary:focus-visible {
  background: var(--ink);
  color: var(--bg);
}

.btn:focus-visible {
  outline: 3px solid rgba(201, 66, 58, 0.35);
  outline-offset: 2px;
}

.how-it-works {
  color: var(--ink-soft);
  font-size: 15px;
  max-width: 58ch;
}

/* ---------- Processing ---------- */

.screen--processing {
  text-align: center;
  padding-top: 64px;
}

.spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 24px;
  border-radius: 50%;
  border: 3px solid var(--rule);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.processing-title {
  font-family: var(--serif);
  font-size: 28px;
  margin: 0 0 6px;
}

.processing-hint {
  color: var(--ink-muted);
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 3s;
  }
}

/* ---------- Results ---------- */

.results-title {
  font-family: var(--serif);
  font-size: 32px;
  margin: 24px 0 20px;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.score-badge {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 2px;
  color: #fff;
  background: var(--ink-muted);
  font-family: var(--serif);
  padding-bottom: 4px;
}

.score-badge[data-score="1"] {
  background: var(--score-1);
}
.score-badge[data-score="2"] {
  background: var(--score-2);
}
.score-badge[data-score="3"] {
  background: var(--score-3);
  color: #3a2a00;
}
.score-badge[data-score="4"] {
  background: var(--score-4);
}

.score-badge__number {
  font-size: 42px;
  font-weight: 700;
  line-height: 1;
}

.score-badge__scale {
  font-size: 16px;
  opacity: 0.85;
}

.score-label__title {
  margin: 0 0 2px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
}

.score-label__caption {
  margin: 0;
  color: var(--ink-muted);
  font-size: 14px;
}

.rationale {
  margin: 0 0 24px;
}

.rationale__title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 10px;
  font-weight: 600;
}

.rationale__body {
  margin: 0;
  font-size: 18px;
  line-height: 1.6;
  color: var(--ink);
}

.recommendations {
  margin: 0 0 28px;
}

.recommendations__title {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.recommendations__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.rec-card__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.rec-card__link:hover,
.rec-card__link:focus-visible {
  border-color: var(--ink);
  background: #fff;
  outline: none;
}

.rec-card__handle {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 600;
}

.rec-card__cta {
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.transcript {
  margin: 0 0 28px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
}

.transcript summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  padding: 4px 0;
  list-style: none;
}

.transcript summary::-webkit-details-marker {
  display: none;
}

.transcript summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  color: var(--ink-muted);
  transition: transform 0.15s ease;
}

.transcript[open] summary::before {
  transform: rotate(90deg);
}

.transcript__body {
  margin: 12px 0 4px;
  color: var(--ink-soft);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.transcript__caption {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
  font-style: italic;
}

.transcript__section + .transcript__section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--rule);
}

.transcript__label {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.results-actions {
  margin: 8px 0 32px;
}

.disclaimer {
  background: var(--disclaimer-bg);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px;
  border-radius: var(--radius);
}

/* ---------- Error / Rate ---------- */

.screen--error,
.screen--rate-limited {
  text-align: center;
  padding-top: 56px;
}

.error-title {
  font-family: var(--serif);
  font-size: 30px;
  margin: 0 0 12px;
}

.error-message {
  color: var(--ink-soft);
  margin: 0 auto 24px;
  max-width: 48ch;
}

.rate-countdown {
  color: var(--ink-muted);
  font-size: 14px;
  margin: -12px auto 20px;
}

/* ---------- Auth (login / identifie) ---------- */

.site-header__actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 13px;
  font-weight: 600;
}

.lang-switch__link {
  color: var(--ink-muted);
  text-decoration: none;
  padding: 4px 6px;
  border-radius: var(--radius);
  transition: color 0.15s ease, background 0.15s ease;
}

.lang-switch__link:hover,
.lang-switch__link:focus-visible {
  color: var(--ink);
  background: var(--bg-elev);
  outline: none;
}

.lang-switch__link[aria-current="page"] {
  color: var(--ink);
  cursor: default;
}

.site-header__auth {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.site-header__auth:hover,
.site-header__auth:focus-visible {
  border-color: var(--ink);
  background: var(--bg-elev);
  outline: none;
}

.auth-card {
  max-width: 420px;
  margin: 32px auto 0;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.auth-card__title {
  font-family: var(--serif);
  font-size: 28px;
  margin: 0 0 20px;
}

.auth-card__hello {
  margin: 0 0 24px;
  color: var(--ink-soft);
  font-size: 16px;
}

.auth-card__hello #user-email {
  color: var(--ink);
  font-weight: 600;
}

.auth-card__switch {
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
  text-align: center;
}

.auth-card__switch a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-card__switch a:hover,
.auth-card__switch a:focus-visible {
  text-decoration: underline;
}

.auth-card__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-card__actions .btn {
  flex: 1 1 140px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-form__label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  margin-top: 12px;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(15, 30, 61, 0.12);
}

.auth-form__error {
  margin: 12px 0 0;
  color: var(--accent);
  font-size: 14px;
}

.auth-form__submit {
  margin-top: 20px;
}

.auth-form__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.site-footer {
  max-width: var(--maxw);
  width: 100%;
  margin: 0 auto;
  padding: 20px 24px 32px;
  color: var(--ink-muted);
  font-size: 12px;
  letter-spacing: 0.04em;
  border-top: 1px solid var(--rule);
}

.site-footer p {
  margin: 0;
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .site-header {
    padding: 24px 20px 12px;
  }

  .site-header__lockup-row {
    gap: 12px;
  }

  .brand__lockup {
    width: min(55vw, 180px);
  }

  .container {
    padding: 16px 20px 64px;
  }

  .hero-title {
    font-size: 30px;
    margin: 20px 0 22px;
  }

  .analyze-form {
    flex-direction: column;
  }

  .analyze-form input[type="url"],
  .btn {
    width: 100%;
  }

  .analyze-form input[type="url"] {
    flex: 0 0 auto;
    padding: 12px 14px;
    font-size: 15px;
  }

  .score-card {
    gap: 16px;
    padding: 16px;
  }

  .score-badge {
    width: 70px;
    height: 70px;
  }

  .score-badge__number {
    font-size: 34px;
  }

  .results-title {
    font-size: 26px;
  }

  .rationale__body {
    font-size: 16px;
  }
}

/* ---------- Discover screen (frontend/tiktoks) ---------- */

.tt-shell {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 24px 48px;
}

.tt-intro {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 15px;
}

/* One rounded, bordered card holding the control rail + results grid. */
.tt-discover {
  display: flex;
  height: 80vh;
  min-height: 520px;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

/* Left rail — does not scroll. */
.tt-rail {
  flex: 0 0 30%;
  min-width: 280px;
  padding: 24px;
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.tt-rail__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tt-rail__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--score-4);
}

.tt-rail__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tt-filter__label {
  margin: 0 0 12px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 600;
}

.tt-stars {
  display: flex;
  gap: 6px;
}

.tt-star {
  font-size: 34px;
  line-height: 1;
  background: none;
  border: none;
  padding: 2px 4px;
  cursor: pointer;
  color: var(--rule); /* empty star */
  transition: color 0.12s ease, transform 0.12s ease;
}

.tt-star.is-filled {
  color: var(--ink-muted); /* fallback fill before a score color applies */
}

/* Filled stars take the score color of the currently-painted value. */
.tt-stars[data-active="1"] .tt-star.is-filled {
  color: var(--score-1);
}
.tt-stars[data-active="2"] .tt-star.is-filled {
  color: var(--score-2);
}
.tt-stars[data-active="3"] .tt-star.is-filled {
  color: var(--score-3);
}
.tt-stars[data-active="4"] .tt-star.is-filled {
  color: var(--score-4);
}

.tt-star:hover {
  transform: scale(1.08);
}

.tt-star:focus-visible {
  outline: 3px solid rgba(201, 66, 58, 0.35);
  outline-offset: 2px;
  border-radius: var(--radius);
}

.tt-filter__caption {
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 14px;
}

/* Reserved slot so future filters drop in without re-laying-out the rail. */
.tt-reserved {
  margin-top: auto;
  padding: 16px;
  border: 1px dashed var(--rule);
  border-radius: var(--radius);
}

.tt-reserved__title {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Right panel — header strip + independently scrolling grid. */
.tt-results {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.tt-results__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}

.tt-pill {
  display: inline-flex;
  align-items: center;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 6px 12px;
  border-radius: 999px;
}

.tt-summary {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.tt-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px;
}

.tt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

/* 9:16 portrait card; the whole card links out to the TikTok. */
.tt-card {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--disclaimer-bg);
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tt-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(15, 30, 61, 0.15);
}

.tt-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Placeholder look: no thumbnail yet, or the cached cover 404'd. */
.tt-card--noimg {
  background: repeating-linear-gradient(
    135deg,
    var(--disclaimer-bg),
    var(--disclaimer-bg) 10px,
    var(--bg) 10px,
    var(--bg) 20px
  );
}

.tt-card--noimg .tt-card__img {
  display: none;
}

/* Score badge in the bottom-right corner; reuses .score-badge[data-score]. */
.tt-card__badge {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: auto;
  height: auto;
  min-width: 40px;
  border-radius: 999px;
  padding: 4px 10px;
  align-items: baseline;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.tt-card__badge .score-badge__number {
  font-size: 16px;
}

.tt-card__badge .score-badge__scale {
  font-size: 11px;
}

/* Skeleton tile while a page loads — don't blank the panel. */
.tt-card--skeleton {
  background: var(--disclaimer-bg);
  animation: tt-pulse 1.1s ease-in-out infinite;
}

@keyframes tt-pulse {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0.9;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tt-card--skeleton {
    animation: none;
  }
}

.tt-empty {
  padding: 40px 8px;
  color: var(--ink-muted);
  text-align: center;
}

.tt-error {
  padding: 32px 8px;
  text-align: center;
  color: var(--ink-soft);
}

.tt-loadmore {
  display: flex;
  justify-content: center;
  padding: 24px 0 8px;
}

/* An author `display` rule overrides the UA `[hidden]{display:none}`, so the
   `hidden` attribute alone wouldn't hide these — restore it explicitly. */
.tt-loadmore[hidden],
.tt-error[hidden],
.tt-empty[hidden] {
  display: none;
}

/* Stack the two panels vertically on narrow screens (controls on top). */
@media (max-width: 768px) {
  .tt-discover {
    flex-direction: column;
    height: auto;
  }

  .tt-rail {
    flex-basis: auto;
    border-right: none;
    border-bottom: 1px solid var(--rule);
    gap: 20px;
  }

  .tt-reserved {
    margin-top: 8px;
  }

  .tt-scroll {
    /* Cap the grid height so the page (not just the panel) scrolls naturally. */
    max-height: 70vh;
  }

  .tt-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
