/* What your TVs cost: a utility meter for the house. A glass-domed meter
   whose aluminium disc spins with the watts the TVs draw right now, an
   odometer for a month of TV, and a bill line per TV. Built on each skin's
   tokens (Classic, Aurora, 8-bit). */

.energy {
  position: fixed; inset: 0; z-index: 86; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg); color: var(--ink);
  padding: max(12px, var(--safe-t)) 16px calc(28px + var(--safe-b));
  animation: fadein .25s ease-out;
}
.en-wrap { max-width: 640px; margin: 0 auto; display: grid; gap: 16px; }
.en-fine { margin: 0; font-size: 11px; line-height: 1.5; color: var(--ink-soft); }
.en-lead { margin: 0; line-height: 1.5; }
.en-error { margin: 0; padding: 12px 14px; border-radius: 14px; background: #e2482a1a; color: #e2482a; font-size: 14px; line-height: 1.4; }

/* ── The meter ── */
.en-hero {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 20px; padding: 20px;
  border-radius: 28px; background: var(--body); border: 1px solid var(--body-edge); overflow: hidden; position: relative;
}
.en-hero::before { /* the faint grid of a meter's faceplate */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(90deg, transparent 0 23px, color-mix(in srgb, var(--ink) 5%, transparent) 23px 24px);
  mask-image: linear-gradient(90deg, transparent, #000 30%, #000 70%, transparent);
}
.en-meter { position: relative; width: 128px; aspect-ratio: 1; }
.en-glass {
  position: absolute; inset: 0; border-radius: 50%; padding: 9px;
  background: radial-gradient(circle at 32% 26%, #ffffffb0 0 6%, transparent 22%), radial-gradient(circle, #ffffff10 55%, #0000002a 100%);
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ink) 18%, transparent), inset 0 -10px 22px #0000002e, 0 14px 30px -14px #0008;
}
.en-plate {
  position: relative; width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #f4f1ea, #d9d4c8 70%, #bdb6a7);
  color: #3a352d;
}
.en-brand, .en-kh { position: absolute; left: 0; right: 0; text-align: center; font-size: 6.5px; letter-spacing: .14em; opacity: .75; }
.en-brand { top: 22%; }
.en-kh { bottom: 21%; }
/* The disc, seen edge-on through the slot: a thin ellipse with a black mark
   that slides across and wraps, like the real ones. */
.en-disc {
  position: relative; width: 74%; height: 12px; border-radius: 50%; overflow: hidden;
  background: linear-gradient(180deg, #8d8a84, #e8e6e1 40%, #a7a39b 60%, #6d6a63);
  box-shadow: 0 1px 0 #fff8, inset 0 0 0 1px #0004;
}
.en-disc i {
  position: absolute; top: 0; bottom: 0; width: 18%; left: -18%; background: linear-gradient(90deg, #111 0 60%, #c2382a 60%);
  border-radius: 2px; animation: en-spin var(--rev, 3s) linear infinite; animation-play-state: var(--play, running);
}
@keyframes en-spin { to { left: 100%; } }

.en-total { position: relative; min-width: 0; display: grid; gap: 6px; }
.en-total .kicker { margin: 0; }
.en-sub { margin: 0; font-size: 11px; color: var(--ink-soft); line-height: 1.5; }
.en-sub b { color: var(--signal); }
.en-live { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.en-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--led-off); }
.en-dot.on { background: var(--led-on); box-shadow: 0 0 10px var(--led-on); animation: en-pulse 1.6s ease-in-out infinite; }
@keyframes en-pulse { 50% { opacity: .45; } }

/* Odometer: one drum per digit, rolling into place one after another. */
.en-odo { display: flex; align-items: flex-end; font: 750 clamp(40px, 12vw, 58px)/1 var(--display); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.en-drum { display: inline-block; height: 1em; overflow: hidden; }
.en-drum > span { display: grid; transform: translateY(calc(var(--d) * -1em)); animation: en-roll 1.1s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i) * 70ms); }
.en-drum b { height: 1em; line-height: 1; font-weight: inherit; }
.en-sep { line-height: 1; }
@keyframes en-roll { from { transform: translateY(0); } }

/* ── Price per kWh ── */
.en-price { display: grid; grid-template-columns: auto 1fr; gap: 14px 16px; align-items: center; padding: 18px; border-radius: 24px; background: var(--body); border: 1px solid var(--body-edge); }
.en-price.from-bill { border-color: color-mix(in srgb, var(--signal) 45%, var(--body-edge)); }
.en-price.fresh { animation: en-fresh 1.4s ease-out; }
@keyframes en-fresh { from { box-shadow: 0 0 0 6px var(--signal-soft), 0 0 40px -6px var(--signal); } }
.en-rate { display: grid; justify-items: center; padding: 10px 14px; border-radius: 16px; background: var(--signal-soft); color: var(--signal); }
.en-rate b { font-size: 26px; letter-spacing: -.02em; }
.en-rate small { font-size: 8px; text-transform: uppercase; letter-spacing: .14em; }
.en-rate-meta { display: grid; gap: 4px; min-width: 0; }
.en-rate-meta p:first-child { margin: 0; font-weight: 650; }
.en-price-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.en-price-actions .small { min-height: 42px; padding: 0 16px; font-size: 13px; }

/* ── One bill line per TV ── */
.en-list { display: grid; gap: 10px; }
.en-tv { display: grid; gap: 12px; padding: 16px; border-radius: 22px; background: var(--body); border: 1px solid var(--body-edge); }
.en-tv header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.en-tv h3 { margin: 0 0 3px; font-size: 18px; letter-spacing: -.02em; }
.en-tv-cost { display: grid; justify-items: end; flex: none; }
.en-tv-cost b { font-size: 22px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.en-tv-cost small { font-size: 8px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); }
.en-bars { display: flex; align-items: flex-end; gap: 3px; height: 46px; }
.en-bars i { flex: 1; height: var(--h); min-height: 2px; border-radius: 3px 3px 1px 1px; background: linear-gradient(180deg, var(--signal), color-mix(in srgb, var(--signal) 45%, transparent)); transform-origin: bottom; animation: en-grow .6s cubic-bezier(.2, .8, .2, 1) both; }
.en-bars i:last-child { box-shadow: 0 0 12px -2px var(--signal); }
@keyframes en-grow { from { transform: scaleY(0); } }
.en-tv-foot { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.en-watts summary { cursor: pointer; list-style: none; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--signal); }
.en-watts summary::-webkit-details-marker { display: none; }
.en-watts form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; margin: 10px 0 6px; }
.en-watts label { display: grid; gap: 4px; }
.en-watts label small { font-size: 8px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-soft); }
.en-watts input, .en-type-form input {
  width: 100%; min-width: 0; min-height: 44px; padding: 0 12px; border-radius: 12px; font: 600 16px var(--mono);
  background: var(--bg); color: var(--ink); border: 1px solid var(--body-edge);
}
.en-watts input:focus, .en-type-form input:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.en-honest { padding: 0 4px; }

/* ── Adding a bill ── */
.en-pick { display: grid; gap: 12px; }
.en-drop {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 14px; row-gap: 3px; align-items: center;
  padding: 18px; border-radius: 22px; cursor: pointer; background: var(--body); border: 1.5px dashed var(--body-edge);
  transition: border-color .15s, transform .1s;
}
.en-drop:active { transform: scale(.985); border-color: var(--signal); }
.en-drop .en-ico { grid-row: span 2; font-size: 30px; }
.en-drop small { color: var(--ink-soft); line-height: 1.4; }
.en-review { display: grid; gap: 14px; }
.en-lines { margin: 0; padding: 12px 12px 12px 34px; max-height: 46dvh; overflow: auto; border-radius: 16px; background: var(--body); border: 1px solid var(--body-edge); font-size: 11px; line-height: 1.6; }
.en-lines li::marker { color: var(--ink-faint); }
.en-crop { display: grid; gap: 14px; }
.en-stage { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 14px; overflow: hidden; background: #000; }
.en-stage img { display: block; width: 100%; height: auto; pointer-events: none; }
.en-box { position: absolute; border: 2px solid var(--signal); border-radius: 6px; box-shadow: 0 0 0 9999px #000a; }
.en-box i { position: absolute; width: 14px; height: 14px; border: 3px solid #fff; }
.en-box i:nth-child(1) { left: -4px; top: -4px; border-right: 0; border-bottom: 0; }
.en-box i:nth-child(2) { right: -4px; top: -4px; border-left: 0; border-bottom: 0; }
.en-box i:nth-child(3) { left: -4px; bottom: -4px; border-right: 0; border-top: 0; }
.en-box i:nth-child(4) { right: -4px; bottom: -4px; border-left: 0; border-top: 0; }
.en-reading { display: grid; justify-items: center; gap: 12px; padding: 40px 0; text-align: center; }
.en-reading .en-meter { width: 168px; }
.en-type { display: grid; gap: 14px; }
.en-type-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
.en-type-form input { font-size: 28px; min-height: 64px; text-align: center; }
.en-type-form .cta { grid-column: 1 / -1; }

@media (max-width: 380px) {
  .en-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .en-odo { justify-content: center; }
  .en-live { justify-content: center; }
  .en-meter { width: 112px; }
  .en-watts form { grid-template-columns: 1fr 1fr; }
  .en-watts form .cta { grid-column: 1 / -1; }
}

/* Aurora: glass panels over the night sky. */
[data-skin="aurora"] :is(.en-hero, .en-price, .en-tv, .en-drop, .en-lines) { background: var(--glass-1); border-color: var(--hair); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
[data-skin="aurora"] .en-price.from-bill { border-color: #ff6a2b66; }

/* 8-bit: an LCD utility meter. */
[data-skin="8bit"] :is(.en-hero, .en-price, .en-tv, .en-drop, .en-lines, .en-rate, .en-stage, .en-watts input, .en-type-form input) { border-radius: 0; }
[data-skin="8bit"] .en-glass, [data-skin="8bit"] .en-plate { border-radius: 0; }
[data-skin="8bit"] .en-plate { background: var(--lcd-2); color: var(--lcd-0); }
[data-skin="8bit"] .en-disc { border-radius: 0; height: 10px; background: var(--lcd-1); }
[data-skin="8bit"] .en-disc i { background: var(--lcd-0); border-radius: 0; animation-timing-function: steps(8); }
[data-skin="8bit"] .en-odo { font-family: var(--display); font-size: 26px; }
[data-skin="8bit"] .en-drum > span { animation-timing-function: steps(10); }
[data-skin="8bit"] .en-bars i { border-radius: 0; background: var(--lcd-0); }
[data-skin="8bit"] .en-tv h3, [data-skin="8bit"] .en-tv-cost b, [data-skin="8bit"] .en-rate b { font-family: var(--display); font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .en-disc i, .en-dot.on, .en-drum > span, .en-bars i, .en-price.fresh { animation: none; }
}
