/* CLH.DO/TEES : le moteur de punchline.shop (bande, tees en SVG, fiche), aux couleurs de la décennie choisie */
:root {
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-io: cubic-bezier(0.76, 0, 0.24, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --ghost: rgb(var(--t-fg-rgb) / 0.055);
  --soft: rgb(var(--t-fg-rgb) / 0.06);
  --display: var(--t-font-display);
  --mono: var(--t-font-mono);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--t-bg);
  color: var(--t-text);
  font: 500 1rem/1.5 var(--t-font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
  overscroll-behavior: none;
}
button, a { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--t-acc1); outline-offset: 3px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 0.6875rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; }

.grain {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  opacity: var(--t-grain);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ——— Shell ——— */
.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: var(--safe-t);
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 1rem;
  padding: 1rem var(--gutter) 0;
}
.logo {
  font: var(--t-display-weight) 1.75rem/0.85 var(--display);
  letter-spacing: var(--t-display-spacing);
  color: var(--t-fg);
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}
.logo span { color: var(--t-acc1-ink); }
.tagline { margin: 0.15rem 0 0; color: var(--t-dim); line-height: 1.35; }
.tagline b { color: var(--t-fg); font-weight: 700; font-variant-numeric: tabular-nums; }
.counter { margin: 0.15rem 0 0; display: flex; align-items: center; gap: 0.6rem; color: var(--t-dim); white-space: nowrap; }
.counter a { color: var(--t-acc1-ink); text-decoration: underline; text-underline-offset: 3px; }
.counter b { color: var(--t-fg); font-weight: 700; font-variant-numeric: tabular-nums; }

/* La puce : une couleur pour tous les tees, ou chacun la sienne (le disque arc-en-ciel) */
.chip, .colors__list button {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgb(var(--t-fg-rgb) / 0.35);
  background: var(--fixed, conic-gradient(#111111, #f2efe7, #1f2a44, #6e1f22, #e5d6b0, #3f4a30, #111111));
}
.chip { position: relative; }
.chip::after { content: ""; position: absolute; inset: -0.75rem; } /* zone de toucher plus large que la puce */
.colors {
  position: fixed;
  inset: calc(3rem + var(--safe-t)) var(--gutter) auto auto;
  margin: 0;
  padding: 0.9rem;
  width: 13rem;
  border: 1px solid var(--t-line);
  border-radius: max(var(--t-radius), 2px);
  background: var(--t-surface);
  color: var(--t-dim);
}
.colors p { margin: 0 0 0.7rem; }
.colors__list { display: grid; grid-template-columns: repeat(5, 1.75rem); gap: 0.6rem; margin-bottom: 0.8rem; }
.colors__list button { width: 1.75rem; height: 1.75rem; }
.colors__list button[aria-pressed="true"] { outline: 2px solid var(--t-acc1); outline-offset: 2px; }
.colors__free { color: var(--t-acc1-ink); text-decoration: underline; text-underline-offset: 3px; }
.colors__free[aria-pressed="true"] { color: var(--t-dim); text-decoration: none; }
.fixed .tee { color: var(--fixed) !important; }

/* ——— Stage ——— */
.stage {
  position: relative;
  min-height: 0;
  display: grid;
  align-items: center;
  isolation: isolate;
}

.marquee {
  position: absolute;
  inset: 50% 0 auto;
  translate: 0 -58%;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}
.marquee span {
  display: inline-block;
  white-space: nowrap;
  font: var(--t-display-weight) clamp(9rem, 36vh, 26rem)/0.8 var(--display);
  color: var(--ghost);
  text-transform: uppercase;
  animation: marquee 60s linear infinite;
  transition: opacity 0.6s var(--ease);
}
.marquee.is-swapping span { opacity: 0; }
@keyframes marquee { to { transform: translateX(-50%); } }

.rail {
  list-style: none;
  margin: 0;
  padding: 0.5rem 9vw;
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  min-height: 0;
  height: 100%;
  align-items: center;
  outline: none;
}
.rail::-webkit-scrollbar { display: none; }

.card {
  flex: 0 0 82vw;
  max-width: 26rem;
  scroll-snap-align: center;
  height: 100%;
  display: grid;
  align-items: center;
}
.card__hit {
  width: 100%;
  max-height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.25rem;
  text-align: left;
}
.card__art {
  display: grid;
  place-items: center;
  min-height: 0;
  transition: transform 0.6s var(--ease), opacity 0.6s var(--ease);
  transform: scale(0.88);
  opacity: 0.55;
}
.card.is-active .card__art { transform: none; opacity: 1; }
.card__meta {
  position: relative;
  z-index: 1;
  margin-top: 0.75rem;
  display: flex;
  align-items: baseline;
  padding: 0 0.5rem;
  justify-content: center;
  gap: 0.6rem;
  min-width: 0;
  transition: opacity 0.4s var(--ease);
  opacity: 0;
}
.card.is-active .card__meta { opacity: 1; }
.card__label {
  font: var(--t-display-weight) 1.5rem/1 var(--display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--t-fg);
  text-align: center;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.tee {
  display: block;
  width: 100%;
  height: 100%;
  max-height: calc(100dvh - 200px);
  aspect-ratio: 400 / 440;
  overflow: visible;
  filter: drop-shadow(0 1.4rem 1.6rem rgb(0 0 0 / 0.35)) drop-shadow(0 0.15rem 0.3rem rgb(0 0 0 / 0.2));
}
/* Le carré derrière le tee, seulement quand le tee a la couleur du fond (classe .on-bg posée par tees.js) :
   chaque décennie a le sien, d'où des carrés différents d'une décennie à l'autre */
.card__art, .sheet__art { position: relative; isolation: isolate; }
.on-bg::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: 50%;
  left: 50%;
  width: 90%;
  aspect-ratio: 1;
  translate: -50% -50%;
  pointer-events: none;
  /* 1990s, le défaut : papier, cadre acide, ombre dure rose, de travers.
     Le fond du carré doit trancher avec le tee (qui a la couleur de la page), jamais --t-surface */
  background: var(--t-paper);
  border: 3px solid var(--t-acc1);
  border-radius: var(--t-radius);
  box-shadow: 12px 12px 0 var(--t-acc2);
  rotate: -2deg;
}
.sheet__art.on-bg::before { width: min(26rem, 100%); }
/* 1960s : papier d'architecte, un trait d'encre et son double décalé, une trame */
[data-theme="archi"] .on-bg::before {
  border: 1px solid #111;
  box-shadow: 10px 10px 0 -1px var(--t-bg), 10px 10px 0 0 #111;
  background: #111 linear-gradient(rgb(255 255 255 / 0.09) 1px, transparent 1px) 0 0 / 100% 24px;
  rotate: none;
}
/* 1970s : moutarde, coins ronds, bord orange épais */
[data-theme="funk"] .on-bg::before {
  background: var(--t-acc1);
  border: 10px solid var(--t-acc2);
  border-radius: 2.5rem;
  box-shadow: none;
  rotate: 3deg;
}
/* Classics : rouge plein, filet crème */
[data-theme="classics"] .on-bg::before {
  background: var(--t-acc1);
  border: 0;
  box-shadow: inset 0 0 0 10px var(--t-acc1), inset 0 0 0 12px var(--t-acc2);
  rotate: none;
}
/* Terminal : cadre phosphore, lignes de balayage */
[data-theme="terminal"] .on-bg::before {
  background: rgb(var(--t-acc1-rgb) / 0.38) repeating-linear-gradient(0deg, rgb(0 0 0 / 0.25) 0 1px, transparent 1px 4px);
  border: 1px solid var(--t-acc1);
  box-shadow: 0 0 24px rgb(var(--t-acc1-rgb) / 0.45), inset 0 0 24px rgb(var(--t-acc1-rgb) / 0.2);
  rotate: none;
}
/* Tube : une carte rouge aux coins doux qui flotte */
[data-theme="tube"] .on-bg::before {
  background: var(--t-acc1);
  border: 0;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 18px 40px rgb(0 0 0 / 0.16);
  rotate: none;
}
/* Neo : jaune, gros trait noir, ombre dure */
[data-theme="neo"] .on-bg::before {
  background: var(--t-acc1);
  border: 3px solid #111;
  border-radius: 12px;
  box-shadow: 8px 8px 0 #111;
  rotate: -1.5deg;
}

.card__art .tee { width: 86%; } /* un peu moins large que la carte : il tient dans son carré */
.tee__print { opacity: 0; transition: opacity 0.35s var(--ease); }
.tee.is-loaded .tee__print { opacity: 1; }

/* ——— Dock (zone du pouce) : le lien vers la chanson, et le bouton ——— */
.dock {
  display: grid;
  gap: 0.625rem;
  padding: 0.25rem var(--gutter) calc(1rem + var(--safe-b));
  background: linear-gradient(to top, var(--t-bg) 70%, transparent);
}
.field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "kind arrow" "title arrow" "meta arrow";
  align-items: center;
  column-gap: 0.75rem;
  min-height: 3.75rem;
  padding: 0.55rem 0.9rem 0.6rem 1rem;
  background: var(--t-surface);
  border: 1px solid var(--t-line);
  border-radius: max(var(--t-radius), 2px);
  text-decoration: none;
  transition: border-color 0.25s var(--ease), translate 0.25s var(--ease);
}
.field__kind { grid-area: kind; color: var(--t-acc1-ink); font-size: 0.5625rem; }
.field__title {
  grid-area: title;
  color: var(--t-fg);
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.field__meta { grid-area: meta; color: var(--t-dim); font-size: 0.5625rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field__arrow { grid-area: arrow; width: 1.5rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; color: var(--t-fg); transition: translate 0.25s var(--ease); }
.field:focus-visible, .field:active { border-color: var(--t-acc1); }

.go {
  height: 3.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  border-radius: max(var(--t-radius), 2px);
  background: var(--t-acc1);
  color: var(--t-on-acc1);
  padding: 0 1rem;
  font: var(--t-display-weight) 1.5rem/1 var(--display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform 0.25s var(--spring), filter 0.2s;
}
.go:active { transform: scale(0.97); filter: brightness(0.9); }
.go__icon { flex-shrink: 0; width: 1.375rem; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.go[aria-busy="true"] .go__icon { animation: spin 0.8s var(--ease-io) infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* ——— La fiche ——— */
.sheet {
  width: 100%;
  max-width: 34rem;
  max-height: 100dvh;
  margin: auto auto 0;
  padding: 0;
  border: 0;
  border-radius: max(var(--t-radius), 1.25rem) max(var(--t-radius), 1.25rem) 0 0;
  background: var(--t-surface);
  color: var(--t-text);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet::backdrop { background: rgb(0 0 0 / 0.6); backdrop-filter: blur(6px); }
/* La fiche monte du bas seulement quand le tee ne s'y transporte pas (sans view transition) :
   une règle retirée après coup relancerait l'animation, d'où le doublon */
.sheet.rise[open] { animation: rise 0.55s var(--ease); }
.sheet.rise[open]::backdrop { animation: fade 0.4s var(--ease); }
@keyframes rise { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

.sheet__inner { position: relative; display: grid; padding: 1rem var(--gutter) calc(1.25rem + var(--safe-b)); }
.sheet__close {
  position: absolute; top: 0.75rem; right: 0.75rem; z-index: 1;
  width: 2.75rem; height: 2.75rem; display: grid; place-items: center;
  border-radius: 50%; background: var(--soft); color: var(--t-fg);
}
.sheet__close svg { width: 1.125rem; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.sheet__art { display: grid; place-items: center; padding: 1.5rem 0 0.5rem; }
.sheet__art .tee { width: min(100%, 24rem); max-height: 50dvh; }
.sheet__kicker { margin: 0.5rem 0 0; color: var(--t-acc2-ink); text-align: center; }
.sheet__title {
  margin: 0.25rem 0 1.25rem;
  font: var(--t-display-weight) clamp(2.25rem, 10vw, 3.25rem)/0.9 var(--display);
  color: var(--t-fg);
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: anywhere;
}
.sheet__actions { display: grid; gap: 0.5rem; }
.sheet__fine { margin: 0.75rem 0 0; color: var(--t-dim); text-align: center; font-size: 0.5625rem; }

.btn {
  height: 3.5rem;
  display: grid; place-items: center;
  border-radius: max(var(--t-radius), 2px);
  font-weight: 700;
  font-size: 1rem;
  text-decoration: none;
  transition: transform 0.25s var(--spring), filter 0.2s, background-color 0.2s;
}
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--t-acc1); color: var(--t-on-acc1); }
.btn--ghost { background: var(--soft); color: var(--t-fg); }

/* ——— Toast ——— */
.toast {
  position: fixed;
  top: calc(0.75rem + var(--safe-t));
  left: 50%;
  z-index: 10;
  margin: 0;
  padding: 0.6rem 1rem;
  border-radius: 2rem;
  background: var(--t-fg);
  color: var(--t-bg);
  font-size: 0.875rem;
  font-weight: 600;
  translate: -50% calc(-100% - 2rem - var(--safe-t));
  visibility: hidden;
  transition: translate 0.5s var(--ease), visibility 0s 0.5s;
  pointer-events: none;
}
.toast.is-on { translate: -50% 0; visibility: visible; transition: translate 0.5s var(--ease); }

/* ——— View transition : du tee de la bande à la fiche ——— */
::view-transition-group(tee) { animation-duration: 0.55s; animation-timing-function: var(--ease); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.35s; }

/* ——— Grands écrans : la bande montre plusieurs tees, celui du centre est le bon ——— */
@media (min-width: 56rem) {
  .rail { padding: 1rem calc(50vw - clamp(8rem, 11vw, 11rem)); gap: clamp(0.5rem, 1.5vw, 1.5rem); }
  .card { flex: 0 0 clamp(16rem, 22vw, 22rem); }
  .dock { grid-template-columns: minmax(0, 34rem) 15rem; justify-content: center; align-items: stretch; }
  .go { height: auto; min-height: 3.75rem; }
}
/* ——— Grands écrans en hauteur : le tee fait toute la hauteur moins 256px, sa largeur en découle ——— */
@media (min-height: 900px) {
  .rail { --card: min(calc((100dvh - 256px) * 400 / 440), 90vw); padding-inline: calc(50vw - var(--card) / 2); }
  .card { flex: 0 0 var(--card); max-width: none; }
  .tee { height: auto; max-height: calc(100dvh - 256px); }
}
@media (hover: hover) {
  .card__art { transition: transform 0.6s var(--ease), opacity 0.6s var(--ease), translate 0.5s var(--ease); }
  .card__hit:hover .card__art { translate: 0 -0.5rem; opacity: 1; }
  .field:hover { border-color: var(--t-acc1); }
  .field:hover .field__arrow { translate: 0.25rem 0; }
  .go:hover { filter: brightness(1.08); }
  .btn--primary:hover { filter: brightness(1.08); }
  .btn--ghost:hover { background: rgb(var(--t-fg-rgb) / 0.12); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
  .marquee span { animation: none; }
}
