/* ajiths.in -- the face of the Ajithalayam power-flow card (its glass is glass.js).

   A copy of the /solar "Power Flow Card" (A102's flowcard.css plus the demo's
   demo.css), scoped under .solar-face and designed at a fixed 410 x 340 px, the
   card's size on /solar. glass.js scales the whole face as one unit with --k, so
   every length here is a design pixel and nothing needs to be fluid.

   The face is printed ON the glass -- z 2, above the refraction layer and below
   the lighting, exactly as .glass-print is for the credit card. It is opaque
   white at all times, for readability: the rain showing through it on the move
   (until 2026-11-06) read as blur over the figures, so that is gone. Same CSP as the
   rest of the site: Roboto is self-hosted, the KSEB mark is a same-origin SVG,
   and nothing is styled inline (solarcard.js sets widths through the CSSOM,
   which the policy allows). */

/* Roboto 300 + 400, one variable woff2 (Google Fonts v51, latin), as on /solar. */
@font-face {
  font-family: "Roboto";
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url("/fonts/roboto-latin.woff2?v=1") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

.solar-card { --k: 1; }            /* glass.js: slab width / 410 */

.solar-face {
  --text: #1c2733;
  --muted: #7b8794;
  --border: #e8ecf1;
  --accent: #0ea5e9;               /* the Ajithalayam accent on /solar */
  --solar: #ff5a1f;
  --grid: #7c3aed;
  --ret: #a855f7;
  --batt: #10b981;
  --batt-out: #0ea5e9;
  --load: #3b82f6;

  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: 410px;
  height: 340px;
  padding: 14px 18px 12px;
  transform: scale(var(--k));
  transform-origin: 0 0;
  background: #fff;
  transition: background-color .4s ease;
  color: var(--text);
  font: 300 13px/1.3 Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: auto;
}

.solar-face * { box-sizing: border-box; }

/* The whole face is a drag handle (glass.css: `.glass-card > *` has no
   pointer events); only the tools (the switch and the Fix button) take
   their own clicks. */
.solar-face .sc-tools { pointer-events: auto; }

/* Focus has to survive `outline: none` -- underline the name instead. */
.solar-card:focus-visible .sc-title {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .3em;
}

/* The glass lighting is tuned for a clear slab; on a white face the tint and
   the bevel's dark foot are eased, or the card reads as grey. */
.solar-card .glass-tint  { opacity: .5; }
.solar-card .glass-bevel { opacity: .7; }
.solar-card .glass-caustic { opacity: .14; }

/* The face, the circles and the pill stay solid on the move too (no
   see-through, no blur over the figures). glass.js still toggles .is-moving. */
.solar-face .circle,
.sc-state { transition: background-color .4s ease; }

/* ------------------------------------------------------------------ head */

.sc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 6px;
}

.sc-eyebrow {
  margin: 0 0 3px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 400;
  letter-spacing: .1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.sc-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.2;
}

/* installed capacity beside the site name, then the live dot */
.sc-cap {
  padding: 1px 7px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.sc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px rgba(14, 165, 233, .65);
}

.sc-title.live .sc-dot    { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, .6); }
.sc-title.offline .sc-dot { background: #ef4444; box-shadow: 0 0 6px rgba(239, 68, 68, .6); }

.sc-tools {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

/* Power / Energy switch */
.sc-mode {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 2px;
  border-radius: 999px;
  background: #dcfce7;
  cursor: default;
}

/* The pin, as on a sticky note: tilted while the card is loose, upright and
   filled once it is pinned (glass.js toggles aria-pressed) */
.sc-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.sc-pin svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  transform: rotate(45deg);
  transition: transform .25s ease;
}

.sc-pin:hover { color: var(--text); }

.sc-pin[aria-pressed="true"] {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #fff;
}

.sc-pin[aria-pressed="true"] svg { transform: none; }

.sc-pin:focus-visible {
  outline: 2px solid #1d4ed8;
  outline-offset: 1px;
}

.sc-mode button {
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #15803d;
  font: 400 11px Roboto, "Segoe UI", sans-serif;
  cursor: pointer;
}

.sc-mode button.on {
  background: #15803d;
  color: #fff;
}

.sc-mode button:focus-visible {
  outline: 2px solid #15803d;
  outline-offset: 1px;
}

/* ------------------------------------------------------------------ flow */

/* A102's flow is laid out at 480 x 356; /solar shows it at 0.75. */
.sc-mount {
  position: relative;
  width: 360px;
  height: 267px;
  margin: 0 auto;
}

.solar-face .flow {
  position: absolute;
  top: 0;
  left: 0;
  width: 480px;
  height: 356px;
  transform: scale(.75);
  transform-origin: 0 0;
}

.solar-face .flow-lines {
  position: absolute;
  inset: 0;
  overflow: visible;
}

.solar-face .line {
  fill: none;
  stroke-width: 2;
  opacity: .35;
}

.solar-face .line.solar      { stroke: var(--solar); }
.solar-face .line.grid       { stroke: var(--grid); }
.solar-face .line.battery    { stroke: var(--batt-out); }
.solar-face .line.battery-in { stroke: var(--batt); }
.solar-face .line.return     { stroke: var(--ret); }

.solar-face .dot {
  opacity: 0;
  transition: opacity .4s;
}

.solar-face .dot.on         { opacity: 1; }
.solar-face .dot.solar      { fill: var(--solar); }
.solar-face .dot.grid       { fill: var(--grid); }
.solar-face .dot.battery    { fill: var(--batt-out); }
.solar-face .dot.battery-in { fill: var(--batt); }
.solar-face .dot.return     { fill: var(--ret); }

.solar-face .node {
  position: absolute;
  display: flex;
  width: 88px;
  align-items: center;
  flex-direction: column;
  gap: 4px;
}

.solar-face .node-solar   { left: 196px; top: 6px; }
.solar-face .node-grid    { left: 8px;   top: 140px; }
.solar-face .node-home    { left: 384px; top: 140px; }
.solar-face .node-battery { left: 196px; top: 256px; }

.solar-face .label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .2px;
  white-space: nowrap;
}

.solar-face .circle {
  position: relative;
  display: flex;
  width: 80px;
  height: 80px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  border: 2px solid;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(16, 30, 54, .07);
}

.solar-face .circle.solar   { border-color: var(--solar); }
.solar-face .circle.grid    { border-color: var(--grid); }
.solar-face .circle.battery { border-color: var(--batt); }
.solar-face .circle.home    { border: 0; }

.solar-face .circle .icon {
  width: 22px;
  height: 22px;
  fill: var(--text);
}

/* KSEB mark in the grid circle: the SVG over a text fallback */
.solar-face .kseb-mark {
  position: relative;
  display: grid;
  width: 54px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
}

.solar-face .kseb-mark > * { grid-area: 1 / 1; }

.solar-face .kseb-fallback {
  color: #0d3f8a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
}

.solar-face .kseb-logo {
  display: block;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: #fff;
  object-fit: contain;
}

.solar-face .kseb-logo[hidden] { display: none; }

.solar-face .circle .icon.icon-solar {
  width: 28px;
  height: 28px;
  overflow: visible;
  filter: drop-shadow(0 1px 1px rgba(30, 64, 175, .18));
}

.solar-face .solar-rays       { fill: none; stroke: #f59e0b; stroke-linecap: round; stroke-width: 1.7; }
.solar-face .solar-sun        { fill: #facc15; stroke: #f59e0b; stroke-width: 1; }
.solar-face .solar-panel      { fill: #2563eb; stroke: #1d4ed8; stroke-linejoin: round; stroke-width: 1.2; }
.solar-face .solar-panel-grid { fill: none; stroke: #dbeafe; stroke-width: .9; }
.solar-face .solar-stand      { fill: none; stroke: #475569; stroke-linecap: round; stroke-width: 1.6; }

.solar-face .circle .icon.icon-home {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 1px rgba(2, 132, 199, .18));
}

.solar-face .home-body   { fill: #38bdf8; stroke: #0284c7; stroke-width: 1; }
.solar-face .home-roof   { fill: #fb7185; stroke: #e11d48; stroke-linejoin: round; stroke-width: 1; }
.solar-face .home-window { fill: #fde047; stroke: #f59e0b; stroke-width: .8; }
.solar-face .home-door   { fill: #2563eb; }
.solar-face .home-knob   { fill: #fff7ed; }

.solar-face .circle .icon.icon-battery {
  width: 29px;
  height: 21px;
  filter: drop-shadow(0 1px 1px rgba(5, 150, 105, .2));
}

.solar-face .battery-terminal { fill: #059669; }
.solar-face .battery-shell    { fill: #ecfdf5; stroke: #059669; stroke-width: 1.5; }
.solar-face .battery-level-1  { fill: #34d399; }
.solar-face .battery-level-2  { fill: #22c55e; }
.solar-face .battery-level-3  { fill: #14b8a6; }
.solar-face .battery-level-4  { fill: #0ea5e9; }
.solar-face .battery-bolt     { fill: #fff; stroke: #047857; stroke-linejoin: round; stroke-width: .55; }

/* readings: one font, black, on every node; grid and battery bold */
.solar-face .circle .value,
.solar-face .circle .soc,
.solar-face .circle .mini {
  color: #000;
  font-size: 11px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.solar-face .mini {
  display: flex;
  align-items: center;
  gap: 1px;
}

.solar-face .mini-icon {
  width: 10px;
  height: 10px;
  fill: currentColor;
}

.solar-face .node-grid .value,
.solar-face .node-grid .mini,
.solar-face .node-battery .value,
.solar-face .node-battery .soc,
.solar-face .node-battery .mini {
  font-weight: 700;
}

/* the load ring: three arcs, solar / grid / battery shares of the load */
.solar-face .circle.home .ring {
  position: absolute;
  inset: 0;
  width: 80px;
  height: 80px;
  transform: rotate(-90deg);
}

.solar-face .ring-bg {
  fill: none;
  stroke: #e8ecf1;
  stroke-width: 6;
}

.solar-face .ring-seg {
  fill: none;
  stroke-linecap: butt;
  stroke-width: 6;
}

.solar-face .ring-seg.solar   { stroke: var(--solar); }
.solar-face .ring-seg.grid    { stroke: var(--grid); }
.solar-face .ring-seg.battery { stroke: var(--batt-out); }

/* ------------------------------------------------------------ state pill */

/* /solar shows the site's state in a header pill; here it sits in the card. */
.sc-state {
  position: absolute;
  left: 18px;
  bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px 3px 7px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(16, 30, 54, .06);
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
  white-space: nowrap;
}

.sc-state i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, .13);
}

.sc-state.live      { color: #078251; }
.sc-state.live i    { background: #10b981; box-shadow: 0 0 0 2px rgba(16, 185, 129, .13); }
.sc-state.offline   { color: #dc5656; }
.sc-state.offline i { background: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, .12); }

/* --------------------------------------------------------------- packs */

/* JK BMS batteries, bottom right (solarcard.js showPacks): horizontal glass
   cylinders, chrome end caps, green fill, one per pack, filled to its SOC. */
.sc-packs {
  position: absolute;
  right: 14px;
  bottom: 12px;
  display: grid;
  gap: 6px;
}

.sc-packs[hidden] { display: none; }

.bms-pack {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #334155;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.bms-pack > span { min-width: 52px; }

.bms-body {
  position: relative;
  width: 74px;
  height: 26px;
  margin-left: 5px;
  border-left: 4px solid #9aa3a8;
  border-right: 4px solid #9aa3a8;
  border-radius: 5px;
  border-color: #c3cacd;
  background: linear-gradient(180deg, #ffffff 0%, #e9eef0 30%, #fbfcfc 55%, #d5dcdf 85%, #f3f5f6 100%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), -1px 0 0 #7f888d, 1px 0 0 #7f888d,
    0 4px 6px -2px rgba(16, 30, 54, .3);
}

.bms-body::before {
  position: absolute;
  top: 7px;
  left: -10px;
  width: 6px;
  height: 12px;
  border-radius: 3px 0 0 3px;
  background: linear-gradient(180deg, #e8ecee, #8f989d 50%, #d9dee0);
  content: "";
}

.bms-fill {
  position: absolute;
  inset: 1px 0 1px auto;
  background: linear-gradient(180deg, #2f9e2f 0%, #45c43d 18%, #7fe36a 30%, #34b02f 48%, #239c25 70%, #4cc843 88%, #1c8a1f 100%);
  transition: width .6s ease;
}

.bms-body::after {
  position: absolute;
  inset: 3px 2px auto;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, .15), rgba(255, 255, 255, .75), rgba(255, 255, 255, .15));
  content: "";
}

.bms-body b {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.bms-pack.low .bms-fill {
  background: linear-gradient(180deg, #b91c1c, #f87171 30%, #dc2626 55%, #991b1b);
}

/* ------------------------------------------------------- small screens */

/* On a phone the face is scaled to about 0.8; /solar's own phone rules
   enlarge the readings the same way. */
@media (max-width: 560px) {
  .solar-face .label { font-size: 15px; }
  .solar-face .circle .value,
  .solar-face .circle .soc { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .solar-face,
  .solar-face .circle,
  .sc-state,
  .solar-face .dot { transition: none; }
  .bms-fill { transition: none; }
}
