/* ============================================
   CVI Virtual - Meteo gara
   Pulsante + modale + campi admin
   ============================================ */

/* ---------- Pulsante pubblico ---------- */
.btn-meteo {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: linear-gradient(135deg, rgba(56, 189, 248, .22), rgba(14, 165, 233, .06));
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, .45);
  padding: .3rem .72rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: .02em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease, box-shadow .2s ease, transform .2s ease;
}
.btn-meteo:hover {
  background: rgba(56, 189, 248, .28);
  color: #e0f2fe;
  box-shadow: 0 0 16px rgba(56, 189, 248, .35);
  transform: translateY(-1px);
}
.btn-meteo:active { transform: translateY(0); }

/* Pulsante sovrapposto alla card "prossima gara" in home */
.next-regata-wrap { position: relative; display: flex; }
.next-regata-wrap > .next-regata-card { flex: 1; }
.next-regata-wrap > .btn-meteo {
  position: absolute;
  top: .9rem;
  right: .9rem;
  z-index: 3;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

body.cvi-meteo-open { overflow: hidden; }

/* ---------- Modale ---------- */
.cvi-meteo-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(3, 7, 18, .78);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
}

.cvi-meteo-modal {
  position: relative;
  width: min(920px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  padding: 1.6rem 1.6rem 1.2rem;
  border-radius: 18px;
  border: 1px solid rgba(56, 189, 248, .35);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(56, 189, 248, .16), transparent 60%),
    linear-gradient(160deg, #0e1a2b 0%, #0b1322 55%, #0a1220 100%);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65), inset 0 1px 0 rgba(255, 255, 255, .04);
  color: #e2e8f0;
  animation: cvi-meteo-in .22s ease-out;
}
.cvi-meteo-modal::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 18px 18px 0 0;
  background: linear-gradient(90deg, #0ea5e9, #38bdf8, #22d3ee);
  opacity: .85;
}
@keyframes cvi-meteo-in {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.cvi-meteo-close {
  position: absolute;
  top: .85rem;
  right: .85rem;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: #cbd5e1;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.cvi-meteo-close:hover {
  background: rgba(248, 113, 113, .18);
  border-color: rgba(248, 113, 113, .5);
  color: #fecaca;
}

.cvi-meteo-head { padding-right: 3rem; }
.cvi-meteo-head h2 {
  margin: 0;
  font-size: clamp(1.15rem, 2.6vw, 1.55rem);
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.cvi-meteo-head p {
  margin: .3rem 0 1rem;
  font-size: .88rem;
  color: #94a3b8;
}
.cvi-meteo-head p strong { color: #e2e8f0; font-weight: 600; }

/* ---------- Tab regate ---------- */
.cvi-meteo-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.1rem;
}
.cvi-meteo-tab {
  flex: 1 1 130px;
  min-width: 0;
  padding: .55rem 1rem;
  border-radius: 9px;
  border: 1px solid rgba(56, 189, 248, .22);
  background: rgba(8, 16, 28, .75);
  color: #94a3b8;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.cvi-meteo-tab:hover { color: #e0f2fe; border-color: rgba(56, 189, 248, .45); }
.cvi-meteo-tab.is-active {
  background: linear-gradient(180deg, rgba(14, 116, 144, .55), rgba(8, 47, 73, .7));
  border-color: rgba(56, 189, 248, .65);
  color: #e0f2fe;
  box-shadow: inset 0 0 18px rgba(56, 189, 248, .18), 0 0 14px rgba(56, 189, 248, .12);
}

/* ---------- Pannello ---------- */
.cvi-meteo-panel { display: none; }
.cvi-meteo-panel.is-active { display: block; }

.cvi-meteo-grid {
  display: grid;
  grid-template-columns: minmax(260px, .92fr) 1.08fr;
  gap: 1.35rem;
  align-items: stretch;
}

.cvi-meteo-wind {
  text-align: center;
  padding: 1rem .9rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(56, 189, 248, .16);
  background: radial-gradient(circle at 50% 26%, rgba(56, 189, 248, .12), transparent 66%);
}

.cvi-compass-svg {
  display: block;
  width: 100%;
  max-width: 232px;
  height: auto;
  margin: 0 auto .4rem;
}
.cvi-compass-ring {
  fill: rgba(8, 20, 34, .55);
  stroke: rgba(56, 189, 248, .28);
  stroke-width: 1.5;
}
.cvi-compass-ring-inner {
  fill: none;
  stroke: rgba(56, 189, 248, .2);
  stroke-dasharray: 3 7;
}
.cvi-compass-label {
  fill: #8fa3bd;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}
.cvi-compass-label.is-main { fill: #dbeafe; font-size: 12px; font-weight: 800; }
.cvi-needle-wind { fill: #38bdf8; filter: drop-shadow(0 0 6px rgba(56, 189, 248, .7)); }
.cvi-needle-tail { fill: #fb923c; filter: drop-shadow(0 0 5px rgba(251, 146, 60, .55)); }
.cvi-compass-hub { fill: #0b0f19; stroke: #38bdf8; stroke-width: 2; }

.cvi-wind-value {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .4rem;
  margin-top: .1rem;
}
.cvi-wind-value .num {
  font-size: clamp(2.2rem, 5.4vw, 3.2rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
  color: #7dd3fc;
  text-shadow: 0 0 24px rgba(56, 189, 248, .4);
}
.cvi-wind-value .unit {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #bae6fd;
}
.cvi-wind-caption {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-top: .35rem;
  font-size: .58rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #7b8ba3;
}
.cvi-wind-dir {
  display: inline-block;
  margin-top: .55rem;
  padding: .34rem .75rem;
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, .32);
  background: rgba(56, 189, 248, .12);
  color: #bae6fd;
  font-size: .84rem;
  font-weight: 700;
}

.cvi-meteo-info {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.cvi-info-line {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(8, 16, 28, .62);
  font-size: .86rem;
}
.cvi-info-line .ico { font-size: 1rem; line-height: 1; }
.cvi-info-line .lbl {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #8fa0b8;
}
.cvi-info-line strong {
  margin-left: auto;
  color: #e2e8f0;
  font-weight: 700;
  text-align: right;
}

.cvi-gauge {
  padding: .7rem .8rem .6rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(8, 16, 28, .62);
}
.cvi-gauge-head {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .45rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #8fa0b8;
}
.cvi-gauge-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .08);
}
.cvi-gauge-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #38bdf8 45%, #fbbf24 76%, #f87171);
  opacity: .85;
}
.cvi-gauge-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 18px;
  border-radius: 2px;
  background: #e0f2fe;
  transform: translateX(-50%);
  box-shadow: 0 0 8px rgba(56, 189, 248, .9);
}
.cvi-gauge-scale {
  display: flex;
  justify-content: space-between;
  margin-top: .28rem;
  font-size: .64rem;
  color: #64748b;
}

.cvi-conditions {
  padding: .75rem .85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .07);
  background: rgba(8, 16, 28, .62);
}
.cvi-conditions h3 {
  margin: 0 0 .45rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.cvi-conditions ul { list-style: none; margin: 0; padding: 0; }
.cvi-conditions li {
  display: flex;
  gap: .45rem;
  padding: .16rem 0;
  font-size: .86rem;
  color: #cbd5e1;
}
.cvi-conditions li::before { content: "•"; color: #38bdf8; }
.cvi-conditions li strong { color: #e2e8f0; font-weight: 600; }

.cvi-meteo-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #94a3b8;
  font-size: .9rem;
}
.cvi-meteo-note {
  margin: 1rem 0 0;
  text-align: center;
  font-size: .72rem;
  color: #64748b;
}

/* ---------- Campi admin ---------- */
.meteo-admin-box {
  margin-top: .35rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, .18);
  background: rgba(56, 189, 248, .04);
}
.meteo-admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.meteo-admin-head strong { color: #7dd3fc; font-size: .92rem; }
.meteo-admin-hint {
  display: block;
  margin-top: .2rem;
  color: #94a3b8;
  font-size: .78rem;
  font-weight: 400;
  line-height: 1.45;
}
.meteo-admin-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: #e2e8f0;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.meteo-admin-toggle input { width: auto; }
.meteo-admin-race {
  margin-top: .85rem;
  padding-top: .75rem;
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.meteo-admin-race h4 {
  margin: 0 0 .5rem;
  font-size: .76rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.meteo-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: .6rem;
}
.meteo-admin-grid label {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #94a3b8;
}
.meteo-admin-grid input {
  width: 100%;
  background: #0b0f19;
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 7px;
  padding: .45rem .55rem;
  font-family: inherit;
  font-size: .85rem;
}
.meteo-admin-grid input:focus { outline: none; border-color: #38bdf8; }
.meteo-admin-dir-hint {
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .03em;
  color: #7dd3fc;
  text-transform: none;
  min-height: .8rem;
}

/* Evita la sovrapposizione con i badge della card "prossima gara" in home */
.next-regata-wrap.has-meteo .regata-badges { padding-right: 7.6rem; }

@media (max-width: 720px) {
  .next-regata-wrap.has-meteo .regata-badges { padding-right: 6.4rem; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .cvi-meteo-modal { padding: 1.15rem 1rem 1rem; border-radius: 14px; }
  .cvi-meteo-grid { grid-template-columns: 1fr; gap: .9rem; }
  .cvi-meteo-wind { padding: .85rem .7rem 1rem; }
  .cvi-compass-svg { max-width: 210px; }
  .cvi-meteo-tab { flex: 1 1 100%; }
  .cvi-info-line { flex-wrap: wrap; }
  .cvi-info-line strong { margin-left: 0; width: 100%; text-align: left; padding-left: 1.55rem; }
  .next-regata-wrap > .btn-meteo { top: .75rem; right: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cvi-meteo-modal { animation: none; }
  .btn-meteo:hover { transform: none; }
}
