/* Shared components. Views add their own files under css/views/ (loaded by the view module). */

/* ---------- glass card (iOS GlassCard: ultraThinMaterial 0.4 + white 0.08, 0.5pt white 0.12 stroke) ---------- */
.card {
  position: relative;
  padding: var(--space-4);
  border-radius: var(--radius-card);
  background: var(--pv-card-bg);
  border: 0.5px solid var(--pv-card-stroke);
  backdrop-filter: blur(20px) saturate(130%);
  -webkit-backdrop-filter: blur(20px) saturate(130%);
  container-type: inline-size;
}
@media (min-width: 1024px) { .card { padding: var(--space-5); } }
.card__title { display: flex; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-3); font-size: var(--step-1); font-weight: 700; }
.card__title svg { width: 20px; height: 20px; color: var(--pv-solar-gold); flex: none; }
.card__note { margin-top: var(--space-3); font-size: var(--step--1); color: var(--pv-secondary-text); }

/* ---------- buttons: gold fill, deep purple text, 14pt radius (iOS) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--hit); padding: 0 var(--space-5);
  border: 0; border-radius: var(--radius-button);
  background: var(--pv-solar-gold); color: var(--pv-deep-purple);
  font-weight: 700; font-size: var(--step-0); letter-spacing: 0.02em; text-decoration: none;
  cursor: pointer; transition: transform var(--fast) var(--ease), filter var(--fast) var(--ease), opacity var(--fast);
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(0.98); }
@media (hover: hover) { .btn:hover { filter: brightness(1.06); } }
.btn[disabled], .btn[aria-busy="true"] { opacity: 0.55; cursor: default; }
.btn--block { width: 100%; }
.btn--ghost { background: var(--pv-card-bg); color: var(--pv-text); border: 0.5px solid var(--pv-card-stroke); }
.btn--quiet { background: transparent; color: var(--pv-solar-gold); padding-inline: var(--space-3); }
.btn--danger { background: transparent; color: var(--pv-danger); border: 0.5px solid rgb(255 107 107 / 0.5); }

.icon-btn {
  display: inline-grid; place-items: center; width: var(--hit); height: var(--hit);
  border: 0; border-radius: var(--radius-small); background: var(--pv-card-bg); color: var(--pv-text); cursor: pointer;
}
.icon-btn svg { width: 22px; height: 22px; }

/* ---------- form fields ---------- */
.field { display: grid; gap: var(--space-1); }
.field__label { font-size: var(--step--1); font-weight: 600; color: var(--pv-secondary-text); letter-spacing: 0.02em; }
.field__row { display: flex; align-items: center; gap: var(--space-2); }
.input, .select {
  width: 100%; min-height: var(--hit); padding: 0 var(--space-3);
  border-radius: var(--radius-small); border: 0.5px solid var(--pv-card-stroke);
  background: rgb(0 0 0 / 0.22); color: var(--pv-text); font-size: max(16px, var(--step-0)); /* 16px stops iOS zoom */
}
.input:focus { border-color: var(--pv-solar-gold); outline: none; box-shadow: 0 0 0 3px rgb(245 166 35 / 0.25); }
.input[readonly] { opacity: 0.75; }
.field__unit { color: var(--pv-secondary-text); font-size: var(--step--1); min-width: 3ch; }
.field__error { color: var(--pv-danger); font-size: var(--step--1); }

/* Segmented control (units, chart/table toggle). Rectangular, not a pill. */
.segmented { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 3px; border-radius: var(--radius-small); background: rgb(0 0 0 / 0.25); }
.segmented button { min-height: 38px; padding: 0 var(--space-3); border: 0; border-radius: 8px; background: transparent; color: var(--pv-secondary-text); font-weight: 600; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--pv-solar-gold); color: var(--pv-deep-purple); }

/* ---------- metrics ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--space-3); }
.metric { padding: var(--space-3); border-radius: var(--radius-small); background: rgb(0 0 0 / 0.18); }
.metric__label { display: block; font-size: var(--step--1); color: var(--pv-secondary-text); letter-spacing: 0.02em; }
.metric__value { display: block; font-size: var(--step-2); font-weight: 700; color: var(--pv-solar-gold); font-variant-numeric: tabular-nums; }
.metric__unit { font-size: var(--step--1); font-weight: 500; color: var(--pv-secondary-text); margin-left: 2px; }

.rows { display: grid; }
.row { display: flex; justify-content: space-between; gap: var(--space-4); padding: var(--space-2) 0; border-bottom: 0.5px solid var(--pv-card-stroke); }
.row:last-child { border-bottom: 0; }
.row__label { color: var(--pv-secondary-text); }
.row__value { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.row__value--accent { color: var(--pv-solar-gold); }

/* ---------- demo banner: unpaid visitors see a sample property everywhere ---------- */
.demo-banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  margin-bottom: var(--space-4); padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  background: linear-gradient(100deg, rgb(245 166 35 / 0.22), rgb(162 66 87 / 0.25));
  border: 0.5px solid rgb(245 166 35 / 0.45);
}
.demo-banner__text { margin: 0; font-weight: 600; }
.demo-banner__text small { display: block; font-weight: 400; }

/* ---------- table that scrolls inside itself on phones, never the page ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-small); }
.data-table { min-width: 560px; font-variant-numeric: tabular-nums; font-size: var(--step--1); }
.data-table th, .data-table td { padding: var(--space-2) var(--space-3); text-align: right; border-bottom: 0.5px solid var(--pv-card-stroke); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; position: sticky; left: 0; background: rgb(41 27 65 / 0.92); }
.data-table thead th { color: var(--pv-secondary-text); font-weight: 600; }

/* ---------- sheet: bottom sheet on phones, centred dialog from tablet up ---------- */
.sheet { position: fixed; inset: 0; z-index: 80; display: grid; align-items: end; }
.sheet__scrim { position: absolute; inset: 0; background: rgb(10 5 20 / 0.6); animation: fade var(--slow) var(--ease) both; }
.sheet__panel {
  position: relative; max-height: 92dvh; overflow: auto;
  padding: var(--space-5) max(var(--gutter), env(safe-area-inset-right)) calc(var(--space-5) + env(safe-area-inset-bottom)) max(var(--gutter), env(safe-area-inset-left));
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #3a2350, var(--pv-deep-purple));
  border-top: 0.5px solid var(--pv-card-stroke);
  animation: sheet-up var(--slow) var(--ease) both;
}
.sheet__close { position: absolute; top: var(--space-3); right: var(--space-3); }
@media (min-width: 600px) {
  .sheet { align-items: center; justify-items: center; padding: var(--space-5); }
  .sheet__panel { width: min(640px, 100%); border-radius: 22px; border: 0.5px solid var(--pv-card-stroke); animation-name: pop; }
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + var(--space-4) + env(safe-area-inset-bottom)); display: grid; gap: var(--space-2); width: min(92vw, 440px); pointer-events: none; }
@media (min-width: 600px) { .toasts { bottom: var(--space-5); } }
.toast { padding: var(--space-3) var(--space-4); border-radius: var(--radius-small); background: #1b1230; border: 0.5px solid var(--pv-card-stroke); box-shadow: 0 10px 30px rgb(0 0 0 / 0.35); animation: sheet-up var(--slow) var(--ease) both; }
.toast--error { border-color: rgb(255 107 107 / 0.6); }

/* ---------- loading overlay with the iOS sun loop ---------- */
.loading { display: grid; place-items: center; gap: var(--space-3); min-height: 50dvh; text-align: center; }
.loading__sun { width: 160px; height: 160px; mix-blend-mode: screen; border-radius: 50%; }
.loading__text { color: var(--pv-secondary-text); font-weight: 600; letter-spacing: 0.02em; }

/* ---------- empty / error states ---------- */
.state { display: grid; justify-items: center; gap: var(--space-3); padding: var(--space-7) var(--space-4); text-align: center; }
.state svg { width: 48px; height: 48px; color: var(--pv-secondary-text); }
.state h2 { font-size: var(--step-2); margin: 0; }
.state p { max-width: 42ch; color: var(--pv-secondary-text); }

.notice { padding: var(--space-3) var(--space-4); border-radius: var(--radius-small); background: rgb(255 107 107 / 0.12); border: 0.5px solid rgb(255 107 107 / 0.45); }
.notice--info { background: rgb(245 166 35 / 0.1); border-color: rgb(245 166 35 / 0.4); }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Provider attribution required wherever building insights are shown (PLAN D13). */
.attribution { display: flex; justify-content: flex-end; margin-top: var(--space-3); font-size: 0.75rem; color: var(--pv-secondary-text); }
.attribution img { height: 16px; width: auto; }

/* ---------- charts (charts.js) ---------- */
.chart { width: 100%; height: auto; overflow: visible; }
.chart__bar { fill: var(--pv-solar-gold); }
.chart__bar--muted { fill: rgb(212 145 58 / 0.55); }
.chart__value { fill: var(--pv-text); font-size: 13px; font-weight: 600; font-family: var(--font); }
.chart__label { fill: var(--pv-secondary-text); font-size: 13px; font-family: var(--font); }
.chart__axis { stroke: var(--pv-card-stroke); }
.chart__ref { stroke: var(--pv-warm-red); stroke-width: 2; stroke-dasharray: 6 5; }
@media print { .chart__bar { fill: #d4913a; } .chart__value, .chart__label { fill: #333; } }
