/* หน้า IdP (SPEC-R3 §9) — ไม่มี JS, ไม่มี inline style, ไม่มี resource ภายนอก (CSP) · light only */
@font-face { font-family: "Inter"; src: url("/auth/assets/fonts/Inter.ttf") format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("/auth/assets/fonts/IBMPlexSansThai-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("/auth/assets/fonts/IBMPlexSansThai-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("/auth/assets/fonts/IBMPlexSansThai-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "IBM Plex Sans Thai"; src: url("/auth/assets/fonts/IBMPlexSansThai-Bold.ttf") format("truetype"); font-weight: 700 900; font-display: swap; }

:root {
  --or: #f7941d; --or2: #e07a0d; --or-text: #b5530a;
  --navy: #1b2a4a; --ink: #1b2a4a; --mute: #6b7280; --line: #e5e7eb; --line2: #c9ced8;
  --bg: #fbfaf7; --card: #fff; --red: #b42318; --red-bg: #fef2f2; --red-line: #fecaca;
  --green: #166534; --green-bg: #f0fdf4; --amber: #7a4a00; --amber-bg: #fff4e5;
  --focus: #1b2a4a;
  --font: "Inter", "IBM Plex Sans Thai", system-ui, -apple-system, "Segoe UI", sans-serif;
  --emb: min(430px, 48vh, 34vw);
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  color: var(--ink);
  font: 16px/1.55 var(--font);
  overflow-wrap: anywhere;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(27, 42, 74, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(27, 42, 74, 0.035) 1px, transparent 1px);
  background-size: 40px 40px;
}
a { color: var(--or-text); }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; color: var(--navy); }
.sub { color: #4b5563; font-size: 15px; margin: 0 0 22px; }

/* canvas */
.auth-bg { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.auth-bg i { position: absolute; border-radius: 50%; filter: blur(70px); }
.auth-bg .b1 { width: 320px; height: 320px; top: -80px; right: -60px; background: rgba(247, 148, 29, 0.11); }
.auth-bg .b2 { width: 380px; height: 380px; bottom: -120px; left: -100px; background: rgba(27, 42, 74, 0.06); }
.auth-bg svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.05; }

/* top bar */
.auth-top { position: absolute; top: 0; left: 0; right: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; }
.auth-back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px 0 10px; border-radius: 999px; color: #4b5563; text-decoration: none; font-weight: 500; font-size: 14px; transition: background 0.2s, color 0.2s; }
.auth-back:hover { background: rgba(27, 42, 74, 0.06); color: var(--navy); }
.auth-back svg { width: 18px; height: 18px; flex: none; }
.auth-lang { display: inline-flex; gap: 2px; padding: 3px; background: #fff; border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 16px -10px rgba(27, 42, 74, 0.35); }
.auth-lang a { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 44px; padding: 0 12px; border-radius: 999px; color: var(--navy); text-decoration: none; font-weight: 600; font-size: 14px; transition: background 0.2s, color 0.2s; }
.auth-lang a.on { background: var(--navy); color: #fff; }

/* layout */
.auth-wrap { position: relative; z-index: 1; max-width: 1180px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; padding: 64px 24px 40px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "brand art" "card art"; gap: 0 40px; align-content: center; }
.auth-brand { grid-area: brand; align-self: end; display: flex; flex-direction: column; gap: 14px; }
.auth-pill { align-self: flex-start; padding: 6px 14px; border-radius: 999px; background: rgba(247, 148, 29, 0.11); color: var(--or-text); font-weight: 600; font-size: 14px; }
.auth-word { font-size: clamp(40px, 4.4vw, 60px); line-height: 1.05; font-weight: 800; color: var(--navy); letter-spacing: -0.01em; }
.auth-word em { font-style: normal; color: var(--or); }
.auth-hbrand { display: none; align-items: center; gap: 10px; }
.auth-hbrand img { flex: none; }
.auth-hbrand span { display: flex; flex-direction: column; line-height: 1.2; }
.auth-hbrand b { font-size: 17px; color: var(--navy); }
.auth-hbrand b em { font-style: normal; color: var(--or-text); }
.auth-hbrand small { color: var(--mute); font-size: 13px; }
.auth-art { grid-area: art; display: flex; align-items: center; justify-content: center; }
.auth-art img { width: var(--emb); height: var(--emb); max-width: 100%; }

/* card */
.auth-card { grid-area: card; width: 100%; max-width: 420px; min-width: 0; margin-top: 34px; padding: 30px 32px 22px; background: var(--card); border: 1px solid rgba(27, 42, 74, 0.08); border-radius: 22px; box-shadow: 0 30px 60px -32px rgba(27, 42, 74, 0.35), 0 2px 6px -2px rgba(27, 42, 74, 0.06); }

/* forms */
label { display: block; font-size: 13px; color: var(--mute); margin: 14px 0 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"] {
  display: block; width: 100%; min-width: 0; min-height: 46px; padding: 11px 13px; font: inherit; font-size: 16px; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; transition: border-color 0.2s;
}
input:focus { outline: 2px solid rgba(247, 148, 29, 0.35); border-color: var(--or); }
input[readonly] { background: var(--bg); }
.hint { color: var(--mute); font-size: 13px; margin: 6px 0 0; }

/* buttons: .btn (ใหม่) + button / a.button (view เดิมจนกว่า R2.3 จะย้าย) */
.btn, button, a.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; margin-top: 10px; padding: 13px 22px 16px;
  font: inherit; font-weight: 600; font-size: 15px; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  border: 2px solid rgba(27, 42, 74, 0.2); border-radius: 999px; color: var(--navy); background: transparent; transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn:hover, button:hover, a.button:hover { border-color: var(--or); color: var(--or-text); }
.btn.pri, button.primary { margin-top: 18px; color: var(--navy); background: var(--or); border-color: transparent; box-shadow: 0 14px 28px -14px rgba(247, 148, 29, 0.7); }
.btn.pri:hover, button.primary:hover { background: var(--or2); color: var(--navy); border-color: transparent; }
.btn.sec, button.secondary { background: transparent; border-color: rgba(27, 42, 74, 0.2); color: var(--navy); }
.btn.sec:hover, button.secondary:hover { border-color: var(--or); color: var(--or-text); }
.btn.danger { color: #fff; background: var(--red); border-color: transparent; }
.btn.danger:hover { background: #912018; color: #fff; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn:disabled, button:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible, button:focus-visible, a:focus-visible, a.button:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--mute); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* messages: .msg (ใหม่) + .alert (view เดิม) */
.msg, .alert { margin: 0 0 14px; padding: 10px 14px 13.5px; border-radius: 12px; border: 1px solid transparent; font-size: 14.5px; }
.msg.err, .alert { background: var(--red-bg); border-color: var(--red-line); color: #991b1b; }
.msg.ok { background: var(--green-bg); border-color: #bbf7d0; color: var(--green); }
.msg.info { background: var(--amber-bg); border-color: #fcd9a3; color: var(--amber); }

.auth-links, .links { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; margin: 14px 0 0; color: var(--mute); font-size: 14px; }
.auth-links a, .links a { display: inline-flex; align-items: center; min-height: 44px; color: #4b5563; font-weight: 500; text-decoration: none; }
.auth-links a:hover, .links a:hover { color: var(--or-text); }
.auth-links a + a::before { content: "·"; margin-right: 10px; color: var(--mute); }

/* mfa */
.qr { display: flex; justify-content: center; margin: 12px 0; }
.qr img { width: 200px; max-width: 100%; height: auto; background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.secret { text-align: center; margin: 0 0 12px; }
.secret code, .codes code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; word-break: break-all; }
.codes { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.codes li { text-align: center; }
.codes code { display: block; padding: 8px 10px; font-size: 15px; letter-spacing: 0.06em; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }

/* consent */
.scope-list, .scopes { list-style: none; margin: 4px 0 8px; padding: 0; }
.scope-list li, .scopes li { display: flex; align-items: flex-start; gap: 10px; padding: 4px 0; }
.scope-list li::before, .scopes li::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 0.6em; border-radius: 50%; background: var(--or); }
.label { font-weight: 600; margin: 0; }
.row { display: flex; flex-direction: column; gap: 0; }
.terms { color: var(--mute); font-size: 12.5px; margin: 12px 0 0; }

.note { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; color: var(--mute); font-size: 12.5px; text-align: center; }
.note svg { width: 14px; height: 14px; flex: none; }

@media (max-height: 820px) and (min-width: 901px) {
  :root { --emb: 380px; }
  .auth-wrap { padding-top: 40px; }
}
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "card"; padding: 72px 16px 32px; justify-items: center; align-content: start; }
  .auth-art { display: none; }
  .auth-brand { align-self: auto; align-items: center; }
  .auth-pill, .auth-word { display: none; }
  .auth-hbrand { display: flex; }
  .auth-card { max-width: 480px; margin-top: 18px; padding: 24px 20px 18px; }
}
@media (max-width: 520px) {
  .auth-card { max-width: 100%; }
}
@media (max-width: 420px) {
  .auth-top { padding: 12px; }
  .auth-back { padding: 0; width: 44px; justify-content: center; }
  .auth-back span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none; animation: none; }
  .btn, button, a.button, .auth-back, .auth-lang a, input, input[type] { transition: none; }
}
@media print {
  body * { visibility: hidden !important; }
  .codes, .codes * { visibility: visible !important; }
  .codes { position: absolute; top: 0; left: 0; }
}
