/* App shell: rail | stage | counter (phone preview) */

.app {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--preview-w);
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   LEFT RAIL — painted shutter green
   ============================================================ */

.rail {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(178deg, var(--forest-800) 0%, var(--forest-900) 100%);
  color: var(--fg-on-chrome);
  border-right: 1px solid rgba(0, 0, 0, 0.3);
  animation: rail-in var(--dur-slow) var(--ease-out) both;
}

@keyframes rail-in {
  from {
    opacity: 0;
    transform: translateX(-14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Hairline of light along the shutter's inner edge */
.rail::after {
  content: '';
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: linear-gradient(
    180deg,
    transparent,
    rgba(255, 255, 255, 0.09) 18%,
    rgba(255, 255, 255, 0.09) 82%,
    transparent
  );
}

.rail__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border-chrome);
  flex-shrink: 0;
}

.rail__mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.35));
}

.rail__wordmark {
  font-family: var(--font-display);
  font-variation-settings: 'opsz' 60;
  font-weight: 600;
  font-size: var(--fs-xl);
  letter-spacing: -0.025em;
  line-height: 1;
}

.rail__wordmark em {
  font-style: normal;
  color: var(--green-400);
}

.rail__tag {
  display: block;
  font-family: var(--font-ui);
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--fg-on-chrome-muted);
  margin-top: 3px;
}

/* ---- Stage navigation ---- */

.rail__nav {
  padding: var(--s-5) var(--s-3) var(--s-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.rail__section-label {
  padding: 0 var(--s-3) var(--s-3);
  color: var(--fg-on-chrome-muted);
  opacity: 0.75;
}

.stage-btn {
  position: relative;
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3);
  border-radius: var(--r-md);
  text-align: left;
  color: var(--fg-on-chrome);
  transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
  animation: rise var(--dur) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 55ms + 120ms);
}

.stage-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
}

.stage-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.stage-btn[aria-current='true'] {
  background: rgba(255, 255, 255, 0.09);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.stage-btn[aria-current='true']::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  width: 3px;
  height: 30px;
  border-radius: 0 3px 3px 0;
  background: var(--green-400);
  transform: translateY(-50%);
  box-shadow: 0 0 12px rgba(53, 214, 128, 0.7);
  animation: pop var(--dur) var(--ease-spring) both;
}

.stage-btn__text {
  min-width: 0;
}

.stage-btn__num {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--r-full);
  border: 1px solid rgba(255, 255, 255, 0.22);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-on-chrome-muted);
  transition: all var(--dur) var(--ease-out);
}

.stage-btn[aria-current='true'] .stage-btn__num {
  border-color: var(--green-400);
  color: var(--green-300);
}

.stage-btn[data-done='true'] .stage-btn__num {
  background: var(--green-500);
  border-color: var(--green-500);
  color: var(--accent-ink);
}

.stage-btn__num svg {
  width: 13px;
  height: 13px;
  animation: pop var(--dur) var(--ease-spring) both;
}

.stage-btn__label {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.stage-btn__sub {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--fg-on-chrome-muted);
  margin-top: 2px;
}

/* ---- Live panel (aaj ka hisaab) ---- */

.rail__spacer {
  flex: 1;
}

.rail__panel {
  margin: 0 var(--s-3) var(--s-3);
  padding: var(--s-4);
  border-radius: var(--r-md);
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid var(--border-chrome);
  animation: rise var(--dur-slow) var(--ease-out) 340ms both;
}

.rail__panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}

.rail__panel-head .eyebrow {
  color: var(--fg-on-chrome-muted);
}

.cap-value {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg-on-chrome);
}

.cap-value b {
  color: var(--green-300);
  font-weight: 500;
}

.cap-track {
  height: 6px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.4);
  overflow: hidden;
}

.cap-fill {
  height: 100%;
  width: 0;
  border-radius: var(--r-full);
  background: linear-gradient(90deg, var(--green-500), var(--green-300));
  transition: width var(--dur-slow) var(--ease-out);
}

.cap-fill[data-full='true'] {
  background: linear-gradient(90deg, var(--amber-500), #f0b64a);
}

.rail__panel-note {
  font-size: var(--fs-xs);
  color: var(--fg-on-chrome-muted);
  margin-top: var(--s-3);
  line-height: 1.4;
}

.cap-foot {
  margin-top: var(--s-3);
}

.cap-adjust {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-left: -8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--fg-on-chrome-muted);
  font: inherit;
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast);
}

.cap-adjust svg {
  width: 13px;
  height: 13px;
}

.cap-adjust:hover {
  color: var(--fg-on-chrome);
  background: rgba(255, 255, 255, 0.07);
}

/* The cap is above what we recommend — flag it where the number is shown, not
   only inside the dialog the user has to open to find it. */
.cap-foot[data-warn='true'] .cap-adjust {
  color: var(--amber-500);
}

.rail__foot {
  padding: var(--s-4) var(--s-5) var(--s-5);
  border-top: 1px solid var(--border-chrome);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-1);
  font-size: var(--fs-xs);
  color: var(--fg-on-chrome-muted);
}

.rail__foot button {
  color: var(--fg-on-chrome-muted);
  font-size: var(--fs-xs);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color var(--dur-fast);
}

.rail__foot button:hover {
  color: var(--green-300);
}

/* The license line reads as status first and a link second — underlining it
   like the action below it would make the rail look like two buttons. */
.rail__license {
  text-decoration: none !important;
  text-align: left;
}

.rail__license:hover {
  text-decoration: underline !important;
}

/* Running build — status text, not a control. Mono so "v1.0.1" reads as a
   version, not a sentence. */
.rail__version {
  margin-top: var(--s-3);
  font-size: var(--fs-2xs);
  letter-spacing: 0.04em;
  color: var(--fg-on-chrome-muted);
  opacity: 0.85;
  user-select: text;
}

/* History is a destination, not a footnote about the license, so it gets a
   surface of its own and sits above the divider. */
.rail__history {
  width: 100%;
  margin-bottom: var(--s-4);
  padding: 8px 12px;
  border-radius: var(--r-sm);
  text-align: left;
  text-decoration: none !important;
  color: var(--fg-on-chrome) !important;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.13);
  transition: background var(--dur-fast);
}

.rail__history:hover {
  background: rgba(255, 255, 255, 0.13);
}

/* ============================================================
   CENTER — the paper work surface
   ============================================================ */

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-canvas);
  position: relative;
}

/* Faint paper grain so the surface isn't a flat fill */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: radial-gradient(rgba(20, 32, 27, 0.055) 1px, transparent 1px);
  background-size: 22px 22px;
}

.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  height: var(--topbar-h);
  padding: 0 var(--s-7);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(var(--paper-100), var(--paper-200));
}

.topbar__head {
  min-width: 0;
}

.topbar__title {
  font-size: var(--fs-xl);
  font-variation-settings: 'opsz' 48;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sub {
  font-family: var(--font-ui);
  font-size: var(--fs-sm);
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-shrink: 0;
}

.stage__scroll {
  position: relative;
  z-index: 1;
  flex: 1;
  overflow-y: auto;
  padding: var(--s-7) var(--s-7) var(--s-9);
}

.stage__inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

/* Beats the .view display:flex above — without this every step shows at once. */
.view[hidden] {
  display: none;
}

/* ---- Back / Next ---- */

.stepnav {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  margin-top: var(--s-2);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}

.stepnav__mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.stepnav__count {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--fg-subtle);
}

/* Says why Next is unavailable, so a disabled button is never a dead end. */
.stepnav__hint {
  font-size: var(--fs-xs);
  color: var(--amber-600);
}

/* The hint is the whole reason a disabled Next is not a dead end, so it stays.
   Only the "Step 2 of 4" counter — which the rail already shows — gives way. */
@media (max-width: 880px) {
  .stepnav__count {
    display: none;
  }
  .stepnav {
    gap: var(--s-3);
  }
}

#banners:empty {
  display: none;
}

#banners {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.view.is-entering {
  animation: view-in var(--dur-slow) var(--ease-out) both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   RIGHT — the counter: phone preview + live telemetry
   ============================================================ */

.counter {
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(165deg, var(--forest-800) 0%, var(--forest-950) 100%);
  color: var(--fg-on-chrome);
  animation: counter-in var(--dur-slow) var(--ease-out) both;
}

@keyframes counter-in {
  from {
    opacity: 0;
    transform: translateX(18px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Kirana doodle wallpaper — original artwork, kept very quiet.
 * Note the dedicated keyframe: a generic fade-to-1 would blow past the
 * target opacity and leave the pattern shouting. */
.counter::before {
  content: '';
  position: absolute;
  inset: -40px;
  background-image: var(--doodles);
  background-size: 190px 190px;
  opacity: 0.05;
  pointer-events: none;
  animation: wallpaper-in var(--dur-slower) var(--ease-out) 300ms both;
}

@keyframes wallpaper-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.05;
  }
}

/* Warm pool of light falling on the counter */
.counter::after {
  content: '';
  position: absolute;
  top: -18%;
  left: 50%;
  width: 130%;
  height: 60%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(31, 191, 107, 0.16), transparent 65%);
  pointer-events: none;
}

.counter__head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border-chrome);
  flex-shrink: 0;
}

.counter__head .eyebrow {
  color: var(--fg-on-chrome-muted);
}

.counter__body {
  position: relative;
  z-index: 2;
  flex: 1;
  overflow-y: auto;
  padding: var(--s-6) var(--s-5) var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-5);
}

.counter__body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  background-clip: content-box;
}

/* ============================================================
   Narrower windows

   The phone preview is the element that makes this tool trustworthy — it is
   the only place the shopkeeper sees what actually lands on a customer's
   phone. So it never gets dropped. The rail gives up its labels first, then
   the work column tightens; the preview is the last thing to shrink and it is
   never hidden.
   ============================================================ */

@media (max-width: 1240px) {
  :root {
    --preview-w: 340px;
    --rail-w: 232px;
  }
  .stage__scroll {
    padding: var(--s-6) var(--s-5) var(--s-8);
  }
}

/* Still labelled, just tighter — the rail keeps its words as long as it can. */
@media (max-width: 1080px) {
  :root {
    --rail-w: 196px;
    --preview-w: 300px;
  }
  .rail__brand {
    padding: 0 var(--s-4);
  }
  .rail__nav {
    padding: var(--s-4) var(--s-2) var(--s-3);
  }
  .stage-btn {
    padding: var(--s-2) var(--s-3);
  }
  .stage-btn__label {
    font-size: var(--fs-sm);
  }
}

/* Only now does it give up the labels: numbered discs, tooltips on hover. */
@media (max-width: 880px) {
  :root {
    --rail-w: 64px;
    --preview-w: 272px;
  }
  .rail__brand {
    justify-content: center;
    padding: 0;
  }
  /* The label block is the unclassed second child of each step button, and the
     wordmark the unclassed div beside the brand mark — target them positionally
     rather than inventing classes the views do not emit. */
  .rail__brand > div,
  .rail__section-label,
  .stage-btn > span:not(.stage-btn__num),
  .rail__panel-note,
  .rail__foot button {
    display: none;
  }
  .stage-btn {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: var(--s-3) 0;
  }
  .stage-btn[aria-current='true']::before {
    left: -10px;
  }
  .rail__panel {
    margin: 0 8px 8px;
    padding: var(--s-3) 6px;
    text-align: center;
  }
  .rail__panel-head {
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: var(--s-2);
  }
  .rail__panel-head .eyebrow {
    display: none;
  }
  .rail__foot {
    padding: var(--s-3) 6px;
    align-items: center;
    text-align: center;
    font-size: var(--fs-2xs);
  }
}

@media (max-width: 880px) {
  .topbar {
    padding: 0 var(--s-5);
  }
  .stage__scroll {
    padding: var(--s-5) var(--s-4) var(--s-7);
  }
}
