@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,900&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --void: #05262d;
  --ink: #0a3a44;
  --ink-2: #0e4854;
  --well: #052a32;
  --line: #1d6a78;
  --dash: #2c8a98;
  --bone: #fff6e0;
  --mute: #a4d2cf;
  --amber: #ffc23d;
  --jade: #3ff0b8;
  --rust: #ff5a3c;
  --paper: #fdf3dc;
  --paper-ink: #17302f;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter Tight', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --r: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(80% 50% at 85% -5%, rgba(255,194,61,.26), transparent 62%),
    radial-gradient(70% 55% at 0% 100%, rgba(255,90,60,.2), transparent 62%),
    linear-gradient(170deg, #07444f 0%, var(--void) 62%);
  background-attachment: fixed;
  min-height: 100dvh;
  color: var(--bone);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

/* gli anelli di un orologio enorme, dietro a tutto */
body::before {
  content: '';
  position: fixed;
  width: 150vmax; height: 150vmax;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255,255,255,.035) 0 .5deg, transparent .5deg 6deg);
  -webkit-mask: radial-gradient(closest-side, transparent 62%, #000 63% 70%, transparent 71% 84%, #000 85% 88%, transparent 89%);
  mask: radial-gradient(closest-side, transparent 62%, #000 63% 70%, transparent 71% 84%, #000 85% 88%, transparent 89%);
  animation: clock 140s linear infinite;
  z-index: 0;
}
@keyframes clock { to { transform: translate(-50%, -50%) rotate(360deg); } }

.wrap { position: relative; z-index: 1; max-width: 1200px; margin: 0 auto; padding: 24px 18px 40px; }
.wrap.narrow { max-width: 560px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -.02em; margin: 0; }
h1 { font-size: clamp(32px, 7vw, 58px); font-weight: 900; }
.brandname { font-size: clamp(64px, 20vw, 118px); line-height: .9; margin: 8px 0 12px; color: var(--amber); text-shadow: 0 5px 0 #a25f06, 0 18px 40px rgba(255,194,61,.32); }
.heroline { position: relative; display: flex; justify-content: space-between; margin: 26px 8px 34px; }
.heroline::before { content: ''; position: absolute; left: 0; right: 0; top: 50%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--amber) 12% 88%, transparent); }
.heroline i { position: relative; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 4px var(--void), 0 0 0 6px var(--amber); }
.heroline i::after { content: attr(data-y); position: absolute; top: 24px; left: 50%; transform: translateX(-50%); font: 700 12px var(--mono); font-style: normal; color: var(--mute); }
.heroline i.q { background: var(--rust); animation: pulse 1.8s ease-in-out infinite; }
.heroline i.q::after { color: var(--rust); font-size: 18px; top: 22px; }
@keyframes pulse { 50% { transform: scale(1.35); } }
h2 { font-size: 22px; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--mute);
}

.year { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.card-surface {
  background: linear-gradient(170deg, rgba(14,72,84,.92) 0%, rgba(10,58,68,.92) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 22px 44px -28px #000;
}

.panel { composes: card-surface; }

button, .btn {
  font-family: var(--body);
  font-weight: 600;
  font-size: 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--bone);
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .12s ease, background .18s ease, border-color .18s ease;
}
button:hover { border-color: var(--amber); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.btn-primary { background: linear-gradient(180deg, #ffd25e, var(--amber)); color: #3a2200; border-color: transparent; font-family: var(--display); font-weight: 900; font-size: 17px; box-shadow: 0 4px 0 #a25f06, 0 14px 24px -12px rgba(255,194,61,.75); }
.btn-primary:hover { filter: brightness(1.07); border-color: transparent; }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #a25f06; }
.btn-ghost { background: transparent; }

input, select {
  font-family: var(--body);
  font-size: 16px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--well);
  color: var(--bone);
}
input::placeholder { color: #79a9a8; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 13px; color: var(--mute); margin-bottom: 6px; }

.row { display: flex; gap: 10px; align-items: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.muted { color: var(--mute); font-size: 13px; }
.error { color: var(--rust); font-size: 14px; min-height: 20px; }

/* --- Carte -------------------------------------------------------------- */
.gcard {
  position: relative;
  flex: 0 0 auto;
  width: 150px;
  aspect-ratio: 5 / 7;
  perspective: 900px;
  border: 0;
  padding: 0;
  background: none;
  border-radius: 13px;
}
.gcard.sm { width: 104px; }
.gcard.lg { width: 178px; }
.gcard.auto { width: 100%; }

.cardinner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.3,.9,.3,1);
  border-radius: 13px;
}
.cardinner.flipped { transform: rotateY(180deg); }
.cardsidefront, .cardsideback {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 13px;
  overflow: hidden;
}
.cardsideback { transform: rotateY(180deg); }

.cardface {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: 13px;
  overflow: hidden;
  background: var(--paper);
  color: var(--paper-ink);
  border: 2px solid color-mix(in srgb, var(--cat) 62%, #fff);
  box-shadow: 0 14px 26px -14px #000;
}
.cardart { position: relative; flex: 1 1 58%; overflow: hidden; }
.cardart .art { width: 100%; height: 100%; object-fit: cover; display: block; }
.cardart .glyph {
  position: absolute; top: 7px; right: 9px;
  font-size: 15px; line-height: 1;
  color: var(--cat); opacity: .85;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.cardbody { padding: 9px 10px 6px; }
.cardcat {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: .16em;
  text-transform: uppercase; color: color-mix(in srgb, var(--cat) 58%, var(--paper-ink)); font-weight: 700;
}
.cardtitle {
  font-family: var(--display); font-weight: 600; font-size: 13.5px;
  line-height: 1.22; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.gcard.sm .cardtitle { font-size: 11.5px; -webkit-line-clamp: 3; }
.gcard.lg .cardtitle { font-size: 15px; }

.cardyear {
  margin-top: auto;
  padding: 7px 10px 9px;
  border-top: 1px solid color-mix(in srgb, var(--cat) 26%, transparent);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--cat) 12%, transparent));
  text-align: center;
}
.cardyear .year { font-size: 21px; font-weight: 700; color: color-mix(in srgb, var(--cat) 55%, var(--paper-ink)); }
.gcard.sm .cardyear .year { font-size: 16px; }
.cardyear.hidden .qmark { font-family: var(--display); font-size: 20px; font-weight: 900; }
.cardyear.hidden .qmark { color: #b49a68; }

.cardback {
  height: 100%;
  display: grid; place-items: center; gap: 8px;
  background: repeating-linear-gradient(45deg, #0e5a68 0 7px, #0a4753 7px 14px);
  border: 1px solid var(--line); border-radius: 13px;
}
.cardback span { font-family: var(--mono); font-size: 10px; letter-spacing: .3em; color: var(--mute); }
.rosette {
  width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid rgba(242,169,59,.5);
  box-shadow: inset 0 0 0 5px rgba(242,169,59,.12), inset 0 0 0 6px rgba(242,169,59,.35), inset 0 0 0 16px rgba(242,169,59,.07);
}

.gcard.is-ok .cardface { border-color: var(--jade); box-shadow: 0 0 0 2px rgba(53,201,167,.28), 0 12px 30px -16px var(--jade); }
.gcard.is-ko .cardface { border-color: var(--rust); box-shadow: 0 0 0 2px rgba(228,87,46,.3), 0 12px 30px -16px var(--rust); }
.gcard.is-ko .cardinner { animation: nudge .5s ease; }
@keyframes nudge {
  0%, 100% { transform: translateX(0) rotate(0); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(4px) rotate(1.5deg); }
}
.gcard.land .cardinner { animation: land .5s cubic-bezier(.2,.9,.25,1); }
@keyframes land { from { transform: translateY(-26px) scale(1.06); opacity: 0; } }
.gcard.stamp .cardyear .year { animation: stamp .45s cubic-bezier(.2,1.4,.4,1) both; display: inline-block; }
@keyframes stamp { from { transform: scale(2.3) rotate(-7deg); opacity: 0; } }

.votecount {
  position: absolute; top: -8px; right: -8px; z-index: 3;
  min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 99px;
  background: var(--amber); color: #3a2200;
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 4px 12px -4px #000;
}

/* --- Lente e zoom ------------------------------------------------------- */
.zoombtn {
  position: absolute; top: 6px; left: 6px; z-index: 4;
  width: 26px; height: 26px; padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(5,38,45,.62);
  color: var(--bone);
  font-size: 13px; line-height: 1;
  display: grid; place-items: center;
  cursor: zoom-in;
  backdrop-filter: blur(3px);
  opacity: .75;
  transition: opacity .15s ease, background .15s ease;
}
.zoombtn:hover { opacity: 1; background: rgba(5,38,45,.85); border-color: var(--amber); }
.gcard.sm .zoombtn { width: 22px; height: 22px; font-size: 11px; }

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(3,24,29,.93);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 24px 18px;
  animation: fade .18s ease;
  cursor: zoom-out;
}
@keyframes fade { from { opacity: 0; } }
.lightbox figure {
  margin: 0; cursor: default;
  max-width: min(880px, 100%); max-height: 100%;
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.lightbox img, .lightbox .zoomart {
  max-width: 100%;
  max-height: 72vh;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--cat) 40%, var(--line));
  box-shadow: 0 30px 70px -30px #000;
  object-fit: contain;
  background: var(--paper);
}
.lightbox .zoomart { width: min(520px, 90vw); aspect-ratio: 10 / 7; overflow: hidden; }
.lightbox .zoomart .art { width: 100%; height: 100%; display: block; }
.lightbox figcaption { text-align: center; display: grid; gap: 5px; }
.lightbox .zoomcat {
  font-family: var(--mono); font-size: 10px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--cat);
}
.lightbox .zoomtitle { font-family: var(--display); font-size: clamp(19px, 3.4vw, 27px); font-weight: 600; }
.lightbox .zoomyear { font-size: 22px; font-weight: 700; color: var(--cat); }
.zoomclose {
  position: absolute; top: 16px; right: 16px;
  width: 42px; height: 42px; padding: 0;
  border-radius: 50%; font-size: 16px;
  background: rgba(10,58,68,.9);
}

button.gcard { cursor: pointer; transition: transform .16s ease; }
button.gcard:hover { transform: translateY(-4px); }
button.gcard.on .cardface { border-color: var(--amber); box-shadow: 0 0 0 2px rgba(242,169,59,.45), 0 16px 30px -18px var(--amber); }
button.gcard.on { transform: translateY(-8px); }

/* --- Nastro temporale --------------------------------------------------- */
.ribbon {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  padding: 30px 8px 24px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
}
.ribbon::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--amber) 5%, var(--amber) 95%, transparent);
  z-index: 0;
}
.ribbon .gcard { z-index: 1; margin: 0 6px; }

.slot {
  position: relative;
  z-index: 1;
  flex: 0 0 62px;
  height: 150px;
  border-radius: 10px;
  border: 1px dashed var(--dash);
  background: transparent;
  color: var(--mute);
  font-family: var(--mono);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 3px;
}
button.slot:hover, .slot.on { border-color: var(--amber); color: var(--amber); background: rgba(242,169,59,.08); }
.slot .n { font-weight: 700; font-size: 15px; color: var(--amber); }
/* passato ‹ … › futuro: chi guarda lo schermo capisce dove sta andando la carta */
.slot .range { font-size: 9px; line-height: 1.25; letter-spacing: .02em; text-align: center; word-break: break-word; }

/* --- Timer -------------------------------------------------------------- */
.timer { display: flex; align-items: center; gap: 10px; }
.timer .bar { flex: 1; height: 9px; border-radius: 99px; background: rgba(255,255,255,.14); overflow: hidden; }
.timer .fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--rust), var(--amber)); transition: width .25s linear; }
.timer .num { font-family: var(--mono); font-weight: 700; font-size: 19px; min-width: 30px; text-align: right; }
.timer.urgent .fill { background: var(--rust); }
.timer.urgent .num { color: var(--rust); }

/* --- Selettore lingua --------------------------------------------------- */
.langpick { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: var(--ink); }
.langpick button {
  padding: 5px 12px; font-size: 12px; font-family: var(--mono); letter-spacing: .08em;
  border: 0; border-radius: 99px; background: transparent; color: var(--mute);
}
.langpick button:hover { color: var(--bone); border: 0; }
.langpick button.on { background: var(--amber); color: #3a2200; }

/* --- Chip / badge ------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--ink);
  font-size: 12px;
}
.dot { width: 9px; height: 9px; border-radius: 99px; display: inline-block; }

/* --- Chat --------------------------------------------------------------- */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.chat .feed { flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.msg { font-size: 13px; line-height: 1.4; }
.msg b { font-weight: 600; }
.msg.sys { color: var(--mute); font-style: italic; }
.tabs { display: flex; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.tabs button { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.tabs button[aria-selected='true'] { background: var(--amber); color: #3a2200; border-color: var(--amber); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Un messaggio d'errore vuoto non deve lasciare un buco. */
.error:empty { display: none; }
.off-link { display: block; margin-top: 2px; padding: 11px; border: 1px solid var(--amber); border-radius: 12px; color: var(--amber); font-size: 15px; font-weight: 600; text-align: center; text-decoration: none; }
.off-link[hidden] { display: none; }
