/* Plexo Mini App. Colori solo da --tg-theme-* (con ripiego se aperta fuori da Telegram). */

:root {
  --plex: #e5a00d;
  --plex-soft: color-mix(in srgb, var(--plex) 16%, transparent);
  /* come le schermate di Telegram: pagina su secondary_bg, card su section_bg */
  --bg: var(--tg-theme-secondary-bg-color, #f2f2f7);
  --text: var(--tg-theme-text-color, #0f1419);
  --hint: var(--tg-theme-hint-color, #6b7280);
  --section: var(--tg-theme-section-bg-color, var(--tg-theme-bg-color, #ffffff));
  --separator: var(--tg-theme-section-separator-color, color-mix(in srgb, var(--hint) 22%, transparent));
  --section-title: var(--tg-theme-section-header-text-color, var(--hint));
  --accent: var(--tg-theme-accent-text-color, var(--tg-theme-link-color, #2481cc));
  --destructive: var(--tg-theme-destructive-text-color, #e5484d);
  --radius: 16px;
  --gap: 16px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not(.tg) {
    --bg: #0f1115;
    --text: #f2f3f5;
    --hint: #8b919c;
    --section: #1c1f25;
    --accent: #6ab3f3;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  min-height: var(--tg-viewport-stable-height, 100vh);
  padding:
    calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + 20px)
    calc(var(--tg-safe-area-inset-right, 0px) + var(--gap))
    calc(var(--tg-safe-area-inset-bottom, 0px) + 32px)
    calc(var(--tg-safe-area-inset-left, 0px) + var(--gap));
}

#app { max-width: 480px; margin: 0 auto; }

h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 22px; font-weight: 700; }
p { margin: 0; }

.lead { color: var(--hint); font-size: 16px; }
.hint { color: var(--hint); font-size: 14px; }
.nowrap { white-space: nowrap; }

/* --- Viste --- */

.view { display: flex; flex-direction: column; gap: 20px; animation: enter .28s ease-out both; }
.view-center { align-items: center; text-align: center; padding-top: 12vh; gap: 14px; }
.view-center .lead { max-width: 34ch; }

@keyframes enter {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 12px 0 4px; }

.brand {
  width: 72px; height: 72px; border-radius: 22px;
  display: grid; place-items: center;
  background: radial-gradient(120% 120% at 20% 10%, #f7c14c 0%, var(--plex) 45%, #b97b00 100%);
  box-shadow: 0 10px 30px -10px color-mix(in srgb, var(--plex) 70%, transparent);
  margin-bottom: 6px;
}
.brand svg { width: 38px; height: 38px; fill: #1b1405; }

.notice {
  background: var(--plex-soft);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}

/* --- Liste in stile Telegram --- */

.section-title {
  color: var(--section-title);
  font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  margin: 4px 0 -12px 16px;
}

.list { list-style: none; margin: 0; padding: 0; background: var(--section); border-radius: var(--radius); overflow: hidden; }

.row { display: flex; align-items: center; gap: 14px; padding: 12px 16px; position: relative; }
.row + .row::before {
  content: ""; position: absolute; top: 0; right: 0; left: 62px;
  border-top: 0.5px solid var(--separator);
}

.row-icon {
  flex: none; width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--plex-soft); color: var(--plex);
}
.row-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.row-body strong { font-weight: 600; font-size: 16px; }

.icon { width: 18px; height: 18px; flex: none; }

.badge {
  flex: none; font-size: 12px; font-weight: 600;
  color: var(--hint); border: 1px solid var(--separator);
  border-radius: 999px; padding: 2px 8px;
}

.fineprint { display: flex; gap: 8px; color: var(--hint); font-size: 13px; padding: 0 4px; }
.fineprint .icon { width: 15px; height: 15px; margin-top: 2px; }

/* --- Profilo --- */

.profile { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 8px 0; }

.avatar {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--plex);
  margin-bottom: 8px;
}
.avatar-initial {
  display: grid; place-items: center;
  background: var(--plex); color: #1b1405; font-size: 30px; font-weight: 700;
}

/* --- Pulsanti --- */

.actions { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 320px; margin-top: 8px; }

.btn {
  appearance: none; border: 0; border-radius: 12px;
  font: inherit; font-weight: 600; padding: 13px 16px; width: 100%;
  cursor: pointer; transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn-tinted { background: var(--plex-soft); color: var(--text); }
.btn-plain { background: transparent; color: var(--accent); }
.btn-destructive { background: var(--section); color: var(--destructive); }

/* --- Stati --- */

.state-icon { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; margin-bottom: 6px; }
.state-icon .icon { width: 30px; height: 30px; }
.state-warn { background: color-mix(in srgb, var(--destructive) 14%, transparent); color: var(--destructive); }

.spinner {
  width: 56px; height: 56px; border-radius: 50%;
  border: 4px solid var(--plex-soft); border-top-color: var(--plex);
  animation: spin .9s linear infinite; margin-bottom: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Skeleton --- */

.skeleton { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: 12px; }
.sk { background: var(--section); border-radius: 10px; animation: pulse 1.2s ease-in-out infinite; }
.sk-mark { width: 72px; height: 72px; border-radius: 22px; }
.sk-title { width: 40%; height: 26px; }
.sk-line { width: 70%; height: 16px; }
.sk-card { width: 100%; height: 190px; border-radius: var(--radius); margin-top: 12px; }
@keyframes pulse { 50% { opacity: .55; } }

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