/* ABE Loyalty — sign-in
   Layout: navy brand panel (left, desktop) + form card; stacked on phones. */
:root {
  --navy: #0a2540;
  --navy-700: #12345a;
  --teal: #0f4c5c;
  --teal-soft: #e6f0f2;
  --orange: #f97316;
  --orange-hover: #ea580c;
  --orange-soft: #fff1e7;
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --ink: #0a2540;
  --muted: #5b6b80;
  --danger: #be123c;
  --danger-soft: #fff1f3;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --font-display: 'Sora', ui-sans-serif, system-ui, 'Segoe UI', sans-serif;
  --font-body: 'IBM Plex Sans', ui-sans-serif, system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font: 15px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ── Layout ── */
.layout { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(380px, 0.95fr) 1.05fr; }
.panel {
  position: relative; overflow: hidden; color: #fff; background: var(--navy);
  display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: max(28px, env(safe-area-inset-top)) 40px 28px max(40px, env(safe-area-inset-left));
}
.panel::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 85% 25%, rgba(15, 76, 92, 0.95), transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px) 0 0 / 28px 28px;
}
.panel > * { position: relative; }
.panel-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { border-radius: 11px; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2); flex: none; }
.brand strong { display: block; font: 700 16px/1.2 var(--font-display); }
.brand span { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255, 255, 255, 0.55); }
.panel-body { max-width: 440px; margin-block: auto; }
.eyebrow { margin: 0 0 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: #fdba74; }
.panel h2 { margin: 0; font: 700 34px/1.12 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.dish { display: block; width: min(300px, 70%); height: auto; margin: 36px 0 0 auto; filter: drop-shadow(0 24px 48px rgba(0, 0, 0, 0.35)); }

.lang { display: inline-flex; padding: 3px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); }
.lang button {
  min-width: 42px; min-height: 38px; border: 0; border-radius: 9px; background: transparent;
  color: rgba(255, 255, 255, 0.7); font: 600 12px var(--font-mono); letter-spacing: 0.08em; cursor: pointer;
}
.lang button[aria-pressed='true'] { background: #fff; color: var(--navy); }

.main {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  padding: 40px max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) 24px;
}
.card {
  width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 32px; box-shadow: 0 1px 2px rgba(10, 37, 64, 0.05), 0 18px 40px -24px rgba(10, 37, 64, 0.25);
}
.card h1 { margin: 0; font: 700 26px/1.2 var(--font-display); letter-spacing: -0.01em; text-wrap: balance; }
.lead { margin: 8px 0 24px; color: var(--muted); }
.lead strong { color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.label { display: block; margin: 0 0 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
.note, .hint { margin: 14px 0 0; font-size: 13px; color: var(--muted); }
.hint { margin-top: 8px; }

input[type='email'] {
  width: 100%; min-height: 52px; padding: 0 16px; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff;
  font: 16px var(--font-body); color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
}
input[type='email']:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 4px #ffedd5; }
input[type='email'][aria-invalid='true'] { border-color: var(--danger); box-shadow: 0 0 0 4px #ffe4e6; }

/* ── OTP: one real input (paste & iOS/Android autofill friendly) over six visual boxes ── */
.otp { position: relative; height: 60px; }
.otp input {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 2; opacity: 0.01; color: transparent; caret-color: transparent;
  border: 0; background: transparent; font-size: 16px; letter-spacing: 1.5em; cursor: text;
}
.otp-boxes { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.otp-boxes span {
  display: grid; place-items: center; border: 1px solid #cbd5e1; border-radius: 12px; background: #fff;
  font: 600 26px/1 var(--font-mono); color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.otp.focused .otp-boxes span.active { border-color: var(--orange); box-shadow: 0 0 0 4px #ffedd5; }
.otp.focused .otp-boxes span.active:empty::after { content: ''; width: 2px; height: 26px; background: var(--orange); animation: blink 1s steps(1) infinite; }
.otp .otp-boxes span.filled { background: #f8fafc; }
.otp.error .otp-boxes span { border-color: var(--danger); background: var(--danger-soft); }
@keyframes blink { 50% { opacity: 0; } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 12px; font: 600 15px var(--font-body); text-decoration: none; cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-block { width: 100%; margin-top: 16px; }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 1px 2px rgba(234, 88, 12, 0.25); }
.btn-primary:hover:not(:disabled) { background: var(--orange-hover); }
.btn-primary:disabled { background: #e2e8f0; color: #94a3b8; box-shadow: none; cursor: not-allowed; }
.btn-ghost { min-height: 44px; margin-top: 8px; background: transparent; color: var(--teal); }
.btn-ghost:hover:not(:disabled) { background: var(--teal-soft); }
.btn-ghost:disabled { color: #94a3b8; cursor: default; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5); border-top-color: #fff; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.back {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; margin: -8px 0 8px -8px; padding: 0 8px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: 500 13px var(--font-body); cursor: pointer;
}
.back:hover { background: #f1f5f9; color: var(--ink); }

.message { margin-top: 16px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.message.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdd3; }
.message.info { background: var(--teal-soft); color: var(--teal); border: 1px solid #cfe3e8; }
.message.success { background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0; }

.noscript { position: fixed; inset: auto 0 0; margin: 0; padding: 12px; background: var(--navy); color: #fff; text-align: center; }

/* ── Simple pages (magic-link confirmation) ── */
body.simple { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.simple-wrap { width: 100%; max-width: 440px; display: grid; gap: 20px; }
.simple-brand { display: flex; align-items: center; gap: 12px; }
.simple-brand img { border-radius: 11px; }
.simple-brand strong { display: block; font: 700 16px/1.2 var(--font-display); }
.simple-brand span { display: block; font-size: 12px; color: var(--muted); }
.email-pill { margin: 0; padding: 12px 14px; border-radius: 12px; background: #f1f5f9; font: 500 14px var(--font-mono); word-break: break-all; }

/* ── Tablet & phone ── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .panel { gap: 0; padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left)); }
  .panel-body { display: none; }
  .brand strong { font-size: 15px; }
  .main { justify-content: flex-start; padding: 28px max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
}
@media (max-width: 480px) {
  .card { padding: 24px 20px; border-radius: 18px; }
  .card h1 { font-size: 23px; }
  .otp { height: 56px; }
  .otp-boxes { gap: 6px; }
  .otp-boxes span { font-size: 22px; border-radius: 10px; }
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
