/* ABOUTME: Static stylesheet for AppSync SSO HTML pages.
   Served from /sso.css; CSP forbids 'unsafe-inline' for styles, so all
   styling lives here. Animations use @keyframes only (no JS). */

:root {
  /* Palette */
  --c-bg-1: #2a1452;
  --c-bg-2: #5b2a83;
  --c-bg-3: #b35590;
  --c-bg-4: #f0a98c;
  --c-card: #ffffff;
  --c-text: #1a1326;
  --c-muted: #6f5b85;
  --c-input-bg: #ee8893;
  --c-input-bg-2: #f0a098;
  --c-input-text: #ffffff;
  --c-input-placeholder: rgba(255, 255, 255, 0.85);
  --c-primary: #2f1a55;
  --c-primary-hover: #432472;
  --c-link: #6a3d96;
  --c-link-hover: #4a2870;
  --c-danger: #b00045;
  --c-divider: rgba(0, 0, 0, 0.08);
  --c-chip: #f3eaf7;

  /* Geometry */
  --r-card: 22px;
  --r-pill: 999px;
  --r-control: 12px;
  --shadow-card: 0 24px 60px rgba(20, 6, 50, 0.35), 0 4px 12px rgba(20, 6, 50, 0.18);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--c-text);
  min-height: 100dvh;
  display: flex;
  flex-wrap: wrap;
  align-items: safe center;
  justify-content: safe center;
  padding: 24px;
  background: var(--c-bg-1);
  position: relative;
  overflow-x: hidden;
}

/* ── Animated gradient background ───────────────────────────────────── */
.bg {
  position: fixed;
  inset: -10vmax;
  z-index: -1;
  background:
    radial-gradient(45% 55% at 18% 22%, rgba(255, 180, 200, 0.55) 0%, transparent 60%),
    radial-gradient(40% 50% at 82% 28%, rgba(255, 220, 180, 0.45) 0%, transparent 65%),
    radial-gradient(60% 60% at 30% 85%, rgba(120, 60, 160, 0.55) 0%, transparent 65%),
    radial-gradient(60% 60% at 80% 80%, rgba(60, 30, 110, 0.6) 0%, transparent 65%),
    linear-gradient(135deg, var(--c-bg-1) 0%, var(--c-bg-2) 40%, var(--c-bg-3) 75%, var(--c-bg-4) 100%);
  background-size: 200% 200%, 200% 200%, 200% 200%, 200% 200%, 250% 250%;
  animation: drift 32s ease-in-out infinite alternate;
  filter: saturate(1.05);
}

@keyframes drift {
  0%   { background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%, 0% 0%; }
  50%  { background-position: 30% 20%, 70% 30%, 20% 70%, 80% 60%, 50% 50%; }
  100% { background-position: 60% 40%, 40% 60%, 50% 40%, 60% 80%, 100% 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .bg { animation: none; }
}

/* ── Card ───────────────────────────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 420px;
  background: var(--c-card);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card.wide {
  max-width: 760px;
}

.hero {
  height: 168px;
  background: #2a1452 url("/img/auth_visual.png") center / cover no-repeat;
  position: relative;
}
.hero-caption {
  position: absolute;
  left: 34px;
  bottom: 2px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  z-index: 2;
}

.panel {
  padding: 10px 32px 28px;
}

.card.wide .panel {
  padding: 36px 40px 40px;
}
.card.wide .panel > .dash-nav:first-child {
  margin-top: -36px;
}

/* ── Typography ─────────────────────────────────────────────────────── */
h1 {
  margin: 0 0 4px;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
h1 + p { margin-top: 0; }

h2 {
  margin: 28px 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--c-text);
}

p { margin: 8px 0; }
.notice { color: var(--c-muted); font-size: 0.92rem; }
.password-rules { margin: -8px 0 8px 7px; }
.error  { color: var(--c-danger); font-weight: 500; padding: 8px 0; }
.success { color: #1a7a4a; font-weight: 500; padding: 8px 0; }
.muted { color: var(--c-muted); font-size: 0.92rem; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.badge-on  { background: #d6f3e2; color: #1a7a4a; }
.badge-off { background: #ece8f3; color: var(--c-muted); }

a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-link-hover); text-decoration: underline; }

/* ── Forms ──────────────────────────────────────────────────────────── */
form { display: flex; flex-direction: column; gap: 14px; margin: 6px 0 8px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--c-muted);
}

/* Pill input wrapper (for primary auth fields with leading icon) */
.field {
  position: relative;
  display: flex;
  align-items: center;
}

.field > .icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--c-primary);
  pointer-events: none;
  opacity: 0.8;
}
.field > .icon svg { width: 100%; height: 100%; display: block; fill: currentColor; }

/* Specificity 0,2,1 — beats plain input[type=x] rules (0,1,1) below */
.field > input[type] {
  width: 100%;
  padding: 14px 18px 14px 46px;
  font: inherit;
  background: #fff;
  color: var(--c-primary);
  border: 1.5px solid var(--c-primary);
  border-radius: var(--r-pill);
  outline: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.field > input[type]::placeholder { color: var(--c-muted); opacity: 0.7; }
.field > input[type]:focus { border-color: var(--c-primary-hover); box-shadow: 0 0 0 3px rgba(47, 26, 85, 0.15); }

/* Plain inputs (used on profile / 2fa etc. — less visual weight) */
input[type=text],
input[type=email],
input[type=password],
input[type=tel],
input[type=number] {
  padding: 10px 14px;
  font: inherit;
  color: var(--c-text);
  background: #fff;
  border: 1px solid #d6cbe2;
  border-radius: var(--r-control);
  outline: none;
}
input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=tel]:focus,
input[type=number]:focus { border-color: var(--c-primary); box-shadow: 0 0 0 3px rgba(47, 26, 85, 0.15); }

/* ── Buttons ────────────────────────────────────────────────────────── */
button, .btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--c-primary);
  color: #fff;
  border: 0;
  border-radius: var(--r-pill);
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover, .btn:hover { background: var(--c-primary-hover); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid rgba(47, 26, 85, 0.35); outline-offset: 2px; }
button.secondary { background: #ece2f4; color: var(--c-primary); }
button.secondary:hover { background: #ddcfe9; }

/* ── Auth helper row (forgot pw, create account links under form) ───── */
.auth-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  margin: 4px 2px 0px;
  color: var(--c-muted);
}

.auth-meta a { color: var(--c-link); font-weight: 700; }

.auth-foot {
  text-align: center;
  margin: 8px 0 0;
  font-size: 0.92rem;
  color: var(--c-muted);
}
.auth-foot a { font-weight: 600; }

/* ── Dashboard nav bar (full-bleed inside wide card) ────────────────── */
.dash-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 -40px 28px;
  padding: 14px 40px;
  background: var(--c-primary);
  color: #fff;
  font-size: 0.95rem;
  border-radius: var(--r-card) var(--r-card) 0 0;
}
.dash-nav-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #fff;
  text-decoration: none;
}
a.dash-nav-title:hover { text-decoration: none; }
.dash-nav-welcome {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  line-height: 1;
  color: rgba(255, 255, 255, 0.85);
  margin-left: 18px;
}
.dash-nav-welcome svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: currentColor;
}
.dash-nav-welcome .icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  color: currentColor;
}
.dash-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto;
}
.dash-nav a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-weight: 500;
  line-height: 1;
}
.dash-nav a:hover {
  color: #fff;
  text-decoration: underline;
}

/* ── App icon grid ───────────────────────────────────────────────────── */
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px 16px;
  padding: 4px 0 8px;
}

.app-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 10px 14px;
  border-radius: 14px;
  text-decoration: none;
  color: var(--c-text);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
  width: 100%;
  box-sizing: border-box;
  font: inherit;
}
.app-tile:hover:not(.locked) { background: #f3eaf7; }
.app-tile.locked { cursor: default; }

form.app-tile {
  padding: 0;
  margin: 0;
  background: none;
}

.app-tile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 10px 14px;
  border-radius: 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font: inherit;
  color: var(--c-text);
  width: 100%;
  opacity: 0.65;
  transition: background 0.15s ease;
}
.app-tile-btn:hover { background: #f3eaf7; opacity: 0.75; }

.app-icon {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--c-chip);
  display: flex;
  align-items: center;
  justify-content: center;
}
.app-icon-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.app-icon-initials {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--c-primary);
  line-height: 1;
  user-select: none;
}
.app-tile-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lock-icon {
  width: 26px;
  height: 26px;
  fill: var(--c-primary);
  opacity: 0.6;
}
.app-label {
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  color: var(--c-text);
  line-height: 1.3;
  max-width: 80px;
  overflow-wrap: break-word;
}

/* ── 2FA helpers ────────────────────────────────────────────────────── */
.code-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  padding: 16px;
  background: var(--c-chip);
  border-radius: var(--r-control);
}
.qr {
  background: #fff;
  padding: 16px;
  max-width: 256px;
  margin: 16px 0;
  border-radius: var(--r-control);
  border: 1px solid var(--c-divider);
}

details { margin: 8px 0; }
summary { cursor: pointer; color: var(--c-link); }

/* ── Build stamp (bottom-right of every SSO page) ───────────────────── */
.build-info {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
  user-select: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.build-info a {
  color: inherit;
  text-decoration: none;
  pointer-events: auto;
}
.build-info a:hover { text-decoration: underline; }
.build-info-sep { margin: 0 6px; opacity: 0.6; }

/* ── Page footer (legal links) ──────────────────────────────────────── */
.page-footer {
  flex-basis: 100%;
  margin-top: 24px;
  text-align: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.page-footer a {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
}
.page-footer a:hover { text-decoration: underline; }
.page-footer-sep { margin: 0 8px; opacity: 0.6; }

/* ── Legal pages ────────────────────────────────────────────────────── */
.legal-content {
  min-width: 0;
  line-height: 1.6;
  color: var(--c-text);
  max-width: 720px;
}
.legal-content h1 { font-size: 1.7rem; margin: 8px 0 16px; }
.legal-content h2 { margin: 28px 0 10px; font-size: 1.15rem; color: var(--c-primary); }
.legal-content h3 { margin: 22px 0 8px; font-size: 1rem; font-weight: 600; }
.legal-content p { margin: 10px 0; }
.legal-content ul, .legal-content ol { padding-left: 22px; margin: 10px 0; }
.legal-content li { margin: 6px 0; }
.legal-content a { color: var(--c-link); }
.legal-content a:hover { text-decoration: underline; }
.legal-content blockquote {
  margin: 14px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--c-primary);
  background: #f3eef9;
  color: var(--c-text);
  font-size: 0.95rem;
}
.legal-content table {
  border-collapse: collapse;
  margin: 12px 0;
}
.legal-content th, .legal-content td {
  border: 1px solid var(--c-divider);
  padding: 6px 10px;
  text-align: left;
  font-size: 0.92rem;
}
.legal-content th { background: var(--c-chip); }

/* ── Profile danger zone ────────────────────────────────────────────── */
.danger-zone {
  margin-top: 32px;
  padding: 18px;
  border: 1.5px solid var(--c-danger);
  border-radius: var(--r-control);
  background: #fff5f8;
}
.danger-zone h2 { color: var(--c-danger); margin-top: 0; }
.danger-zone button {
  background: var(--c-danger);
}
.danger-zone button:hover { background: #8a0036; }

/* ── Consent + plain checkboxes ─────────────────────────────────────── */
.consent {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.92rem;
  color: var(--c-text);
  padding: 4px 2px;
  text-align: left;
}
.consent > span { flex: 1; }
.consent input[type="checkbox"] {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--c-primary);
  flex-shrink: 0;
}
.consent a { color: var(--c-link); text-decoration: underline; }
.consent a:hover { color: var(--c-link-hover); }

/* ── Small screens ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .panel { padding: 24px 22px 22px; }
  .hero { height: 140px; }
  h1 { font-size: 1.6rem; }
  .dash-nav-welcome { display: none; }
}

/* ── Help pages ─────────────────────────────────────────────────────── */
.help-foot { margin-top: 14px; }

.help-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 32px;
  margin-top: 8px;
}

.help-nav {
  border-right: 1px solid #e7e2ee;
  padding-right: 20px;
}
.help-nav h2 {
  margin: 4px 0 12px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-muted);
}
.help-nav h2 + ul + h2 { margin-top: 24px; }
.help-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.help-nav li { margin: 0; }
.help-nav-item {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--c-text);
  font-size: 0.95rem;
  text-decoration: none;
  line-height: 1.3;
}
.help-nav-item:hover { background: #f3eef9; }
.help-nav-item.current {
  background: var(--c-primary);
  color: #fff;
  font-weight: 600;
}

.help-content {
  min-width: 0;
  line-height: 1.55;
  color: var(--c-text);
}
.help-content h1 {
  font-size: 1.7rem;
  margin: 0 0 16px;
}
.help-content h2 {
  margin: 28px 0 10px;
  font-size: 1.15rem;
  color: var(--c-primary);
  border: none;
}
.help-content h3 {
  margin: 22px 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--c-text);
}
.help-content p { margin: 10px 0; }
.help-content ul, .help-content ol { padding-left: 22px; margin: 10px 0; }
.help-content li { margin: 6px 0; }
.help-content a { color: var(--c-link); }
.help-content a:hover { text-decoration: underline; }
.help-content strong { font-weight: 600; }
.help-content code {
  background: #f3eef9;
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.92em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (max-width: 785px) {
  .help-layout { grid-template-columns: 1fr; }
  .help-nav { display: none; }
}

/* Language switcher
   Uses native <details>/<summary> so it works without JavaScript and stays
   compliant with our strict CSP. */
.title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.title-row h1 { margin: 0; }

.lang-switcher {
  position: relative;
  display: inline-block;
}
.lang-switcher > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--r-control);
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  user-select: none;
}
.lang-switcher > summary::-webkit-details-marker { display: none; }
.lang-switcher > summary::after {
  content: "▾";
  font-size: 0.7em;
  opacity: 0.7;
}
.lang-switcher > summary:hover { background: rgba(255, 255, 255, 0.16); }

.lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 50;
  background: var(--c-card);
  color: var(--c-text);
  border-radius: var(--r-control);
  box-shadow: 0 8px 24px rgba(20, 6, 50, 0.25);
  min-width: 160px;
  padding: 6px 0;
  list-style: none;
  margin: 0;
}
.lang-menu .lang-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--c-text);
  white-space: nowrap;
}
.lang-menu .lang-item:hover { background: var(--c-chip); color: var(--c-text); }
.lang-menu .lang-item.current { font-weight: 600; }

.flag {
  display: inline-block;
  width: 24px;
  height: 16px;
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}
.flag svg { display: block; width: 100%; height: 100%; }

/* In dashboards, the switcher sits inside .dash-nav-links so colors flip
   and the pill stays flush with the surrounding text height. */
.dash-nav-links .lang-switcher > summary {
  background: transparent;
  color: inherit;
  padding: 0;
  gap: 4px;
}
.dash-nav-links .lang-switcher > summary:hover {
  background: transparent;
  color: #fff;
}
.dash-nav-links .lang-switcher .flag {
  width: 20px;
  height: 14px;
}
