/* ============================================================
   KAIS Contact Page — Matches Homepage Dark Sophisticated Theme
   ============================================================ */

:root {
  --brand: #6aa8ff;
  --brand-2: #9b6dff;
  --ok: #2fd37a;
  --kais-green: #2fd37a;
  --kais-blue: #6aa8ff;
  --kais-purple: #9b6dff;
  --bg-page: #0b1020;
  --bg-alt: #0e1429;
  --bg-card: #121939;
  --text-heading: #e7e9f3;
  --text-body: #b9bfd3;
  --text-muted: #7a83a0;
  --border-light: rgba(255, 255, 255, .1);
  --border-card: rgba(255, 255, 255, .08);
  --shadow-card: 0 10px 30px rgba(0, 0, 0, .35);
  --shadow-card-hover: 0 25px 60px rgba(31, 45, 92, .45);
  --shadow-btn: 0 4px 15px rgba(106, 168, 255, .3);
  --radius-card: 20px;
  --radius-btn: 999px;
  --container: 1140px;
  --font: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --gradient-cta: linear-gradient(90deg, var(--brand), var(--brand-2));
}

/* 1b. Light palette
   ------------------------------------------------------------
   WHAT WAS HERE BEFORE, AND WHY IT WAS A BUG.
   This file shipped a bare `@media (prefers-color-scheme: light) { :root
   { … } }`. That block is live for a light-OS visitor who explicitly
   chose DARK — and because page sheets are linked from
   `{% block extra_head %}`, i.e. AFTER theme.css, its `:root` (0,1,0)
   also beat theme.css's own dark `:root` on source order. The result was
   a bright island inside dark chrome, which is the exact regression
   theme.css's THEMING banner documents.

   The fix is two-part and needs BOTH halves: the media block's interior
   is now scoped to `:root[data-theme="auto"]`, and the same values are
   spelled out again under `:root[data-theme="light"]` for the explicit
   opt-in. Re-guarding alone would leave a chosen-light visitor dark.

   The values cannot be shared through an indirection — the contrast
   sweep in tests/test_static/test_theme_pages_a.py resolves them to
   opaque hex — so KEEP THE TWO BLOCKS IN SYNC. A test does too.
   `@media` adds ZERO specificity, which is why the scoping, not the
   ordering, is what makes this safe.
   ------------------------------------------------------------ */
:root[data-theme="light"] {
  color-scheme: light;
  accent-color: #2563eb;

  /* -- surface vocabulary (in step with theme.css section A2) --------- */
  --bg-page: #f1f5f9;
  --bg-alt: #e8eef6;
  --bg-card: #ffffff;
  --text-heading: #0f172a;
  --text-body: #334155;
  --text-muted: #475569;

  /* White-alpha veils invert to black-alpha — an rgba(255,255,255,.1)
     hairline is invisible on a white card. */
  --border-light: rgba(15, 23, 42, .12);
  --border-card: rgba(15, 23, 42, .10);

  --shadow-card: 0 10px 30px rgba(15, 23, 42, .10);
  --shadow-card-hover: 0 25px 60px rgba(31, 45, 92, .18);
  --shadow-btn: 0 4px 15px rgba(29, 78, 216, .25);

  /* Accent INK — the six `--*-ink` tokens are declared ONCE, in theme.css
     sections A2/A3, and reset in D2 so a still-dark island cannot inherit
     light ink onto a dark surface. They are NOT re-declared here: two
     copies of one value have already drifted in this repo. Consumers stay
     `var(--accent-ink, var(--brand))`, so dark mode still falls back to
     the brand literal by construction.
     tests/test_static/test_theme_pages_a.py pins theme.css as the source,
     so a rename there fails a test instead of silently un-inking six
     pages. */
  /* The brand gradient used as INK, for the `background-clip: text` sites
     only. --gradient-cta itself is NOT flipped: it is also the resting
     background of buttons and badges whose labels are white or near-black,
     and darkening it there breaks those pairings (theme.css section C makes
     the same argument for .text-white).

     COMPOSED from the ink tokens rather than restating their hexes, so
     #1d4ed8 / #6d28d9 have exactly one source (theme.css A2/A3) and this
     cannot drift from it. MEASURED degradation, because the rule here is
     not obvious: if theme.css ever stops publishing those tokens this
     value becomes guaranteed-invalid, the OUTER
     `var(--gradient-cta-ink, var(--gradient-cta))` at each call site takes
     ITS fallback, and the text paints with the brand gradient — the
     dark-mode appearance, not blank text. Verified in Chromium rather than
     reasoned about, because the opposite outcome (invisible headings) is
     the repo's worst failure class. */
  --gradient-cta-ink: linear-gradient(90deg, var(--accent-ink), var(--accent-2-ink));
  /* White-on-CTA. The brand gradient measures 2.6:1 under white text
     (home.css says so at --brand-accent-strong), which is site debt in
     BOTH themes — but a pale blue button on a white card is where it is
     most visible. Only the BUTTON reads this token; --gradient-cta
     itself stays put so accent stripes and badges are unaffected.
     Measured white-on: 6.7:1 and 7.1:1. */
  --cta-surface: linear-gradient(90deg, #1d4ed8, #6d28d9);

  /* Gradient TEXT (background-clip: text) — BOTH stops are read as ink,
     so the pale second stop has to darken too. */
  --highlight-green: linear-gradient(90deg, #14532d, #166534);
  --highlight-blue: linear-gradient(90deg, #1e40af, #1d4ed8);
  --highlight-purple: linear-gradient(90deg, #5b21b6, #6d28d9);
  --highlight-orange: linear-gradient(90deg, #78350f, #9a3412);

  /* The card wash ships as a hard literal. Its consumer is
     `var(--card-surface, <the exact literal>)`, so dark mode is
     byte-identical BY CONSTRUCTION rather than by a retyped value —
     and a white-on-white wash would make every card vanish here. */
  --card-surface: #ffffff;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="auto"] {
    color-scheme: light;
    accent-color: #2563eb;

    /* -- surface vocabulary (in step with theme.css section A2) --------- */
    --bg-page: #f1f5f9;
    --bg-alt: #e8eef6;
    --bg-card: #ffffff;
    --text-heading: #0f172a;
    --text-body: #334155;
    --text-muted: #475569;

    /* White-alpha veils invert to black-alpha — an rgba(255,255,255,.1)
       hairline is invisible on a white card. */
    --border-light: rgba(15, 23, 42, .12);
    --border-card: rgba(15, 23, 42, .10);

    --shadow-card: 0 10px 30px rgba(15, 23, 42, .10);
    --shadow-card-hover: 0 25px 60px rgba(31, 45, 92, .18);
    --shadow-btn: 0 4px 15px rgba(29, 78, 216, .25);

    /* Accent INK — the six `--*-ink` tokens are declared ONCE, in theme.css
       sections A2/A3, and reset in D2 so a still-dark island cannot inherit
       light ink onto a dark surface. They are NOT re-declared here: two
       copies of one value have already drifted in this repo. Consumers stay
       `var(--accent-ink, var(--brand))`, so dark mode still falls back to
       the brand literal by construction.
       tests/test_static/test_theme_pages_a.py pins theme.css as the source,
       so a rename there fails a test instead of silently un-inking six
       pages. */
    /* The brand gradient used as INK, for the `background-clip: text` sites
       only. --gradient-cta itself is NOT flipped: it is also the resting
       background of buttons and badges whose labels are white or near-black,
       and darkening it there breaks those pairings (theme.css section C makes
       the same argument for .text-white).

       COMPOSED from the ink tokens rather than restating their hexes, so
       #1d4ed8 / #6d28d9 have exactly one source (theme.css A2/A3) and this
       cannot drift from it. MEASURED degradation, because the rule here is
       not obvious: if theme.css ever stops publishing those tokens this
       value becomes guaranteed-invalid, the OUTER
       `var(--gradient-cta-ink, var(--gradient-cta))` at each call site takes
       ITS fallback, and the text paints with the brand gradient — the
       dark-mode appearance, not blank text. Verified in Chromium rather than
       reasoned about, because the opposite outcome (invisible headings) is
       the repo's worst failure class. */
    --gradient-cta-ink: linear-gradient(90deg, var(--accent-ink), var(--accent-2-ink));
    /* White-on-CTA. The brand gradient measures 2.6:1 under white text
       (home.css says so at --brand-accent-strong), which is site debt in
       BOTH themes — but a pale blue button on a white card is where it is
       most visible. Only the BUTTON reads this token; --gradient-cta
       itself stays put so accent stripes and badges are unaffected.
       Measured white-on: 6.7:1 and 7.1:1. */
    --cta-surface: linear-gradient(90deg, #1d4ed8, #6d28d9);

    /* Gradient TEXT (background-clip: text) — BOTH stops are read as ink,
       so the pale second stop has to darken too. */
    --highlight-green: linear-gradient(90deg, #14532d, #166534);
    --highlight-blue: linear-gradient(90deg, #1e40af, #1d4ed8);
    --highlight-purple: linear-gradient(90deg, #5b21b6, #6d28d9);
    --highlight-orange: linear-gradient(90deg, #78350f, #9a3412);

    /* The card wash ships as a hard literal. Its consumer is
       `var(--card-surface, <the exact literal>)`, so dark mode is
       byte-identical BY CONSTRUCTION rather than by a retyped value —
       and a white-on-white wash would make every card vanish here. */
    --card-surface: #ffffff;
  }
}

.kais-contact {
  background: radial-gradient(1200px 600px at 80% -10%, rgba(155, 109, 255, .15), transparent),
              radial-gradient(900px 500px at -10% 10%, rgba(106, 168, 255, .15), transparent),
              var(--bg-page) !important;
  color: var(--text-body) !important;
  font-family: var(--font);
}

.kais-contact *,
.kais-contact *::before,
.kais-contact *::after {
  box-sizing: border-box;
}

/* Layout */
.kais-contact .kais-container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

/* Gradient text highlights */
.kais-contact .highlight-green {
  background: var(--highlight-green, linear-gradient(90deg, var(--ok), #5dffb0));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Hero Section */
.contact-hero {
  position: relative;
  overflow: hidden;
  padding-top: clamp(2rem, 5vw, 4rem);
  padding-bottom: clamp(2rem, 4vw, 3rem);
  background: radial-gradient(1200px 600px at 80% -10%, rgba(155, 109, 255, .25), transparent),
              radial-gradient(900px 500px at -10% 10%, rgba(106, 168, 255, .25), transparent),
              var(--bg-page);
  text-align: center;
}

.contact-hero-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
  opacity: 0;
  transform: translateY(20px);
  animation: contact-fade-in 0.7s ease 0.2s forwards;
}

.contact-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(106, 168, 255, .12);
  color: var(--accent-ink, var(--brand));
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-btn);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.contact-heading {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 800;
  color: var(--text-heading);
  line-height: 1.1;
  margin: 0;
}

.contact-subtitle {
  font-size: clamp(1rem, 2vw, 1.15rem);
  color: var(--text-body);
  line-height: 1.6;
  margin: 0;
  max-width: 32rem;
}

/* Decorative orbs */
.contact-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(14px);
  opacity: 0.7;
}

.contact-orb-1 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, rgba(106, 168, 255, .3), transparent 70%);
  top: -100px;
  right: -80px;
  animation: contact-float 18s ease-in-out infinite;
}

.contact-orb-2 {
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(155, 109, 255, .25), transparent 70%);
  bottom: -60px;
  left: -60px;
  animation: contact-float 14s ease-in-out infinite reverse;
}

@keyframes contact-float {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(40px, -30px); }
  50% { transform: translate(-40px, 20px); }
  75% { transform: translate(60px, -20px); }
}

@keyframes contact-fade-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Form Section */
.contact-form-section {
  padding-block: clamp(2rem, 5vw, 4rem);
}

.contact-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  max-width: 960px;
  margin-inline: auto;
}

@media (min-width: 768px) {
  .contact-grid {
    grid-template-columns: 1.4fr 1fr;
    gap: 3rem;
  }
}

/* Contact Card (form container) */
.contact-card {
  background: var(--card-surface, linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02)));
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.contact-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-cta);
  z-index: 2;
}

/* Form styling — override crispy-tailwind's gray labels on dark bg */
.contact-form label,
.contact-form .asteriskField,
.contact-card label {
  color: var(--text-heading) !important;
  font-weight: 600;
  font-size: 0.9rem;
}

.contact-form p,
.contact-form span,
.contact-form .form-text,
.contact-form .help-block,
.contact-form small,
.contact-card .mb-3 > p {
  color: var(--text-muted) !important;
}

.contact-form .text-danger,
.contact-form .invalid-feedback,
.contact-form [id*="error"] {
  color: var(--danger-ink, #FF4B4B) !important;
}

.contact-submit {
  width: 100%;
  margin-top: 1rem;
  gap: 0.5rem;
}

/* Info sidebar */
.contact-info {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.info-card {
  background: var(--card-surface, linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(255, 255, 255, .02)));
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 1.5rem;
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  backdrop-filter: saturate(140%) blur(8px);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  position: relative;
  overflow: hidden;
}

.info-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-cta);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.5s ease;
  z-index: 2;
}

.info-card:hover::before {
  transform: scaleX(1);
}

.info-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-card-hover);
}

.info-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.info-card:hover .info-icon {
  transform: scale(1.15) rotate(-5deg);
}

.info-card h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-heading);
  margin: 0 0 0.25rem;
}

.info-card p {
  font-size: 0.9rem;
  color: var(--text-body);
  margin: 0;
  line-height: 1.5;
}

/* Button — reuse homepage pattern */
.kais-contact .btn-kais-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--cta-surface, var(--gradient-cta));
  color: #fff;
  border: none;
  border-radius: var(--radius-btn);
  padding: 0.9rem 2rem;
  font-weight: 700;
  font-size: 1.05rem;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
  box-shadow: var(--shadow-btn);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.kais-contact .btn-kais-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-2), var(--brand));
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
}

.kais-contact .btn-kais-primary:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(106, 168, 255, .4);
}

.kais-contact .btn-kais-primary:hover::before {
  opacity: 1;
}

.kais-contact .btn-kais-primary:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 767px) {
  .contact-grid {
    gap: 2rem;
  }

  .contact-info {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .info-card {
    flex: 1 1 100%;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .contact-hero-text {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .contact-orb-1,
  .contact-orb-2 {
    animation: none;
  }
}

/* CSP inline-style cleanup: variant backgrounds for the contact
   info-card icon. Replaces `style="background: var(--kais-X);"`
   attributes in kais/templates/account/contact_us.html. */
.info-icon--blue   { background: var(--kais-blue); }
.info-icon--purple { background: var(--kais-purple); }
.info-icon--green  { background: var(--kais-green); }

/* CSP cleanup: rules previously inlined as a `<style nonce>` block
   in kais/templates/account/contact_success.html. */
.success-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.5rem;
  justify-content: center;
}
.contact-hero {
  min-height: 60vh;
  display: flex;
  align-items: center;
}
.contact-hero .kais-container {
  width: 100%;
}
.btn-kais-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: transparent;
  color: var(--text-heading, #e7e9f3);
  border: 1px solid var(--border-light, rgba(255, 255, 255, .1));
  border-radius: 999px;
  padding: 0.85rem 1.8rem;
  font-weight: 600;
  font-size: 1.05rem;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-kais-ghost:hover {
  border-color: var(--brand, #6aa8ff);
  background: rgba(106, 168, 255, .08);
  transform: translateY(-2px);
}
