/* Swipe: stile dell'app, sopra il design system di ui-kit (token, prezzi, barra del prezzo), che
   ui_kit::mount_style() inserisce prima di questo foglio.
   Una colonna da telefono anche su desktop: il mazzo è il centro, le scelte sono pulsanti grandi
   sotto il pollice. Verde = segui / buon prezzo, rosso = scarta, blu = soglia. */

:root {
  --card-radius: 20px;
  --card-shadow: 0 12px 32px rgb(24 33 43 / 13%), 0 2px 6px rgb(24 33 43 / 6%);
  --tabs-h: 60px;
  --spring: cubic-bezier(.2, .9, .3, 1.25);
}
@media (prefers-color-scheme: dark) {
  :root { --card-shadow: 0 12px 32px rgb(0 0 0 / 45%); }
}

html, body { height: 100%; overscroll-behavior: none; }
body { -webkit-tap-highlight-color: transparent; }

.app { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); height: 100dvh; max-width: 520px; margin: 0 auto;
  background: var(--bg); }
@media (min-width: 700px) {
  body { background: var(--surface-2); }
  .app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
.app > main { min-width: 0; max-width: none; margin: 0; padding: 0; overflow-y: auto; display: flex; flex-direction: column; }

.icon { width: 22px; height: 22px; flex: none; }
/* -webkit-box conta tutto il testo come larghezza minima: va contenuto dal genitore */
.clamp-1, .clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; min-width: 0; overflow-wrap: anywhere; }
.clamp-1 { -webkit-line-clamp: 1; }
.clamp-2 { -webkit-line-clamp: 2; }
.small { font-size: 12.5px; }
.row.center { justify-content: center; }

/* --- barra in alto e schede in basso ----------------------------------------------------------- */

.appbar { display: flex; align-items: center; justify-content: space-between; height: 52px; padding: 0 16px;
  padding-top: env(safe-area-inset-top); }
.appbar .brand { display: flex; gap: 8px; align-items: center; font-weight: 760; font-stretch: 88%; color: var(--text); }
.appbar .brand:hover, .taste-link:hover, .tabs a:hover { text-decoration: none; }
.taste-link { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; font-weight: 600;
  padding: 6px 10px; border-radius: 999px; }
.taste-link[aria-current=page] { color: var(--accent); background: var(--accent-soft); }
.taste-link .icon { width: 18px; height: 18px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tabs-h); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.tabs a[aria-current=page] { color: var(--accent); }
.tabs a[aria-current=page] .icon { stroke-width: 2.6; }
.tab-badge { position: absolute; top: 6px; left: calc(50% + 7px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 10.5px; font-weight: 750; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--surface); }

/* --- mazzo ------------------------------------------------------------------------------------- */

.deck-page { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.deck { position: relative; flex: 1; min-height: 340px; margin: 4px 14px 0; }

.sw-card { position: absolute; inset: 0; display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: var(--card-radius); box-shadow: var(--card-shadow);
  touch-action: none; user-select: none; -webkit-user-select: none; will-change: transform;
  transition: transform .42s var(--spring), opacity .2s ease; transform-origin: 50% 90%; }
.sw-card.top { cursor: grab; }
.sw-card.top:active { cursor: grabbing; }
.deck.busy .sw-card { pointer-events: none; }
.sw-card.entering { animation: card-back .36s var(--spring); }
@keyframes card-back { from { transform: translateY(-60px) scale(.9) rotate(-4deg); opacity: 0; } }

.sw-card .media { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center;
  padding: 22px 22px 14px; background: #fff; }
.sw-card .media img { max-width: 100%; max-height: 100%; object-fit: contain; pointer-events: none; }

.why { position: absolute; top: 12px; left: 12px; max-width: calc(100% - 24px); padding: 5px 11px; border-radius: 999px;
  background: rgb(24 33 43 / 78%); color: #fff; font-size: 12px; font-weight: 650; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; backdrop-filter: blur(6px); }
.why::before { content: "✦ "; opacity: .8; }
.why.good { background: var(--good); }
.why.explore { background: var(--accent); }

.stamp { position: absolute; top: 34px; padding: 2px 12px; border: 4px solid currentColor; border-radius: 10px;
  font-size: 30px; font-weight: 820; font-stretch: 85%; letter-spacing: .05em; opacity: 0; pointer-events: none;
  background: color-mix(in srgb, #fff 70%, transparent); }
.s-follow { left: 20px; color: var(--good); transform: rotate(-14deg); }
.s-pass { right: 20px; color: var(--bad); transform: rotate(14deg); }
.s-alert { top: auto; bottom: 22px; left: 50%; color: var(--accent); transform: translateX(-50%); }

.sw-card .body { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px 14px; border-top: 1px solid var(--border); }
.sw-card .cat { margin: 0; font-size: 12px; color: var(--muted); }
.sw-card .title { font-size: 16px; line-height: 1.3; font-weight: 650; letter-spacing: -0.01em; }
.brand-line { display: flex; gap: 10px; justify-content: space-between; margin: 0; font-size: 12.5px; color: var(--muted); }
.checked { margin: 2px 0 0; font-size: 11.5px; }
.sw-card .prange { margin: 2px 0; }

.price-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 9px; margin: 2px 0; }
.price-line .price-tag { font-size: 30px; line-height: 1.1; }
.was { color: var(--faint); font-size: 14px; }
.off { padding: 1px 7px; border-radius: 6px; background: var(--good); color: #fff; font-size: 13px; font-weight: 750; }

.actions { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px 0 8px; }
.act { display: grid; place-items: center; flex: none; width: 50px; height: 50px; padding: 0; border-radius: 50%; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 4px 14px rgb(24 33 43 / 10%);
  transition: transform .12s ease, background .15s ease; }
.act:hover:not(:disabled) { filter: none; transform: translateY(-1px); }
.act:active:not(:disabled) { transform: scale(.9); }
.act:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.act.pass, .act.follow { width: 66px; height: 66px; }
.act .icon { width: 24px; height: 24px; }
.act.pass .icon, .act.follow .icon { width: 30px; height: 30px; }
.act.pass { color: var(--bad); }
.act.pass:hover:not(:disabled) { background: var(--bad-soft); }
.act.follow { color: var(--good); }
.act.follow:hover:not(:disabled) { background: var(--good-soft); }
.act.follow .icon { fill: currentColor; }
.act.alert { color: var(--accent); }
.act.alert:hover:not(:disabled) { background: var(--accent-soft); }
.act.undo { color: var(--warn); }
.act.info { color: var(--muted); }
.keys { display: none; margin: 0 0 8px; text-align: center; font-size: 11.5px; }
@media (hover: hover) and (pointer: fine) { .keys { display: block; } }

.deck-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 24px; text-align: center; background: var(--surface); border: 1px dashed var(--border);
  border-radius: var(--card-radius); }
.deck-empty .big { font-size: 40px; margin: 0; }
.deck-empty p { margin: 0 0 8px; max-width: 34ch; }

/* spiegazione dei gesti al primo uso */
.coach { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: rgb(10 14 18 / 66%); color: #fff; cursor: pointer; animation: fade .25s ease; }
.coach-hint { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 34px; font-weight: 800; line-height: 1; }
.coach-hint span { font-size: 12.5px; font-weight: 650; }
.coach-hint.left { left: 18px; top: 38%; animation: nudge-left 1.4s ease-in-out infinite; }
.coach-hint.right { right: 18px; top: 38%; animation: nudge-right 1.4s ease-in-out infinite; }
.coach-hint.up { top: 18px; left: 50%; transform: translateX(-50%); }
.coach-box { max-width: 320px; padding: 16px 18px; border-radius: 16px; background: var(--surface); color: var(--text);
  text-align: center; box-shadow: var(--card-shadow); }
.coach-box p { margin: 0 0 12px; }
@keyframes nudge-left { 50% { transform: translateX(-8px); } }
@keyframes nudge-right { 50% { transform: translateX(8px); } }

/* --- fogli dal basso (soglia, scheda completa) ------------------------------------------------- */

.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgb(10 14 18 / 45%); animation: fade .2s ease; }
.sheet { position: fixed; left: 50%; bottom: 0; z-index: 51; width: min(520px, 100%); max-height: 92dvh; overflow-y: auto;
  transform: translateX(-50%); padding: 8px 18px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 40px rgb(0 0 0 / 20%);
  animation: sheet-up .28s cubic-bezier(.2, .9, .3, 1); overscroll-behavior: contain; }
.sheet > h2 { margin: 8px 0 4px; font-size: 18px; }
.sheet > p { margin: 0 0 4px; }
.grabber { width: 38px; height: 4px; margin: 2px auto 6px; border-radius: 2px; background: var(--border); }
.sheet .chips { margin: 14px 0 4px; gap: 8px; }
.sheet .chip, .ob-chips .chip { height: auto; gap: 8px; padding: 9px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text); font-weight: 500; }
.sheet .chip b { font-variant-numeric: tabular-nums; }
.sheet .chip.on, .ob-chips .chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0 16px; font-size: 13px; color: var(--muted); }
.field input { width: 100%; height: 46px; font-size: 18px; font-variant-numeric: tabular-nums; }
.sheet-actions { display: flex; gap: 10px; }
.sheet-actions button { flex: 1; height: 46px; font-weight: 650; border-radius: 12px; }

.sheet.detail { height: 92dvh; }
.sheet .close { position: sticky; top: 4px; float: right; z-index: 2; display: grid; place-items: center; width: 36px; height: 36px;
  padding: 0; border-radius: 50%; }
.detail-media { display: flex; align-items: center; justify-content: center; height: 250px; margin: 6px 0 12px; padding: 12px;
  background: #fff; border-radius: 14px; }
.detail-media img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sheet.detail .cat { margin: 0 0 2px; font-size: 12px; color: var(--muted); }
.sheet.detail .title { font-size: 18px; line-height: 1.3; }
.sheet.detail .title + .muted { margin: 2px 0 0; }
.detail-actions { display: flex; gap: 8px; margin: 14px 0 4px; }
.detail-actions button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 44px;
  border-radius: 12px; font-weight: 650; }
.detail-actions .icon { width: 18px; height: 18px; }
button.good { background: var(--good); }
.block { margin-top: 20px; }
.block h3 { margin: 0 0 8px; }
.hist-stats { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 13px; }
.hist-stats b { color: var(--text); font-variant-numeric: tabular-nums; }
.bullets { margin: 0; padding-left: 18px; color: var(--muted); font-size: 13.5px; display: flex; flex-direction: column; gap: 4px; }
.buy { margin-top: 20px; }
.buy .hint { margin: 8px 0 0; font-size: 12px; }
a.button.amazon { width: 100%; justify-content: center; height: 46px; border-radius: 12px; background: var(--amazon); color: #111;
  font-weight: 700; }

/* --- primo accesso ----------------------------------------------------------------------------- */

.onboarding { position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--bg); animation: fade .2s ease; }
.ob-inner { display: flex; flex-direction: column; gap: 14px; max-width: 520px; margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top)) 22px calc(28px + env(safe-area-inset-bottom)); }
.ob-inner h1 { font-size: 28px; line-height: 1.15; font-stretch: 88%; }
.ob-inner > p { margin: 0; }
.ob-lang { align-self: flex-end; }
.mark.big { transform: scale(1.6); transform-origin: left center; margin: 8px 0 4px; }
.ob-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ob-chips .chip small { color: var(--faint); font-size: 12px; }
.ob-actions button.big { width: 100%; height: 52px; border-radius: 14px; font-size: 16px; font-weight: 700; }

/* --- pagine ------------------------------------------------------------------------------------ */

.page { min-width: 0; padding: 8px 16px 28px; }
.page-head { display: block; margin-bottom: 14px; }
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; }
.page-head .row { margin-top: 8px; }
.list { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.fav, .alert-row { display: flex; gap: 8px; align-items: center; padding: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; }
.fav.hit { border-color: var(--good); box-shadow: 0 0 0 3px var(--good-soft); }
.fav-main, .alert-row > button { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: center; height: auto; padding: 0;
  background: none; border: 0; color: inherit; text-align: left; font-weight: 400; }
.fav-main:hover, .alert-row > button:hover { filter: none; }
.fav img, .alert-row img { flex: none; width: 66px; height: 66px; padding: 4px; object-fit: contain; background: #fff;
  border-radius: 10px; }
.fav-text { flex: 1; min-width: 0; width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 13.5px; }
.fav-text .price-tag { font-size: 20px; }
.fav-text .prange { max-width: 240px; }
.fav-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.fav-actions .danger { display: grid; place-items: center; width: 28px; padding: 0; }
.fav-actions .icon { width: 15px; height: 15px; }
.pill { padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; }
.pill.good { background: var(--good-soft); color: var(--good); }
.alert-row.unread { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.alert-row .dot { flex: none; width: 9px; height: 9px; margin-right: 4px; border-radius: 50%; background: var(--accent); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 48px 10px; text-align: center;
  color: var(--muted); }
.empty-state p { margin: 0; max-width: 34ch; }
.empty-state .big .icon { width: 40px; height: 40px; color: var(--faint); }

/* --- interessi -------------------------------------------------------------------------------- */

.interest-form { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.interest-form .row { flex-wrap: nowrap; }
.interest-form input { flex: 1; min-width: 0; height: 46px; font-size: 16px; }
.interest-form button[type=submit] { height: 46px; }
.interest-preview { display: flex; flex-direction: column; gap: 8px; }
.interest-preview p { margin: 0; }
.preview-strip { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.preview-strip img { flex: none; width: 64px; height: 64px; padding: 4px; object-fit: contain; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; }
.interest { display: flex; gap: 8px; align-items: center; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px; }
.interest.paused { opacity: .65; }
.interests { margin-bottom: 14px; }

/* --- accesso ----------------------------------------------------------------------------------- */

.login-page { display: block; overflow-y: auto; padding: env(safe-area-inset-top) 16px 0; }

/* --- avvisi brevi ------------------------------------------------------------------------------ */

.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + 12px + env(safe-area-inset-bottom)); z-index: 70;
  display: flex; justify-content: center; pointer-events: none; }
.toast { display: flex; gap: 14px; align-items: center; max-width: min(480px, calc(100% - 24px)); padding: 11px 14px;
  border-radius: 12px; background: var(--text); color: var(--bg); font-size: 13.5px; box-shadow: 0 8px 24px rgb(0 0 0 / 22%);
  pointer-events: auto; animation: toast-in .22s ease; }
/* con un foglio aperto il messaggio va in alto, per non coprirne i pulsanti */
.app:has(.sheet) .toast-wrap { top: calc(12px + env(safe-area-inset-top)); bottom: auto; }
.toast button.link { color: inherit; font-weight: 750; text-decoration: underline; white-space: nowrap; }

@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translate(-50%, 100%); } }
@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sw-card { transition: opacity .15s ease !important; }
  .sw-card.entering, .sheet, .coach-hint, .toast { animation: none !important; }
}
