/* ============================================================
   ÜRG GRÜRG — stile del sito.
   Ordine: base → lettere ritagliate → porta → app (barra, pannelli,
   foglio, adesivo, tab) → movimento → desktop.
   ============================================================ */

/* ---------- BASE ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper) url("../assets/paper.svg");
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  caret-color: var(--magenta);
}

::selection { background: var(--yellow); color: var(--ink); }

:focus-visible { outline: 3px solid var(--magenta); outline-offset: 3px; }

[hidden] { display: none !important; }

button { font: inherit; color: inherit; cursor: pointer; }

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

html { scrollbar-color: var(--ink) var(--paper-2); }

/* ---------- LETTERE RITAGLIATE (ransom note) ----------
   Ogni lettera è un pezzetto di carta (::before) ritagliato con le forbici.
   Le dieresi sono due bollini magenta, con l'anello nero fuori registro. */
.rn {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: inherit;
  align-items: flex-end;
  gap: 0.12em 0.3em;
  margin: 0;
  font-size: var(--rn-size, 34px);
  line-height: 1;
  font-weight: 400;
  text-decoration: none;
}
.rn[data-size="xl"] { --rn-size: clamp(60px, 19vw, 112px); }
.rn[data-size="md"] { --rn-size: 34px; }
.rn[data-size="sm"] { --rn-size: 27px; }

.rn__word { display: inline-flex; gap: 0.04em; white-space: nowrap; }

.rn__l {
  position: relative;
  isolation: isolate;
  display: inline-block;
  padding: 0.07em 0.11em 0.03em;
  font-size: calc(1em * var(--k, 1));
  transform: translateY(var(--y, 0)) rotate(var(--r, 0deg));
  text-transform: uppercase;
}
.rn__l::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--bg);
  clip-path: var(--cut);
}

/* 6 "giornali" diversi */
.rn__l.v0 { --bg: var(--ink); color: var(--paper); font-family: "Anton", sans-serif; }
.rn__l.v1 { --bg: #f7f7f5; font-family: "Bodoni Moda", serif; font-style: italic; font-weight: 900; text-transform: none; }
.rn__l.v2 { --bg: var(--yellow); font-family: "Alfa Slab One", serif; }
.rn__l.v3 { --bg: var(--magenta); font-family: "Archivo", sans-serif; font-weight: 900; font-stretch: 125%; }
.rn__l.v4 { --bg: radial-gradient(rgb(20 19 18 / 0.5) 1px, transparent 1.3px) 0 0 / 5px 5px, #e3e4e1; font-family: "Courier Prime", monospace; font-weight: 700; }
.rn__l.v5 { --bg: #f7f7f5; font-family: "Anton", sans-serif; }

/* tagli di forbice: pochi angoli, mai arrotondati */
.cut-a { --cut: polygon(0 4%, 97% 0, 100% 93%, 3% 100%); }
.cut-b { --cut: polygon(4% 0, 100% 6%, 96% 100%, 0 95%); }
.cut-c { --cut: polygon(0 0, 100% 3%, 98% 97%, 6% 100%, 0 70%); }

/* la dieresi */
.rn__uml {
  position: absolute;
  left: 50%;
  top: -0.27em;
  display: flex;
  gap: 0.1em;
  transform: translateX(-50%) rotate(-4deg);
  pointer-events: none;
}
.rn__uml i {
  position: relative;
  width: 0.34em;
  height: 0.34em;
  border-radius: 50%;
  background: var(--magenta);
}
.rn__uml i:last-child { transform: translateY(-0.04em) scale(1.08); }
.rn__uml i::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 0.045em solid var(--uml-ring, var(--ink));
  translate: var(--misreg-x) var(--misreg-y);
}
.rn--dark { --uml-ring: var(--paper); }
.rn__l:has(.rn__uml) { margin-top: 0.3em; }

/* ---------- PORTA (scelta del nome) ---------- */
.porta {
  min-height: 100dvh;
  max-width: 520px;
  margin: 0 auto;
  padding: calc(var(--s-7) + env(safe-area-inset-top)) var(--s-4) var(--s-7);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}
.porta__logo { justify-content: center; }

.porta__ask {
  margin: var(--s-7) 0 var(--s-4);
  font-size: 30px;
  font-weight: 900;
  font-stretch: 75%;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1;
}

.porta__names {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
  display: grid;
  gap: var(--s-3);
}

.name-slip {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 68px;
  padding: var(--s-3) var(--s-4);
  border: 0;
  background: none;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  text-align: left;
  font-size: 30px;
  font-weight: 900;
  font-stretch: 70%;
  text-transform: uppercase;
  line-height: 1;
  transform: rotate(var(--r, 0deg));
  transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.name-slip::before {                    /* il foglietto */
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: #f7f7f5;
  clip-path: polygon(0 3%, 99% 0, 100% 96%, 1% 100%);
  transition: background-color 120ms ease;
}
.name-slip::after {                     /* ombra a retino */
  content: "";
  position: absolute; inset: 0; z-index: -2;
  background: var(--halftone);
  opacity: 0.55;
  translate: 5px 6px;
}
.name-slip__initial {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  background: var(--ink);
  color: var(--paper);
  font-size: 26px;
  font-stretch: 100%;
}
.name-slip:active { transform: rotate(var(--r, 0deg)) scale(0.97); }
@media (hover: hover) and (pointer: fine) {
  .name-slip:hover::before { background: var(--yellow); }
}
.name-slip.is-picked::before { background: var(--yellow); }

/* ---------- APP ---------- */
.app { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--s-4) 0;
  background: var(--ink);
}
.topbar__logo { flex: none; flex-wrap: nowrap; padding-top: 6px; }

.me-chip {
  min-width: 0;
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 40px;
  padding: 0 10px;
  border: 2px solid var(--paper);
  background: transparent;
  color: var(--paper);
  font-size: 15px;
  font-weight: 800;
  font-stretch: 62%;                   /* stretto: anche PUSILLANIME ci sta intero */
  text-transform: uppercase;
  letter-spacing: 0.02em;
  transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
.me-chip:active { transform: scale(0.96); }

.panels { padding: var(--s-5) var(--s-4) var(--s-7); }

.panel { display: none; }
.panel.is-active { display: block; }

.panel__title { margin-left: 2px; }
.panel__lede {
  margin: var(--s-2) 0 var(--s-5);
  color: var(--ink-soft);
  font-size: 16px;
}

/* il foglio: la scaletta attaccata al muro col nastro */
.sheet {
  position: relative;
  isolation: isolate;
  min-height: 220px;
  transform: rotate(-0.5deg);
}
.sheet--flyer { transform: rotate(0.4deg); }
.sheet::before {                        /* la carta */
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: #f7f7f5 url("../assets/paper.svg");
}
.sheet::after {                         /* ombra a retino, sotto la carta */
  content: "";
  position: absolute; inset: 0; z-index: -2;
  background: var(--halftone);
  opacity: 0.5;
  translate: 6px 7px;
}
.tape {                                 /* nastro adesivo */
  position: absolute;
  z-index: 1;
  top: -13px;
  left: 50%;
  width: 104px;
  height: 28px;
  background: var(--tape);
  translate: -50% 0;
  rotate: -3deg;
  clip-path: polygon(0 8%, 6% 0, 100% 4%, 95% 50%, 100% 100%, 3% 94%);
}
.sheet--flyer .tape { left: auto; right: 18px; translate: 0 0; rotate: 4deg; }

.sheet__empty { padding: var(--s-7) var(--s-5) var(--s-6); }
.sheet__empty p { margin: 0; color: var(--ink-soft); }
.sheet__empty-big {
  margin-bottom: var(--s-2) !important;
  color: var(--ink) !important;
  font-size: 30px;
  font-weight: 900;
  font-stretch: 70%;
  text-transform: uppercase;
  line-height: 1;
}

/* l'adesivo "+" per proporre un brano */
.sticker {
  position: fixed;
  right: var(--s-4);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + var(--s-4));
  z-index: 25;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: 3px solid var(--ink);
  background: var(--magenta);
  rotate: -6deg;
  transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1);
}
body[data-tab="jam"] .sticker { display: none; }   /* sul telefono l'adesivo serve solo in Brani */
.sticker svg { width: 34px; height: 34px; fill: none; stroke: var(--ink); stroke-width: 3.5; stroke-linecap: square; }
.sticker:active { transform: scale(0.94); }

/* barra delle tab in basso */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: 1fr 1fr;
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--ink);
}
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  color: var(--paper);
  text-decoration: none;
  font-size: 15px;
  font-weight: 800;
  font-stretch: 80%;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: square; }
.tab[aria-current="page"] {
  background: var(--paper);
  color: var(--ink);
  clip-path: polygon(0 9px, 100% 0, 100% 100%, 0 100%);
}

/* ---------- MOVIMENTO ----------
   "Slap": il foglietto viene sbattuto sul muro in 3 fotogrammi,
   con il contorno che trema. Solo per stati e conferme. */
@keyframes slap {
  0%     { transform: scale(1.1) rotate(-4deg); animation-timing-function: steps(1, end); }
  33.3%  { transform: scale(0.97) rotate(1.8deg); animation-timing-function: steps(1, end); }
  66.6%  { transform: scale(1.01) rotate(-0.6deg); animation-timing-function: steps(1, end); }
  100%   { transform: rotate(var(--r, 0deg)); }
}
@keyframes boil {
  0%     { filter: url(#boil-0); animation-timing-function: steps(1, end); }
  33.3%  { filter: url(#boil-1); animation-timing-function: steps(1, end); }
  66.6%  { filter: url(#boil-2); animation-timing-function: steps(1, end); }
  100%   { filter: none; }
}
.is-slapping {
  animation:
    slap calc(var(--frame) * 3) both,
    boil calc(var(--frame) * 3) both;
}

@media (prefers-reduced-motion: reduce) {
  .is-slapping { animation: none; }
  .name-slip, .me-chip, .sticker { transition: none; }
}

/* ---------- DESKTOP: le due sezioni affiancate ---------- */
@media (min-width: 960px) {
  .app { padding-bottom: 0; }
  .tabs { display: none; }
  .topbar { padding-inline: max(var(--s-6), calc((100vw - 1280px) / 2 + var(--s-6))); min-height: 72px; }
  .topbar__logo.rn { --rn-size: 34px; }
  .panels {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: var(--s-7);
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--s-6) var(--s-6) var(--s-7);
  }
  .panel { display: block; }
  /* su desktop l'adesivo sta accanto al titolo BRANI, non sopra il calendario */
  .view[data-view="list"] { position: relative; }
  .sticker,
  body[data-tab="jam"] .sticker { display: grid; position: absolute; top: 0; right: 0; bottom: auto; z-index: 10; width: 72px; height: 72px; }  /* sotto la barra nera quando scorri */
}

/* ---------- PORTA: parola d'ordine ---------- */
.porta__pass { display: grid; gap: var(--s-3); width: 100%; text-align: left; }
.porta__pass .porta__ask { display: block; margin-bottom: 0; text-align: center; }
.porta__pass input { min-height: 60px; font-size: 20px; text-align: center; letter-spacing: 0.08em; }
.porta__error { min-height: 1.45em; margin: 0; font-weight: 700; text-align: center; }
.porta__error:not(:empty) { justify-self: center; padding: 2px 8px; background: var(--magenta); }
#porta-who { width: 100%; }

/* ---------- Avvisi ---------- */
.toast {
  position: fixed;
  left: var(--s-4);
  right: var(--s-4);
  bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + var(--s-4));
  z-index: 40;
  max-width: 480px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-4);
  background: var(--ink);
  color: var(--paper);
  font-weight: 700;
  rotate: -0.6deg;
}
@media (min-width: 960px) { .toast { bottom: var(--s-6); } }
