/* v3 P2C: herói «Agora» com o fluxo de energia, ilustrações, palco da entrada, marca. Só tokens.
   Vem de design-v3/mockups/assets/v3.css (desenho aprovado). */

/* ---------- Marca ---------- */
.logo { display: block; height: 26px; width: auto; }
.logo-link { display: flex; align-items: center; min-height: var(--touch); flex-shrink: 0; }
.kind-icon { width: 28px; height: 28px; flex-shrink: 0; }
.site-chip {
	/* min-width 0 em cadeia: o <select> com um nome longo encolhe em vez de empurrar a página (D1, +3 px a 375). */
	display: inline-flex; align-items: center; gap: var(--space-2); flex: 0 1 auto; min-width: 0; max-width: 60%; overflow: hidden;
	min-height: var(--touch); padding: 0 var(--space-3) 0 var(--space-2);
	border: 1px solid var(--hairline); border-radius: 999px; background: var(--surface);
	font-size: var(--fs-small); color: var(--text);
}
.site-chip .site-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-chip .site-select { flex: 1 1 auto; width: 100%; min-width: 0; max-width: 100%; padding: 0; color: var(--text); font-size: 16px; text-align: left; overflow: hidden; }
.site-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border-radius: var(--radius); background: var(--surface-2); color: var(--text); }
.site-card .kind-icon { width: 44px; height: 44px; }
.site-card-text { display: flex; flex-direction: column; min-width: 0; }
.site-card-name { font-size: var(--fs-small); line-height: 20px; font-weight: 600; }
.site-card-sub { font-size: var(--fs-label); line-height: 18px; color: var(--text-muted); }
.byline { padding: 0 var(--space-3); font-size: var(--fs-label); line-height: 20px; color: var(--text-muted); }

/* ---------- Herói: cena + leitura ---------- */
.hero-flow { background: var(--surface); border-radius: var(--panel-radius); display: grid; grid-template-columns: minmax(0, 1fr); overflow: hidden; align-items: stretch; }
.hero-scene { position: relative; padding: var(--space-3) var(--space-3) 0; min-width: 0; }
.hero-read { display: flex; flex-direction: column; gap: var(--space-4); padding: var(--space-4) var(--space-5) var(--space-5); min-width: 0; }
/* Em coluna (abaixo de 1024), a cena não passa de 560 px: a 768 ocuparia meio ecrã. */
/* Abaixo de 1024 a pastilha do centro (até 2 linhas + consumo) desce além do desenho: a margem por baixo
   reserva essa altura, para a cena nunca invadir a leitura (D2). */
@media (max-width: 1023px) {
	.hero-scene .scene { max-width: 560px; margin-inline: auto; margin-bottom: 64px; }
	/* A pastilha desce para o chão da ilustração: não tapa a base do edifício (D2). */
	.hero-scene .s4 .at-centre { top: 81%; }
	.hero-scene .s1 .at-centre { top: 86%; }
}
@media (min-width: 1024px) {
	.hero-flow { grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr); }
	.hero-scene { padding: var(--space-5) 0 var(--space-5) var(--space-5); display: flex; align-items: center; }
	.hero-read { padding: var(--space-7) var(--space-6); justify-content: center; border-left: 1px solid var(--hairline); }
	/* Sem contador não há cena: o cartão Agora ocupa uma só coluna. */
	.hero-flow.hero-no-scene { grid-template-columns: minmax(0, 1fr); }
	.hero-no-scene .hero-scene { display: none; }
	.hero-no-scene .hero-read { border-left: 0; padding: var(--space-5); }
}
.label { font-size: var(--fs-label); line-height: 18px; letter-spacing: var(--tracking-label); text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
.live { display: flex; align-items: center; gap: var(--space-2); font-size: var(--fs-small); color: var(--text-muted); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); flex-shrink: 0; }
.live-dot.off { background: var(--control-border); box-shadow: none; }
.hero-value.is-stale { opacity: 0.5; }
.hero-value .hero-unit { font-size: 0.42em; padding-left: 0.12em; }
.direction { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--text-muted); }
.note { font-size: var(--fs-label); line-height: 20px; color: var(--text-muted); }
.chip-sw { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.hero-read .chip { min-height: 32px; background: var(--surface-2); border: 0; cursor: default; align-self: flex-start; }

.meter { display: flex; flex-direction: column; gap: var(--space-2); }
.meter-track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--text); }
.meter-row { display: flex; justify-content: space-between; gap: var(--space-3); font-size: var(--fs-label); color: var(--text-muted); }

.hero-read .phases { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-3); padding: 0; }
.hero-read .phase { display: flex; flex-direction: column; gap: var(--space-1); }
.phase-name { font-size: var(--fs-label); color: var(--text-muted); }
.phase-val { font-size: var(--fs-small); font-weight: 600; white-space: nowrap; }
/* 1024–1279 px: a leitura é estreita e «230 V · 0,6 A» partia; as fases passam a linhas. */
@media (min-width: 1024px) and (max-width: 1279px) {
	.hero-read .phases { grid-template-columns: minmax(0, 1fr); gap: var(--space-1); }
	.hero-read .phase { flex-direction: row; justify-content: space-between; }
}

.hero-read .rows .row { min-height: 52px; padding: 0; border-top: 0; border-bottom: 1px solid var(--hairline); }
.hero-read .rows .row:last-child { border-bottom: 0; }
.row-sw { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.row-name { font-size: var(--fs-small); line-height: 20px; }
.row-val { min-width: 96px; flex-shrink: 0; text-align: right; white-space: nowrap; font-size: var(--fs-body); font-weight: 600; }

.sw-grid { background: var(--flow-grid); }
.sw-solar { background: var(--flow-solar); }
.sw-battery { background: var(--flow-battery); }
.sw-load { background: var(--text); }
.sw-ev { background: transparent; box-shadow: inset 0 0 0 2px var(--text); }
.sw-forecast-line { height: 0; width: 18px; border-top: 2px dotted var(--text-muted); border-radius: 0; background: none; }

.more-link { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--touch); font-size: var(--fs-small); font-weight: 600; text-decoration: none; color: var(--accent-text); align-self: flex-start; }

.insight { display: flex; gap: var(--space-4); align-items: flex-start; background: var(--accent-soft); border-radius: var(--panel-radius); padding: var(--space-5); color: var(--text); text-decoration: none; font-size: var(--fs-body); line-height: var(--lh-body); }
.insight .icon { color: var(--accent-text); margin-top: 2px; }

/* ---------- Cena do fluxo: SVG + rótulos HTML por ranhura ---------- */
.scene { position: relative; width: 100%; margin-bottom: var(--space-5); }
.scene > svg { display: block; width: 100%; height: auto; }
/* Rótulos laterais presos a 25 % da largura (sem max-content): não invadem o centro. */
.lbl { position: absolute; display: flex; flex-direction: column; align-items: center; text-align: center; width: 25%; }
.lbl-name { font-size: var(--fs-label); line-height: 16px; color: var(--text-muted); }
.lbl-strong { color: var(--text); font-weight: 650; font-size: var(--fs-small); line-height: 20px; }
.lbl-val { font-size: var(--fs-body); line-height: 22px; font-weight: 650; white-space: nowrap; }
.lbl-sub { font-size: var(--fs-label); line-height: 16px; color: var(--text-muted); }
.lbl.is-idle .lbl-val { font-weight: 400; color: var(--text-muted); font-size: var(--fs-small); }
/* Pastilha do centro: no máximo 44 % da cena; um nome longo parte em duas linhas em vez de tapar os lados. */
.at-centre { left: 50%; transform: translateX(-50%); width: max-content; max-width: 44%; padding: var(--space-1) var(--space-4); border-radius: 18px; background: var(--surface); border: 1px solid var(--hairline); }
.at-centre .lbl-name { text-wrap: balance; }
/* D2: no máximo 2 linhas, com reticências; o nome completo está no title e no aria-label do SVG. */
.at-centre .lbl-sub { white-space: nowrap; }
.s1 .at-centre { max-width: 52%; }
.at-centre .lbl-name { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }
.s4 .at-solar { left: 0; top: 28%; }
.s4 .at-grid { left: 0; top: 73%; }
.s4 .at-battery { right: 0; top: 28%; }
.s4 .at-ev { right: 0; top: 73%; }
.s4 .at-centre { top: 76%; left: 49%; }
.s1 .at-grid { left: 0; width: 19.5%; top: 54%; }
.s1 .at-centre { left: 61.5%; top: 80%; }
.scene-offline .lbl-val { color: var(--text-muted); }

/* ilustração */
.ill-ground { stroke: var(--ill-ground); stroke-width: 1.5; fill: none; }
.ill-shadow { fill: var(--ill-ground); opacity: 0.7; }
.ill-orb { fill: var(--ill-orb); }
.b-front { fill: var(--ill-front); stroke: var(--ill-line); stroke-width: 1.2; stroke-linejoin: round; }
.b-side { fill: var(--ill-side); stroke: var(--ill-line); stroke-width: 1.2; stroke-linejoin: round; }
.b-top { fill: var(--ill-top); stroke: var(--ill-line); stroke-width: 1.2; stroke-linejoin: round; }
.b-win { fill: var(--ill-win); }
.b-door { fill: var(--ill-line); }
.b-line { stroke: var(--ill-line); stroke-width: 1.2; fill: none; stroke-linecap: round; }
.scene-night .b-win.lit { fill: var(--ill-win-lit); }
.b-pv { fill: var(--ill-pv); stroke: var(--ill-pv-line); stroke-width: 0.8; }
.b-pv-line { stroke: var(--ill-pv-line); stroke-width: 0.6; }
.b-car { fill: var(--surface-2); stroke: var(--ill-line); stroke-width: 1.2; }
.b-tree { fill: var(--ill-side); stroke: var(--ill-line); stroke-width: 1.2; }

/* medalhões */
.medal { fill: var(--medal); stroke-width: 2; }
.medal-grid { stroke: var(--flow-grid); }
.medal-solar { stroke: var(--flow-solar); }
.medal-battery { stroke: var(--flow-battery); }
.medal-ev { stroke: var(--text); }
.medal.idle { stroke: var(--hairline); }
.n-ico { fill: none; stroke: var(--text); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.n-soc { fill: var(--flow-battery); }

/* linhas de fluxo: os pontos andam no sentido da energia; a cor é a de onde ela vem */
.flow-track { fill: none; stroke: var(--flow-track); stroke-width: 6; stroke-linecap: round; }
.flow-dots { fill: none; stroke-width: 6; stroke-linecap: round; stroke-dasharray: 0 16; animation: flow 1.6s linear infinite; }
.flow-dots.rev { animation-direction: reverse; }
.flow-dots.v1 { animation-duration: 2.6s; }
.flow-dots.v2 { animation-duration: 1.6s; }
.flow-dots.v3 { animation-duration: 0.9s; }
.c-grid { stroke: var(--flow-grid); }
.c-solar { stroke: var(--flow-solar); }
.c-battery { stroke: var(--flow-battery); }
.flow-arrow { fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.flow-idle { fill: none; stroke: var(--hairline); stroke-width: 2; stroke-dasharray: 2 6; stroke-linecap: round; }
@keyframes flow { to { stroke-dashoffset: -32; } }
.scene.paused .flow-dots { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) { .flow-dots { animation: none; } }
.scene-offline .flow-dots { animation: none; stroke: var(--control-border); stroke-dasharray: 2 8; stroke-width: 2; }
.scene-offline .flow-arrow { display: none; }
.scene-offline .medal { stroke: var(--hairline); }

/* ---------- Entrar: palco grafite ---------- */
.entry { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.stage {
	position: relative; isolation: isolate;
	display: flex; flex-direction: column; gap: var(--space-4);
	padding: calc(env(safe-area-inset-top) + var(--space-6)) var(--page-pad) var(--space-5);
	background: var(--stage-bg); color: var(--stage-text); overflow: hidden;
	/* Sempre escuro, nos dois temas: os tokens escuros do palco estão em tokens.css (.stage). */
}
.stage picture { align-self: flex-start; }
.stage .logo { height: 30px; }
.stage-scene { width: 100%; max-width: 330px; align-self: center; }
.stage-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -0.02em; }
.stage-lede, .stage-foot { display: none; }
.stage-foot a { color: var(--stage-text); }
.entry-form { display: flex; flex-direction: column; justify-content: center; gap: var(--space-4); padding: var(--space-5) var(--page-pad) var(--space-6); width: 100%; max-width: 460px; margin: 0 auto; }
.entry-form .field input { min-height: 52px; font-size: 17px; }
/* ≥1024 a casca põe os campos com o fundo da página; no Entrar ficam brancos (superfície), como na maqueta. */
@media (min-width: 1024px) { .entry-form .field input { background: var(--surface); } }
.entry-form .button { width: 100%; }
@media (min-width: 1024px) {
	.entry { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
	.stage { padding: var(--space-7) var(--space-8); gap: var(--space-6); }
	.stage .logo { height: 44px; }
	.stage-scene { max-width: 780px; align-self: flex-start; }
	.stage-title { font-size: 56px; line-height: 62px; max-width: 700px; }
	.stage-lede { display: block; color: var(--stage-muted); font-size: var(--fs-body); line-height: var(--lh-body); max-width: 520px; }
	.stage-foot { display: flex; margin-top: auto; justify-content: space-between; gap: var(--space-4); font-size: var(--fs-label); color: var(--stage-muted); }
	.entry-form { padding: var(--space-7) var(--page-pad); gap: var(--space-5); }
}
