/* ============================================================
   ShopRouteBoard — auth surfaces (login, forgot/set password,
   site selection). Brings these pages onto the same WOW graphite
   design language as the dashboard so signing in no longer feels
   like a separate, older application.

   The "morning" animation is a board waking up behind the card:
   a field of status tiles light up in sequence, the way the real
   board fills as the shop day starts. It is purely decorative and
   CSS-driven — it never touches the form, so password managers and
   autofill are unaffected — and it collapses to a static, already-lit
   state under prefers-reduced-motion.
   ============================================================ */

:root {
  --a-bg: #0C0E10;
  --a-panel: #14171A;
  --a-panel2: #1B2025;
  --a-line: #23282D;
  --a-line2: #2A3036;
  --a-text: #F2EDE4;
  --a-bright: #C6CCD2;
  --a-muted: #9AA0A6;
  --a-faint: #7A828B;
  --a-amber: #F5A623;      /* semantic caution only (e.g. .auth-tile.hot) */
  --a-green: #29C46A;
  --a-red: #E8433A;
  --a-blue: #2BA0FF;       /* brand blue (route emblem) — the auth accent */
  --a-blue-deep: #0C6FD6;  /* deep brand blue for the solid sign-in button */
  --a-disp: 'Schibsted Grotesk', system-ui, sans-serif;
  --a-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
  --a-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --a-tap: 44px;
}

body.auth-body {
  margin: 0; min-height: 100svh; background: var(--a-bg); color: var(--a-text);
  font-family: var(--a-sans); -webkit-font-smoothing: antialiased;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
body.auth-body * { box-sizing: border-box; }
body.auth-body :focus-visible { outline: 2px solid var(--a-blue); outline-offset: 3px; border-radius: 4px; }

/* ---------- morning board, behind the card ---------- */
.auth-morning {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(245, 166, 35, .06), transparent 60%),
    radial-gradient(70% 60% at 100% 100%, rgba(78, 161, 255, .05), transparent 60%);
}
.auth-tiles {
  position: absolute; inset: -2%; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(clamp(84px, 12vw, 128px), 1fr));
  grid-auto-rows: clamp(48px, 7vw, 74px); gap: 12px; opacity: .5;
  transform: perspective(1400px) rotateX(24deg) scale(1.18); transform-origin: 50% 30%;
}
.auth-tile {
  border: 1px solid var(--a-line); border-radius: 8px; background: var(--a-panel);
  border-left: 3px solid #333A41; opacity: .28; transform: translateY(6px);
  animation: auth-wake .7s ease forwards; animation-delay: var(--d, 0s);
}
.auth-tile.hot { border-left-color: var(--a-amber); }
.auth-tile.crit { border-left-color: var(--a-red); }
.auth-tile.ok { border-left-color: var(--a-green); }
.auth-tile.info { border-left-color: var(--a-blue); }
@keyframes auth-wake {
  from { opacity: .12; transform: translateY(8px); }
  60%  { opacity: .85; }
  to   { opacity: .5; transform: translateY(0); }
}
.auth-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 40%, rgba(6, 8, 10, .82) 100%);
}

/* ---------- card ---------- */
.auth-card {
  position: relative; z-index: 2; width: 100%; max-width: 400px; margin-inline: auto;
  background: rgba(20, 23, 26, .82); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--a-line2); border-radius: 16px; padding: clamp(26px, 5vw, 38px);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5);
  animation: auth-card-in .5s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes auth-card-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 22px;
  font-family: var(--a-disp); font-weight: 800; font-size: 15px; letter-spacing: .14em;
}
/* The inline route SVG is replaced by the real SRB mark on a white tile (the
   navy mark needs the light ground to read on the dark auth card). */
.auth-brand svg { display: none; }
.auth-brand::before {
  content: ""; flex: 0 0 auto; width: 30px; height: 30px; border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: #fff url('/assets/images/product/srb.png') center / 22px no-repeat;
}
.auth-brand b { font-weight: 800; }

.auth-card h1 {
  font-family: var(--a-disp); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05;
  font-size: clamp(24px, 4vw, 30px); margin: 0 0 6px; color: var(--a-text);
}
.auth-sub { color: var(--a-muted); font-size: 14.5px; margin: 0 0 22px; line-height: 1.5; }

.auth-card label {
  display: block; font-family: var(--a-mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--a-faint); margin: 16px 0 7px;
}
.auth-card input[type=text],
.auth-card input[type=password],
.auth-card input:not([type]) {
  width: 100%; background: var(--a-panel2); color: var(--a-text);
  border: 1px solid var(--a-line2); border-radius: 10px; padding: 13px 14px;
  font-family: var(--a-sans); font-size: 15.5px; min-height: var(--a-tap);
  transition: border-color .15s, box-shadow .15s;
}
.auth-card input:focus {
  outline: none; border-color: var(--a-blue); box-shadow: 0 0 0 3px rgba(78, 161, 255, .18);
}
/* Keep autofilled fields legible on the dark card. */
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--a-text);
  -webkit-box-shadow: 0 0 0 40px var(--a-panel2) inset;
  caret-color: var(--a-text);
}

.auth-btn {
  width: 100%; margin-top: 22px; min-height: var(--a-tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--a-mono); font-weight: 600; font-size: 13.5px; letter-spacing: .14em;
  text-transform: uppercase; padding: 15px 22px; border-radius: 10px;
  background: var(--a-blue-deep); border: 1px solid var(--a-blue-deep); color: #fff; cursor: pointer;
  transition: filter .15s, transform .12s;
}
.auth-btn:hover { filter: brightness(1.06); }
.auth-btn:active { transform: scale(.99); }
.auth-btn svg { width: 16px; height: 16px; stroke: currentColor; }

.auth-links { margin-top: 16px; text-align: center; }
.auth-links a { color: var(--a-blue); text-decoration: none; font-size: 13.5px; }
.auth-links a:hover { text-decoration: underline; }
.auth-links .sep { display: block; margin-top: 8px; }
.auth-links .back { color: var(--a-muted); }

.auth-alert {
  border-radius: 10px; padding: 12px 14px; margin: 4px 0 6px; font-size: 14px; line-height: 1.45;
}
.auth-alert.err { border: 1px solid rgba(232, 67, 58, .5); background: rgba(232, 67, 58, .1); color: #F6B4AF; }
.auth-alert.warn { border: 1px solid rgba(245, 166, 35, .5); background: rgba(245, 166, 35, .1); color: #F3CE8E; }
.auth-alert.ok { border: 1px solid rgba(41, 196, 106, .5); background: rgba(41, 196, 106, .1); color: #9FE3BE; }

.cf-turnstile { margin-top: 16px; }

/* ---------- site selection ---------- */
.auth-select { max-width: 960px; }
.auth-select .auth-brand { justify-content: center; }
.auth-select h1 { text-align: center; }
.auth-select .auth-sub { text-align: center; }
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 14px; margin-top: 24px; align-items: stretch; }
.site-card {
  display: flex; flex-direction: column; gap: 10px; text-decoration: none;
  background: var(--a-panel2); border: 1px solid var(--a-line2); border-radius: 12px;
  padding: 18px; color: var(--a-text); min-height: 108px;
  transition: border-color .16s, transform .14s, background .16s;
}
.site-card:hover, .site-card:focus-visible { border-color: var(--a-blue); background: var(--a-panel); transform: translateY(-2px); }
.site-card .sc-top { display: flex; align-items: center; gap: 11px; }
/* Logos are arbitrary dealer artwork: contain (never crop) on a constant
   light tile, the way OEM marks are supplied for light backgrounds. */
.site-card .sc-logo {
  width: 44px; height: 44px; border-radius: 9px; flex: 0 0 auto; object-fit: contain;
  background: #FFFFFF; border: 1px solid var(--a-line2); padding: 4px;
}
.site-card .sc-mark {
  width: 44px; height: 44px; border-radius: 9px; flex: 0 0 auto; display: grid; place-items: center;
  background: rgba(43, 160, 255, .12); color: var(--a-blue); font-family: var(--a-disp);
  font-weight: 800; font-size: 16px; letter-spacing: 0.02em;
}
/* Platform Admin stays visually distinct from dealership cards. */
.site-card.admin { border-color: rgba(78, 161, 255, .4); }
.site-card.admin:hover, .site-card.admin:focus-visible { border-color: var(--a-blue); }
.site-card.admin .sc-go { color: var(--a-blue); }
.site-card .sc-mark.admin { background: rgba(78, 161, 255, .14); color: var(--a-blue); }
.site-card .sc-top { min-width: 0; }
.site-card .sc-name { font-family: var(--a-disp); font-weight: 700; font-size: 16px; line-height: 1.25; min-width: 0; overflow-wrap: anywhere; }
/* The hostname is metadata, not part of the name: its own line, always. */
.site-card .sc-host { display: block; margin-top: 3px; font-family: var(--a-mono); font-size: 11px; color: var(--a-muted); word-break: break-all; }
.site-card .sc-role {
  margin-top: auto; align-self: flex-start; font-family: var(--a-mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--a-bright); border: 1px solid var(--a-line); border-radius: 99px; padding: 3px 10px;
}
.site-card .sc-go { margin-top: auto; display: inline-flex; align-items: center; gap: 6px; color: var(--a-blue); font-family: var(--a-mono); font-size: 12px; }
.site-card .sc-role + .sc-go { margin-top: 0; }
.site-card .sc-go svg { width: 14px; height: 14px; stroke: currentColor; }

.auth-topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center;
  justify-content: space-between; padding: 12px 20px; background: rgba(12, 14, 16, .8);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--a-line);
}
.auth-topbar .who { font-family: var(--a-mono); font-size: 12.5px; color: var(--a-bright); }
.auth-topbar .who b { color: var(--a-text); }
.auth-topbar a { color: var(--a-muted); font-family: var(--a-mono); font-size: 12px; text-decoration: none; }
.auth-topbar a:hover { color: var(--a-text); }
.auth-select-wrap { position: relative; z-index: 2; width: 100%; padding-top: 46px; }

/* iPhone: breathe at the edges, respect the notch/home-indicator, and make
   horizontal document panning impossible (Safari pans the html element even
   when body overflow is hidden). */
html:has(body.auth-body) { overflow-x: clip; }
body.auth-body {
  padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right))
           calc(16px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
}
.auth-topbar {
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
}
@media (max-width: 640px) {
  .auth-card { padding: 22px 18px; border-radius: 14px; }
  .auth-select-wrap { padding-top: calc(52px + env(safe-area-inset-top)); }
  .site-grid { grid-template-columns: 1fr; }
  .site-card { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-tile { animation: none; opacity: .5; transform: none; }
  .auth-card { animation: none; }
}
