/* Terra Charge — QR deep-link landing page
   Hand-written stylesheet (replaces the runtime Tailwind JIT engine).
   All colors / spacing live as design tokens in :root. */

/* Self-hosted Noto Sans JP, subset to only the ~190 characters this page uses
   (one variable file covers weights 400–700). It's <link rel=preload>ed in the
   <head>, so it's ready before first paint — no download window where iOS
   Safari would flash last-resort [?] glyphs. font-display:block keeps text
   invisible (never tofu) for the imperceptible moment before it's ready. */
@font-face {
  font-family: "Noto Sans JP";
  src: url("./NotoSansJP-subset.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: block;
}

:root {
  /* Brand & UI colors */
  --color-brand:           #123d6f;  /* primary "Open in app" button   */
  --color-brand-text:      #123d6f;  /* dark-blue body text            */
  --color-guest-bg:        #f0f3fb;  /* secondary "guest" button       */
  --color-guest-bg-hover:  #dde5f7;
  --color-info-bg:         #eaf4ff;  /* store-fallback dialog          */
  --color-info-accent:     #0c9aea;
  --color-page-bg:         #f3f4f6;
  --color-surface:         #ffffff;
  --color-text:            #111827;
  --color-text-muted:      #6b7280;
  --color-text-subtle:     #9ca3af;
  --color-text-nav:        #374151;
  --color-border:          #d1d5db;
  --color-toast-bg:        rgba(0, 0, 0, 0.85);

  /* Guest-unavailable notice — matches the iOS GuestModeInfoToast (TERRA-12554) */
  --color-danger:          #f7395b;  /* border  */
  --color-danger-light:    #fceae8;  /* fill    */
  --color-danger-dark:     #b11e2f;  /* icon + text */

  /* Disabled "guest" button (charger doesn't support guest-mode charging) */
  --color-guest-disabled-bg:   #ededed;
  --color-guest-disabled-text: #d9d9d9;

  /* Type — Latin uses the platform UI font; CJK falls back to a NAMED
     Japanese system font (Hiragino on iOS/macOS, Yu Gothic/Meiryo on Windows)
     because iOS Safari doesn't reliably auto-fall-back to CJK from system-ui. */
  --font-base: "Noto Sans JP", -apple-system, BlinkMacSystemFont,
               "Hiragino Sans", "Hiragino Kaku Gothic ProN",
               "Yu Gothic", "Yu Gothic UI", Meiryo,
               system-ui, sans-serif;

  /* Shape */
  --radius-pill: 9999px;
  --content-max: 24rem;  /* button column width */
}

/* ---- Reset ----------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--color-page-bg);
  font-family: var(--font-base);
  color: var(--color-text);
}

img { display: block; }

/* ---- Page shell ------------------------------------------------------ */
.page {
  width: 100%;
  min-height: 100vh;        /* fallback for browsers without dvh */
  min-height: 100dvh;       /* tracks the *visible* area (excludes Safari's bar) */
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
}

/* ---- Nav ------------------------------------------------------------- */
.nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
}

.nav__lang {
  font-family: inherit;
  font-size: 13px;
  color: var(--color-text-nav);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 5px 9px;
}

.nav__contact {
  font-size: 0.875rem;
  color: #7d7d7d;
  text-decoration: underline;
}

/* ---- Content --------------------------------------------------------- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 1.75rem 1.5rem;
}

/* Main block (icon + copy + buttons) — centered in the space above the
   bottom-pinned store row. */
.content__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.content__icon { margin-bottom: 1.25rem; }

.content__title {
  margin: 0 0 0.625rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--color-brand-text);
  text-align: center;
}

.content__subtitle {
  margin: 0 0 1.75rem;
  max-width: 20rem;
  font-size: 0.875rem;
  line-height: 1.625;
  color: var(--color-brand-text);
  text-align: center;
}

/* ---- Action column --------------------------------------------------- */
.actions {
  width: 100%;
  max-width: var(--content-max);
}

/* Guest-unavailable notice — copied from the iOS GuestModeInfoToast (TERRA-12554):
   light-red box, red 1px border, warning-triangle icon, left-aligned dark-red text.
   Sits under the guest description; shown when the charger doesn't support guest mode. */
.guest-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 1rem;
  padding: 10px;
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  border-radius: 4px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-danger-dark);
  text-align: left;
}

.guest-notice__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;   /* fill: currentColor → dark-red icon */
}

.btn {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-weight: 700;
  font-size: 16px;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.15s, background-color 0.15s, transform 0.05s;
}

.btn:active { transform: scale(0.985); }

.btn--primary {
  margin-bottom: 0.875rem;
  background: var(--color-brand);
  color: #fff;
}
.btn--primary:hover  { opacity: 0.9; }
.btn--primary:active { opacity: 0.75; }

.btn--secondary {
  margin-bottom: 1rem;
  background: var(--color-guest-bg);
  color: var(--color-brand-text);
}
.btn--secondary:hover { background: var(--color-guest-bg-hover); }

/* Guest button — resolved states (see app.js setGuestState).
   Loading: show only the iOS spinner. Unsupported: grayed but still tappable
   so the tap can explain why (a real :disabled can't fire a click). */
.btn--secondary.is-loading  { cursor: default; }
.btn--secondary.is-loading:hover { background: var(--color-guest-bg); }

.btn--secondary.is-disabled {
  background: var(--color-guest-disabled-bg);
  color: var(--color-guest-disabled-text);
  cursor: default;
}
.btn--secondary.is-disabled:hover { background: var(--color-guest-disabled-bg); }
.btn.is-loading:active,
.btn.is-disabled:active { transform: none; }

.btn__label { display: inline; }
.btn.is-loading .btn__label { display: none; }

/* iOS-style 12-spoke activity indicator (spokes are built in app.js). */
.ios-spinner {
  display: none;
  position: relative;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  color: inherit;   /* spokes use currentColor */
}
.btn.is-loading .ios-spinner { display: inline-block; }
.ios-spinner span {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 5px;
  margin-left: -1px;
  border-radius: 1px;
  background: currentColor;
  transform-origin: 1px 10px;   /* rotate around the 20px box centre */
  opacity: 0.15;
  animation: ios-spinner-fade 1s linear infinite;
}
@keyframes ios-spinner-fade {
  0%   { opacity: 1; }
  100% { opacity: 0.15; }
}
@media (prefers-reduced-motion: reduce) {
  .ios-spinner span { animation: none; opacity: 0.4; }
}

.actions__or {
  margin: 0 0 0.875rem;
  font-size: 14px;
  font-weight: 400;
  line-height: 1;
  color: var(--color-brand-text);
  text-align: center;
}

.actions__guest-desc {
  margin: 0;
  padding: 0 1rem;
  font-size: 11.5px;
  line-height: 1.625;
  color: rgba(18, 61, 111, 0.4);  /* --color-brand-text (#123d6f) at 40% */
  text-align: left;
}

/* ---- Store row (pinned to the bottom of the screen) ------------------ */
.store {
  width: 100%;
  max-width: var(--content-max);
  margin-top: 1.5rem;   /* min gap from the main block on short screens */
}

.store__dialog {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-accent);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-brand-text);
}

.store__dialog-icon { flex-shrink: 0; }

.store__badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.store__badge { text-decoration: none; }

/* Official Apple / Google badges have different aspect ratios — pin them to a
   common height and let width follow so neither distorts. */
.store__badge img {
  display: block;
  height: 44px;
  width: auto;
}

/* ---- Toast ----------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 2.5rem;
  left: 50%;
  transform: translate(-50%, 1.25rem);
  z-index: 50;
  padding: 0.625rem 1.25rem;
  background: var(--color-toast-bg);
  color: #fff;
  font-size: 0.875rem;
  white-space: nowrap;
  border-radius: var(--radius-pill);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
