/* Meteor web: tre temi come nelle app. I colori arrivano da app.js (variabili sotto). */
:root {
  --bg: #FBF8EF; --surface: #FFFFFF; --ink: #111111; --ink-soft: #3A3A3A;
  --primary: #E0262F; --on-primary: #FFFFFF; --outline: #111111;
  --shadow: 5px;
  --col: 560px;          /* larghezza della colonna della previsione */
  --rail: 300px;         /* colonne pubblicitarie ai lati (schermi larghi) */
  --ad-h: 0px;           /* altezza del banner in basso (solo con la pubblicità attiva) */
  color-scheme: light;
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "PingFang SC", "Microsoft YaHei", sans-serif;
  padding-bottom: calc(var(--ad-h) + env(safe-area-inset-bottom));
}
body.ads { --ad-h: 66px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--primary); }
.ic { display: inline-block; vertical-align: -3px; flex: none; }

/* ------------------------------------------------ impaginazione e pubblicità */
.layout { display: flex; justify-content: center; align-items: flex-start; gap: 24px; }
#app { width: 100%; max-width: var(--col); min-height: 100vh; }
.rail { display: none; }
.ad-bottom { display: none; }
body.ads .ad-bottom {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--ad-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--outline); z-index: 10;
}
body.ads .ad-bottom ins { width: 100%; max-width: 728px; height: 50px; }
/* colonne laterali solo se c'e' spazio per colonna + due annunci da 300 px */
@media (min-width: 1240px) {
  body.ads .rail { display: block; position: sticky; top: 16px; width: var(--rail); min-height: 600px; margin-top: 16px; }
}
@media (min-width: 900px) and (max-width: 1239px) {
  :root { --rail: 160px; }
  body.ads .rail { display: block; position: sticky; top: 16px; width: var(--rail); min-height: 600px; margin-top: 16px; }
}
.ad-label { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 2px; }

/* ------------------------------------------------ barra superiore */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; min-height: 52px; padding: 0 4px;
}
.topbar .sp { width: 14px; flex: none; }
.topbar h1 {
  flex: 1; margin: 0; font-size: 21px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar .actions { display: flex; }
canvas.rule { display: block; width: 100%; height: 10px; position: sticky; top: 52px; z-index: 5; background: var(--bg); }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); border-radius: 10px; flex: none; }
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon-btn:disabled { opacity: .25; cursor: default; }
.icon-btn.sm { width: 34px; height: 40px; }
.icon-btn.sm .ic { width: 17px; height: 17px; }
.icon-btn.gold { color: #F5A524; }
.icon-btn.dim { color: var(--ink-soft); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.content { padding: 4px 14px 24px; }

/* ------------------------------------------------ card */
.card { position: relative; margin-top: 10px; border-radius: 16px; background: var(--fill, var(--surface)); overflow: hidden; }
.card.tight { margin-top: 6px; }
.card .in { position: relative; padding: 12px 14px; }
.card.strip .in { padding-left: 20px; }
.card.strip::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px; background: var(--strip); }
.cardlink { display: block; color: inherit; text-decoration: none; width: 100%; text-align: left; }
.cardlink:hover .card { filter: brightness(.98); }

/* ------------------------------------------------ contenuti */
.status { text-align: right; font-size: 12px; color: var(--ink-soft); margin: 0; min-height: 16px; }
.status.err { color: var(--primary); }
.soft { color: var(--ink-soft); }
.small { font-size: 13px; }
.xs { font-size: 11px; }
.bold { font-weight: 700; }
.grow { flex: 1; min-width: 0; }
p.small, p.xs { margin: 8px 0 0; }
.now { display: flex; gap: 12px; align-items: center; }
.now .big { font-size: 52px; font-weight: 600; line-height: 1.05; }
.cond { font-weight: 700; font-size: 17px; }
.cond.small { font-size: 14px; }
.big2 { font-size: 19px; }
.row3 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; }
.stat { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; min-width: 0; }
.stat span { overflow: hidden; text-overflow: ellipsis; }
.ai { margin: 0; font-style: italic; line-height: 1.5; }
.dayhead { display: flex; align-items: center; gap: 10px; }
.dname { font-weight: 600; font-size: 17px; }
.temps { white-space: nowrap; }
.tmax { font-size: 22px; font-weight: 600; }
.tmin { font-size: 17px; color: var(--ink-soft); margin-left: 10px; }
.tmax.xl { font-size: 30px; }
.tmin.lg { font-size: 22px; }
.line { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 14px; }
.line b { white-space: nowrap; }
canvas.chart { display: block; width: 100%; height: 170px; }
.hour { display: flex; align-items: center; gap: 8px; }
.hour .hh { width: 46px; font-size: 15px; }
.hour .t { font-size: 19px; font-weight: 600; }
.hour .grow > div { white-space: nowrap; }
.hour .r { text-align: right; font-size: 13px; white-space: nowrap; min-width: 70px; }
.attr { font-size: 11px; color: var(--ink-soft); margin-top: 16px; }

h2.section { margin: 20px 0 0; font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }

.btn {
  display: flex; width: 100%; min-height: 52px; margin-top: 10px; align-items: center; justify-content: center; gap: 8px;
  border-radius: 12px; font-size: 16px; font-weight: 700; border: 1.5px solid var(--primary);
}
.btn.filled { background: var(--primary); color: var(--on-primary); }
.btn.outline { color: var(--primary); }

.intro { font-size: 16px; margin: 6px 0 0; }
.searchbox { display: flex; align-items: center; gap: 8px; margin: -6px -8px -6px 0; color: var(--ink-soft); }
.searchbox input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 16px; padding: 10px 0;
}
.searchbox input:focus { outline: none; }
.res { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.res b { color: var(--ink); }
.saved { display: flex; align-items: center; margin: -8px -8px -8px -10px; }
.saved .open { display: flex; flex-direction: column; text-align: left; padding: 4px 0; overflow: hidden; }
.saved .open b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.radios { display: flex; flex-direction: column; }
.radios.h { flex-direction: row; flex-wrap: wrap; }
.radios label { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding-right: 14px; cursor: pointer; font-size: 16px; }
.radios input { accent-color: var(--primary); width: 19px; height: 19px; margin: 0; }
.card p.soft.small:first-child { margin-top: 0; }
.ver { margin-top: 18px; }

.foot { margin-top: 26px; text-align: center; font-size: 12px; color: var(--ink-soft); }
.foot p { margin: 4px 0; }
.foot .tag { font-weight: 600; }

/* ------------------------------------------------ tema manga */
:root[data-theme="manga"] .card { background: none; border-radius: 0; overflow: visible; margin-top: 12px; }
:root[data-theme="manga"] .card.tight { margin-top: 8px; }
:root[data-theme="manga"] .card.strip::before { display: none; }
:root[data-theme="manga"] .card .in { padding: 12px calc(14px + var(--shadow)) calc(12px + var(--shadow)) 14px; }
:root[data-theme="manga"] canvas.panel { position: absolute; inset: 0; width: 100%; height: 100%; }
:root[data-theme="manga"] .topbar h1 { font-size: 24px; font-weight: 900; font-style: italic; }
:root[data-theme="manga"] .now .big,
:root[data-theme="manga"] .tmax,
:root[data-theme="manga"] .dname,
:root[data-theme="manga"] .hour .hh,
:root[data-theme="manga"] .hour .t,
:root[data-theme="manga"] .saved .open b,
:root[data-theme="manga"] .btn { font-weight: 900; font-style: italic; }
:root[data-theme="manga"] .cond,
:root[data-theme="manga"] .line b { font-weight: 700; font-stretch: condensed; }
:root[data-theme="manga"] .btn { border-radius: 2px; border: 2.5px solid var(--ink); }
:root[data-theme="manga"] .cardlink:hover .card { filter: none; transform: translate(-1px, -1px); }
:root[data-theme="manga"] h2.section { margin: 22px 0 2px; color: var(--surface); font-size: 15px; letter-spacing: .08em; }
:root[data-theme="manga"] h2.section span {
  display: inline-block; position: relative; padding: 4px 22px 8px 16px; font-weight: 900; font-style: italic;
  background: var(--ink); clip-path: polygon(9px 0, 100% 0, calc(100% - 9px) calc(100% - 4px), 0 calc(100% - 4px));
}
/* "ombra" rossa sfalsata dell'etichetta (il clip-path taglierebbe un'ombra sullo span) */
:root[data-theme="manga"] h2.section { filter: drop-shadow(4px 4px 0 var(--primary)); }
.bubble { position: relative; margin-top: 12px; }
.bubble canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.bubble p { position: relative; margin: 0; padding: 14px 22px 30px; font-weight: 700; line-height: 1.5; }

@media (max-width: 340px) {
  .now .big { font-size: 44px; }
}
@media (prefers-reduced-motion: no-preference) {
  .card { transition: transform .08s; }
}
