/* ---------------------------------------------------------------------------
   app.css — emulator shell chrome only.

   No card styling lives here — every card's CSS installs itself via
   PK.register when its render.js loads (shared/preview-kit.js). This file is
   the meta chrome around that: the household picker, the top bar, the
   app-shell frame (header pinned / body scrolling / nav fixed), and — since
   Phase 2 — the flow shell's own bar plus the provisional-step form/summary
   chrome, ported from workflows/anti-parasite-flow/preview.html's own
   <style> block (same classes, same purpose: harness, not product UI).
   --------------------------------------------------------------------------- */

html, body {
  height: 100%;
  /* Without this, body's content (topbar + app-shell) can grow taller than
     the viewport and the whole document scrolls instead — dragging the
     header along with it despite .app-shell__body's own overflow-y: auto,
     since that only kicks in once its parent box stops growing to fit it.
     This is what makes the header (and topbar) actually stay put, the same
     way .app-shell__nav already does via position: fixed. */
  overflow: hidden;
}

body {
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* app.js renders everything into #root — body's actual flex child, not the
   topbar/.app-shell markup directly. Without this, #root is a plain block
   box that grows to fit its content and never forwards the viewport-
   constrained height down to .app-shell, so .app-shell (and its header)
   grows past the viewport instead of .app-shell__body scrolling inside it. */
#root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Top bar: emulator-only chrome, never part of the SDUI payload ---- */
.app-topbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--color-surface-container-low);
  border-bottom: 1px solid var(--color-outline-variant);
  font-size: 13px;
}

.app-topbar__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-on-surface-variant);
}

.app-topbar__label strong {
  color: var(--color-on-surface);
}

.app-topbar button {
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
  cursor: pointer;
  white-space: nowrap;
}

/* Same toggle-button spec as landing-web's #theme-toggle/#lang-toggle
   (repos/landing-web/index.html's .toggle-btn) — kept identical so the
   theme/language controls read as the same component across both apps. */
.toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

/* ---- App shell: the phone-shaped column the whole page becomes ---- */
.app-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.app-shell__header {
  flex-shrink: 0;
  padding: 12px 16px 8px;
  display: flex;
}

.app-shell__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Fixed to the viewport, not just the flex column, per
   bottom-navigation-card/render.js's own note that placement is a client
   concern. Centered under the same max-width as .app-shell via the
   left:0/right:0 + auto-margin trick, so it lines up with the rest of the
   frame on a wide (desktop) viewport instead of stretching edge to edge
   there — on an actual phone-width viewport the max-width never binds, so it
   is already edge to edge. .app-shell__body's bottom padding above reserves
   room so scrolled content never lands underneath it. */
.app-shell__nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  max-width: 430px;
  margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-surface-container-lowest);
}

/* Cards read near edge to edge on an actual phone — the fixed 16px side
   padding around them is a desktop-only affordance that frames the
   phone-shaped mockup on a wide viewport. Below the mockup's own max-width,
   shrink it to a thin, viewport-proportional margin instead of dropping it
   entirely (flush edge to edge read as too tight). */
@media (max-width: 430px) {
  .app-shell__body {
    padding-left: 2%;
    padding-right: 2%;
  }
}

.phone-frame__section-label {
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-on-surface-variant);
  margin: 4px 0 -6px;
}

.phone-frame__pet-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.phone-frame__hint {
  margin: 0;
  padding: 10px 12px;
  border-radius: 0.75rem;
  background: var(--color-surface-container-low);
  color: var(--color-on-surface-variant);
  font-size: 12.5px;
  line-height: 18px;
}

/* ---- Household picker ---- */
.picker {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 32px 20px;
  text-align: center;
}

.picker h1 {
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 22px;
  margin: 0;
}

.picker > p {
  margin: -12px 0 0;
  color: var(--color-on-surface-variant);
  font-size: 14px;
  max-width: 360px;
}

.picker__lang-toggle {
  align-self: flex-end;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-lowest);
  color: var(--color-on-surface);
  cursor: pointer;
}

.picker__options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 340px;
}

.picker__option {
  text-align: left;
  padding: 56px 20px;
  border-radius: 1rem;
  border: none;
  background: var(--color-surface-container-lowest);
  box-shadow: var(--shadow-card);
  cursor: pointer;
  font-family: inherit;
  color: var(--color-on-surface);
}

.picker__option-title {
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 10px;
}

.picker__option-desc {
  margin: 0;
  font-size: 13px;
  line-height: 18px;
  color: var(--color-on-surface-variant);
}

/* ---- Flow bar: replaces the header/nav during the four provisional steps
   (schedule/reminder/review/history) — those views aren't confirmed to carry
   the same main-view chrome pet-health-overview does. ---- */
.flow-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 10px 4px;
  border-bottom: 1px solid var(--color-outline-variant);
}

.flow-bar__back {
  border: none;
  background: none;
  color: var(--color-on-surface-variant);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
}

.flow-bar__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-bar__cancel {
  flex-shrink: 0;
  border: none;
  background: none;
  color: var(--color-error);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
}

.flow-bar__spacer {
  width: 40px;
  flex-shrink: 0;
}

/* ---- Provisional marker — same meaning as everywhere else in this repo:
   the card/view this step composes isn't specced yet. ---- */
.prov {
  border: 1.5px dashed var(--color-tertiary);
  border-radius: 0.75rem;
  padding: 10px 12px;
  font-size: 11.5px;
  line-height: 16px;
  color: var(--color-tertiary);
  background: color-mix(in srgb, var(--color-tertiary-container) 12%, transparent);
}
.prov code { font-size: 11px; }

/* ---- Generic form surface (provisional steps only) ---- */
.sheet {
  background: var(--color-surface-container-lowest);
  border-radius: 1rem;
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-on-surface-variant);
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
}
.field input, .field select {
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: 0.75rem;
  border: 1px solid var(--color-outline-variant);
  background: var(--color-surface-container-low);
  color: var(--color-on-surface);
}
.field[data-invalid="true"] input,
.field[data-invalid="true"] select { border-color: var(--color-error); }
.field__error { font-size: 12px; color: var(--color-error); }
.field__row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }

.btn-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
.btn {
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 0.75rem;
  padding: 12px 14px;
  min-height: 44px;
  cursor: pointer;
  background: var(--color-surface-container-high);
  color: var(--color-on-surface);
}
.btn[data-style="accent"] { background: var(--color-action-container); color: var(--color-on-action-container); }

.summary { display: flex; flex-direction: column; gap: 8px; margin: 0; }
.summary__row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.summary__row dt { color: var(--color-on-surface-variant); margin: 0; }
.summary__row dd { margin: 0; font-weight: 600; text-align: right; }
.summary__head {
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 13px; font-weight: 700;
}
.summary__edit {
  border: none; background: none; font: inherit; font-size: 13px; font-weight: 600;
  color: var(--color-primary); cursor: pointer; padding: 4px 6px; border-radius: 8px;
}

.history-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--color-surface-container-lowest);
  border-radius: 0.75rem; padding: 12px 14px; box-shadow: var(--shadow-card);
}
.history-item__tick {
  width: 32px; height: 32px; flex-shrink: 0; border-radius: 9999px; display: grid; place-items: center;
  background: color-mix(in srgb, var(--color-primary-container) 26%, transparent);
  color: var(--color-primary);
}
.history-item__tick svg { width: 17px; height: 17px; }
.history-item p { margin: 0; font-size: 14px; font-weight: 600; }
.history-item span { font-size: 12.5px; color: var(--color-on-surface-variant); }

.empty-slate { text-align: center; padding: 28px 16px; color: var(--color-on-surface-variant); font-size: 13.5px; }

.toast {
  font-size: 12.5px; padding: 9px 12px; border-radius: 0.75rem;
  background: var(--color-surface-container-high); color: var(--color-on-surface-variant);
  margin: 0;
}

/* ---- Toast: emulator-only feedback for actions not wired up yet ---- */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  max-width: 320px;
  padding: 10px 16px;
  border-radius: 0.75rem;
  background: var(--color-on-surface);
  color: var(--color-page);
  font-size: 13px;
  text-align: center;
  box-shadow: var(--shadow-screen);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}

.app-toast[data-visible="true"] {
  opacity: 1;
}

/* ---- Quick-log confirm: a real on-page dialog, not window.confirm() ---- */
@keyframes confirm-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
  animation: confirm-overlay-in 150ms ease;
}

.confirm-dialog {
  width: 100%;
  max-width: 320px;
  background: var(--color-surface-container-lowest);
  border-radius: 1rem;
  padding: 20px;
  box-shadow: var(--shadow-screen);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.confirm-dialog__title {
  margin: 0;
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 18px;
  font-weight: 700;
}

.confirm-dialog__body {
  margin: 0;
  color: var(--color-on-surface-variant);
  font-size: 14px;
}

.confirm-dialog__actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.confirm-dialog__btn {
  flex: 1;
  font-family: 'Plus Jakarta Sans', 'Helvetica Neue', Arial, sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  border: none;
  border-radius: 0.75rem;
  padding: 12px;
  min-height: 44px;
  cursor: pointer;
}

.confirm-dialog__btn[data-style="accent"] {
  background: var(--color-action-container);
  color: var(--color-on-action-container);
}

.confirm-dialog__btn[data-style="neutral"] {
  background: var(--color-surface-container-high);
  color: var(--color-on-surface);
}

/* ---- "Details" inline subcard: expands below the card it was opened from
   instead of navigating away. max-height is a fixed cap, not the content's
   real height — a true auto-height transition needs JS to measure the
   element, which this emulator's plain-classes-in-innerHTML approach avoids;
   the cap just needs to comfortably fit the 3-entry activity log. app.js
   flips data-anim between enter -> open (rAF) and open -> leave -> removed
   (setTimeout) so the transition actually plays instead of snapping. ---- */
.pet-detail-subcard {
  position: relative;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-6px);
  margin-top: 0;
  transition: max-height 260ms ease, opacity 200ms ease, transform 220ms ease, margin-top 260ms ease;
}

.pet-detail-subcard[data-anim="open"] {
  max-height: 480px;
  opacity: 1;
  transform: translateY(0);
  margin-top: 10px;
}

.pet-detail-subcard__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 9999px;
  background: var(--color-surface-container-high);
  color: var(--color-on-surface-variant);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
