/* =========================================================
   ArcNode web demo — shell (page, iPad frame, app chrome, shared components)
   All app dimensions are iOS points on a 1194×834 landscape canvas (1pt = 1px),
   and the whole screen is scaled to fit the browser via --scale.
   ========================================================= */

@font-face {
  font-family: 'Petrona';
  src: url('../fonts/Petrona-VariableFont_wght.woff2') format('woff2');
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Petrona';
  src: url('../fonts/Petrona-Italic-VariableFont_wght.woff2') format('woff2');
  font-weight: 100 900; font-style: italic; font-display: swap;
}

:root {
  /* ArcDS dark tokens */
  --primary: #767DFB;
  --primary-light: #9B9FFC;
  --primary-text: #5B63E0;
  --yellow: #FFE381;
  --green: #2ABC53;
  --red: #FF6565;
  --blue: #5B9BD5;
  --orange: #FF9800;
  --sys-green: #30D158;
  --sys-gray: #8E8E93;

  --fg-primary: #F5F1EB;
  --fg-primary-warm: #FFFDFA;
  --fg-secondary: #A8A7A7;
  --fg-tertiary: #8E8D8A;
  --fg-secondary-light: #383838;

  --primary-bg: #38383C;
  --bg-inlay: #242526;
  --bg-elevated: #1C1C1C;
  --bg-gray: #454545;
  --bg-green: #1C3424;
  --bg-card: #242424;
  --bg-control: #3A3A3A;
  --bg-deep: #2C2C2C;
  --bg-blue-badge: #1C2434;
  --grey400: #393A4B;
  --grey500: #858699;
  --divider: #444444;
  --stroke: #A5A5A5;
  --menu-grey: #4B4B4B;
  --button-primary-text: #242526;

  --glass-bg: rgba(28, 28, 28, 0.85);
  --glass-selected-pill: rgba(255, 255, 255, 0.10);
  --glass-selected-text: #FFFFFF;
  --glass-default-text: #A8A7A7;
  --glass-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", Inter, "Helvetica Neue", Arial, sans-serif;
  --font-display: 'Petrona', Georgia, serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;

  --ease-spring: cubic-bezier(.2, .9, .3, 1);
  --margin: 32px;
  --safe-top: 24px;       /* fake iOS status bar height */

  --screen-w: 1194px;
  --screen-h: 834px;
  --scale: 1;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% 40%, #232327 0%, #111112 70%) fixed, #111112;
  color: var(--fg-primary);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { display: block; }

/* ---------- Main site nav (styles come from ../css/styles.css) ---------- */
/* The demo page never scrolls, so the nav always uses its compact "scrolled" look.
   The link to this page stays underlined as the current page. */
.nav-links a[aria-current="page"]::after { transform: scaleX(1); }
.mobile-menu-inner a[aria-current="page"] { opacity: .6; }

/* ---------- Stage + iPad frame ---------- */
.stage {
  /* top is set from the nav's height in shell.js fit() */
  position: fixed; inset: 112px 0 0 0;
  display: flex; align-items: center; justify-content: center;
}
.ipad {
  /* Outer frame size = screen + bezel, then scaled */
  --bezel: 22px;
  width: calc(var(--screen-w) + var(--bezel) * 2);
  height: calc(var(--screen-h) + var(--bezel) * 2);
  transform: scale(var(--scale));
  transform-origin: center center;
  flex: none;
}
.ipad__bezel {
  position: relative; width: 100%; height: 100%;
  padding: var(--bezel);
  background: #0B0B0C;
  border-radius: 48px;
  box-shadow:
    0 0 0 2px #2A2A2E,
    0 0 0 3px #0A0A0A,
    0 40px 120px rgba(0, 0, 0, 0.6),
    0 10px 40px rgba(0, 0, 0, 0.5);
}
.ipad__camera {
  position: absolute; top: 50%; left: 9px; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: #1B1B22; box-shadow: inset 0 0 1px 1px #26262E;
}
.screen {
  position: relative; width: var(--screen-w); height: var(--screen-h);
  border-radius: 26px; overflow: hidden;
  background: var(--primary-bg);
  font-family: var(--font-ui);
  color: var(--fg-primary);
  isolation: isolate;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.screen input, .screen textarea { user-select: text; -webkit-user-select: text; }
.screen ::-webkit-scrollbar { display: none; }
.screen * { scrollbar-width: none; }

.rotate-hint {
  display: none; position: fixed; left: 0; right: 0; bottom: 18px;
  text-align: center; font-size: 13px; color: #8E8D8A;
}
@media (orientation: portrait) and (max-width: 820px) { .rotate-hint { display: block; } }

/* ---------- Status bar ---------- */
.statusbar {
  position: absolute; top: 0; left: 0; right: 0; height: var(--safe-top); z-index: 400;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px 0 26px; font-size: 13px; font-weight: 600; color: #fff;
  pointer-events: none;
}
.statusbar__right { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.screen[data-tab="home"] .statusbar { text-shadow: 0 1px 2px rgba(0,0,0,.25); }

/* ---------- Tab root ---------- */
.tab-root { position: absolute; inset: 0; z-index: 1; }
.tab-page { position: absolute; inset: 0; animation: arc-fade-in .25s ease-in-out; }
@keyframes arc-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Icons ---------- */
.arc-icon { display: inline-block; flex: none; vertical-align: middle; }

/* ---------- Header bar (DashboardHeaderBar) ---------- */
.arc-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(var(--safe-top) + 32px) 32px 8px;
  color: var(--fg-primary);
  transition: padding-top .35s var(--ease-spring);
  position: relative; z-index: 5;
}
.arc-header--home { color: #fff; }
.arc-header__left { display: flex; align-items: center; gap: 10px; }
.arc-header__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sys-green); transform: translateY(2px); }
.arc-header__logo { height: 24px; width: auto; }
.arc-header__right { display: flex; align-items: center; gap: 16px; font-size: 16px; }
.arc-header__batt { display: flex; align-items: center; gap: 4px; }
.arc-header__temps { display: flex; gap: 16px; }
.arc-header__score {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(245, 241, 235, 0.15); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .3s var(--ease-spring), opacity .3s;
}
.arc-header--home .arc-header__score { background: rgba(255, 255, 255, 0.15); }
.arc-header__score.is-hidden { transform: scale(.4); opacity: 0; pointer-events: none; width: 0; margin-left: -16px; }
.arc-header__bell { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; position: relative; }
.arc-header__avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: var(--button-primary-text); font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Bottom bar (GlassTabBar + AI button) ---------- */
.bottom-bar {
  position: absolute; left: 0; right: 0; bottom: 16px; height: 80px; z-index: 300;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  transition: transform .3s ease-in-out, opacity .3s ease-in-out;
}
.bottom-bar.is-hidden { transform: translateY(40px); opacity: 0; }
.bottom-bar.is-hidden * { pointer-events: none !important; }
.glass {
  background: var(--glass-bg);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--glass-shadow);
  position: relative;
}
.glass::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(135deg, rgba(255,255,255,.30) 0%, rgba(255,255,255,.05) 50%, rgba(255,255,255,.20) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
}
.tabbar {
  pointer-events: auto;
  height: 80px; padding: 4px; border-radius: 131px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  transform: translateX(56px);
}
.tabbar__item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 24px; border-radius: 32px;
  color: var(--glass-default-text);
  transition: background .2s ease-in-out, color .2s ease-in-out;
}
.tabbar__item.is-active { background: var(--glass-selected-pill); color: var(--glass-selected-text); }
.tabbar__label { font-size: 14px; display: grid; }
.tabbar__label > span { grid-area: 1 / 1; text-align: center; }
.tabbar__label .ghost { font-weight: 700; visibility: hidden; }
.tabbar__item.is-active .tabbar__label .real { font-weight: 700; }
.ai-btn {
  pointer-events: auto;
  position: absolute; right: 32px; top: 0;
  width: 80px; height: 80px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--glass-default-text); font-size: 14px;
}

/* ---------- Overlays / modals ---------- */
.overlay-root { position: absolute; inset: 0; z-index: 200; pointer-events: none; }
.overlay-root > * { pointer-events: auto; }
.arc-modal {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  animation: arc-fade-in .25s ease-out;
}
.arc-modal.is-closing { animation: arc-fade-out .25s ease-in forwards; }
@keyframes arc-fade-out { to { opacity: 0; } }
.arc-modal__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.8); }
.arc-modal__scrim--blur { background: rgba(0, 0, 0, 0.75); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.arc-modal__card {
  position: relative; max-height: calc(100% - 48px); overflow: auto;
  animation: arc-pop-in .3s var(--ease-spring);
}
.arc-modal.is-closing .arc-modal__card { animation: arc-pop-out .25s ease-in forwards; }
@keyframes arc-pop-in { from { transform: scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes arc-pop-out { to { transform: scale(.96); opacity: 0; } }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; color: var(--fg-secondary); }

/* ---------- Toast (ToastOverlay) ---------- */
.toast-root { position: absolute; left: 32px; bottom: 40px; z-index: 350; pointer-events: none; }
.arc-toast {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 6px;
  background: var(--green); color: #fff; font-size: 13px;
  animation: arc-toast-in .3s ease-out;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
}
.arc-toast--info { background: #3A3A3A; }
.arc-toast.is-leaving { animation: arc-fade-out .5s ease-in forwards; }
@keyframes arc-toast-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Shared controls ---------- */
/* iOS switch: <button class="ios-switch" role="switch" aria-checked="true"> */
.ios-switch {
  width: 51px; height: 31px; border-radius: 15.5px; flex: none;
  background: rgba(120, 120, 128, 0.32); position: relative;
  transition: background .2s ease-in-out;
}
.ios-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06);
  transition: transform .2s ease-in-out;
}
.ios-switch[aria-checked="true"] { background: var(--switch-tint, var(--primary)); }
.ios-switch[aria-checked="true"]::after { transform: translateX(20px); }

/* iOS slider: <input type="range" class="ios-slider" style="--val:50%"> */
.ios-slider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer;
  --val: 50%;
}
.ios-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--slider-fill, var(--primary)) var(--val), rgba(120,120,128,.32) var(--val));
}
.ios-slider::-moz-range-track { height: 4px; border-radius: 2px; background: rgba(120,120,128,.32); }
.ios-slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--slider-fill, var(--primary)); }
.ios-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 28px; height: 28px; border-radius: 50%; margin-top: -12px;
  background: #fff; box-shadow: 0 0.5px 4px rgba(0,0,0,.12), 0 6px 13px rgba(0,0,0,.12);
}
.ios-slider::-moz-range-thumb {
  width: 28px; height: 28px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: 0 0.5px 4px rgba(0,0,0,.12), 0 6px 13px rgba(0,0,0,.12);
}

/* StatusBadge */
.status-badge {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 10px; font-weight: 500; line-height: 1.3;
  padding: 2px 8px; border-radius: 4px; border: 1px solid currentColor;
  color: var(--green); background: var(--bg-green);
}
.status-badge--purple { color: var(--primary); background: var(--bg-green); }
.status-badge--gray { color: var(--sys-gray); background: rgba(142,142,147,.2); }
.status-badge--blue { color: var(--blue); background: var(--bg-blue-badge); }
.status-badge--red { color: #FF453A; background: rgba(255,69,58,.2); }

/* ---------- Score modal (shared) ---------- */
.score-modal { width: 400px; padding: 30px 32px; background: var(--bg-inlay); border-radius: 16px; display: flex; flex-direction: column; gap: 10px; }
.score-modal__title { display: flex; justify-content: space-between; align-items: center; font-size: 20px; margin-bottom: 16px; }
.score-modal__center { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 16px; text-align: center; }
.score-ring { position: relative; width: 94px; height: 94px; }
.score-ring svg { width: 94px; height: 94px; transform: rotate(-90deg); }
.score-ring__num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 40px; font-weight: 700; }
.score-modal__desc { font-size: 16px; line-height: 20px; }
.btn-primary {
  height: 40px; width: 100%; border-radius: 4px; background: var(--primary); color: var(--button-primary-text); font-size: 16px;
}
.btn-link { height: 24px; font-size: 14px; text-decoration: underline; color: var(--fg-primary); align-self: center; }

/* ---------- PIN gate (shared) ---------- */
.pin-card { width: calc(100% - 80px); max-width: 420px; background: var(--bg-elevated); border-radius: 24px; }
.pin-card__head { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 12px 12px 0; }
.pin-card__title { text-align: center; font-size: 18px; font-weight: 600; }
.pin-card__close { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; color: var(--fg-primary); }
.pin-card__body { padding: 0 20px 20px; display: flex; flex-direction: column; align-items: center; }
.pin-card__lock { width: 64px; height: 64px; border-radius: 50%; background: rgba(118,125,251,.12); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.pin-card__msg { font-size: 14px; color: var(--fg-secondary); text-align: center; padding: 0 8px; margin-bottom: 8px; white-space: pre-line; }
.pin-card__ack { display: flex; gap: 8px; padding: 12px; background: rgba(255,227,129,.08); border: 1px solid rgba(255,227,129,.3); border-radius: 8px; margin-bottom: 12px; font-size: 14px; line-height: 1.35; }
.pin-card__ack .arc-icon { color: var(--yellow); margin-top: 2px; }
.pin-dots { display: flex; gap: 16px; padding: 10px 0; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--fg-tertiary); transition: background .15s; }
.pin-dot.is-filled { background: var(--primary); box-shadow: none; }
.pin-dots.is-error .pin-dot { box-shadow: inset 0 0 0 1.5px var(--red); }
.pin-dots.is-error .pin-dot.is-filled { background: var(--red); }
.pin-dots.is-shaking { animation: arc-shake .35s; }
@keyframes arc-shake { 20%,60% { transform: translateX(-8px); } 40%,80% { transform: translateX(8px); } }
.pin-error { font-size: 12px; color: var(--red); min-height: 16px; }
.pin-hint { font-size: 12px; color: var(--fg-tertiary); margin-top: 2px; }
.pin-hint b { color: var(--fg-secondary); font-weight: 600; letter-spacing: .1em; }
.pin-pad { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 8px 0 16px; }
.pin-key { height: 54px; border-radius: 12px; background: var(--bg-inlay); font-size: 24px; font-weight: 500; display: flex; align-items: center; justify-content: center; color: var(--fg-primary); }
.pin-key:active { background: #34353A; }
.pin-key--blank { background: transparent; pointer-events: none; }
.pin-unlock { width: 100%; padding: 16px 0; border-radius: 12px; font-size: 16px; font-weight: 600; background: var(--bg-control); color: var(--fg-secondary); }
.pin-unlock:not(:disabled) { background: var(--primary); color: var(--button-primary-text); }

/* ---------- Battery impact modal (shared) ---------- */
.bi-card { width: calc(100% - 80px); max-width: 500px; background: var(--bg-card); border-radius: 24px; }
.bi-head { position: relative; padding: 20px; text-align: center; font-size: 18px; font-weight: 600; }
.bi-head .pin-card__close { position: absolute; right: 8px; top: 8px; }
.bi-body { padding: 0 20px 8px; display: flex; flex-direction: column; gap: 16px; }
.bi-dev { display: flex; align-items: center; gap: 12px; }
.bi-dev__icon { width: 48px; height: 48px; border-radius: 12px; background: rgba(118,125,251,.15); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.bi-dev__name { font-size: 18px; font-weight: 600; }
.bi-dev__learned { font-size: 12px; color: var(--fg-tertiary); display: flex; align-items: center; gap: 4px; }
.bi-dev__learned .arc-icon { color: var(--primary); }
.bi-dev__watts { margin-left: auto; font-size: 16px; font-weight: 700; color: var(--primary); background: rgba(118,125,251,.15); padding: 6px 12px; border-radius: 8px; }
.bi-divider { height: 1px; background: rgba(142,141,138,.2); }
.bi-sub { font-size: 14px; font-weight: 500; color: var(--fg-secondary); }
.bi-rows { display: flex; flex-direction: column; gap: 12px; }
.bi-row { display: flex; align-items: center; gap: 12px; }
.bi-row__label { width: 64px; font-size: 13px; color: var(--fg-secondary); }
.bi-row__bar { flex: 1; height: 10px; border-radius: 5px; background: rgba(142,141,138,.2); overflow: hidden; }
.bi-row__bar > span { display: block; height: 100%; border-radius: 5px; transform-origin: left; animation: bi-grow .6s var(--ease-spring); }
@keyframes bi-grow { from { transform: scaleX(0); } }
.bi-row__pct { width: 40px; text-align: right; font-size: 13px; font-weight: 500; }
.bi-runtime { display: flex; align-items: center; gap: 8px; padding: 12px; background: var(--bg-inlay); border-radius: 10px; font-size: 14px; }
.bi-runtime .tag { font-size: 10px; font-weight: 500; color: var(--primary); background: rgba(118,125,251,.12); padding: 2px 6px; border-radius: 4px; }
.bi-runtime .solar { margin-left: auto; font-size: 12px; color: var(--primary); display: flex; align-items: center; gap: 4px; }
.bi-risk { display: flex; align-items: center; gap: 8px; padding: 12px; background: rgba(255,101,101,.1); border-radius: 10px; font-size: 13px; color: var(--fg-secondary); }
.bi-risk .arc-icon { color: var(--red); }
.bi-actions { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.bi-on { width: 100%; padding: 16px 0; border-radius: 12px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.bi-cancel { font-size: 16px; font-weight: 500; color: var(--fg-secondary); padding: 4px; }

/* ---------- Generic "not in demo" info modal ---------- */
.info-card { width: 420px; background: var(--bg-inlay); border-radius: 16px; padding: 28px 28px 22px; display: flex; flex-direction: column; gap: 12px; text-align: center; align-items: center; }
.info-card__icon { width: 56px; height: 56px; border-radius: 50%; background: rgba(118,125,251,.15); color: var(--primary); display: flex; align-items: center; justify-content: center; margin-bottom: 4px; }
.info-card h3 { font-size: 20px; font-weight: 500; }
.info-card p { font-size: 15px; line-height: 21px; color: var(--fg-secondary); }
.info-card .btn-primary { margin-top: 8px; }

/* Short landscape screens (phones sideways): give the iPad the whole viewport */
@media (max-height: 500px) {
  .nav, .nav.scrolled { top: 8px; }
  .ipad { --bezel: 12px; }
}
