/* ===========================================================================
   Enterprise design system — shared by the portal gateway (index.php) and the
   validation portal (dynportal/valid8.php). Single source of truth: change a
   token here and both pages follow.

   Fixed premium dark theme (Voipify / Sourceed). This is a deliberately locked
   dark presentation: it does NOT follow the browser/OS light preference — see
   the color-scheme + explicit tokens below. Accent palette is restricted to the
   four brand violets; everything else is neutral black/white/grey. The centred
   card is the dominant focus; #bg-canvas paints an ambient particle field
   behind it (particles.js).

   Mobile-first. Vertical rhythm is vh-based clamp() so layouts compress on
   short viewports (1366x768 laptops, landscape phones) instead of overflowing.
   =========================================================================== */

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

:root {
  /* Locked dark: never auto-switch native controls to a light rendering. */
  color-scheme: dark;

  /* fluid scale: min for phones, preferred grows with viewport, max for desktop */
  --card-pad-y: clamp(1.15rem, 2.4vh, 2.2rem);
  --card-pad-x: clamp(1.1rem,  4vw,   2.4rem);
  --rhythm:     clamp(0.5rem,  1.5vh, 1.05rem);

  /* brand accent palette — ONLY these four violets are used as accents */
  --accent-deep: #6D28D9;
  --accent:      #8A2BE2;
  --accent-lit:  #A855F7;
  --accent-soft: #C084FC;
  --accent-ink:  #ffffff;

  /* neutral surfaces / ink on deep matte black */
  --page:      #0B0B0F;
  --ink:       #eef0f6;
  --rule:      rgba(168,133,247,0.14);
  --surface:   rgba(17,15,24,0.82);
  --edge:      rgba(180,170,210,0.16);
  --notice-bg: rgba(255,255,255,0.035);
  --field-bg:  rgba(8,7,13,0.72);

  /* functional status colours (form validation legibility — not brand accents) */
  --danger:    #ff6f6f;
  --success:   #74dca0;
  --warn:      #d8a24a;
  --radius:    10px;
}

html { -webkit-text-size-adjust: 100%; }

/* Ambient particle background: fixed, non-interactive, painted behind the card.
   Deep matte black base shows through until particles.js starts (and stays as
   the fallback if scripting is disabled). */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--page);
  z-index: 0;
  pointer-events: none;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--page);
  color: var(--ink);
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  place-items: safe center;
  padding: clamp(0.5rem, 1.6vh, 1.5rem) clamp(0.5rem, 3vw, 1.5rem);
  padding-left:  max(clamp(0.5rem, 3vw, 1.5rem), env(safe-area-inset-left));
  padding-right: max(clamp(0.5rem, 3vw, 1.5rem), env(safe-area-inset-right));
}

/* ---- Card ---------------------------------------------------------------- */
/* Sits above the particle canvas. Translucent dark glass so the field is just
   visible at the edges while the card body stays clearly dominant. */
.card {
  position: relative;
  z-index: 1;
  width: min(100%, 40rem);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: clamp(10px, 1.4vw, 14px);
  padding: var(--card-pad-y) var(--card-pad-x);
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.45),
    0 34px 90px -28px rgba(109,40,217,0.42),
    0 12px 40px -22px rgba(0,0,0,0.75);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
}
.card--narrow { width: min(100%, 27rem); }

/* ---- Sourceed corporate identity ----------------------------------------- */
.brand {
  text-align: center;
  padding-bottom: calc(var(--rhythm) * 1.3);
  margin-bottom: calc(var(--rhythm) * 1.4);
  border-bottom: 1px solid var(--rule);
}
/* Fallback: the logo ships with an opaque black backdrop and no alpha channel,
   so present it as a deliberate brand plate rather than a stray black box. */
.brand-mark { display: inline-flex; padding: .5rem .85rem; border-radius: var(--radius);
              background: #000; }
.brand-mark img { display: block; width: clamp(132px, 30vw, 184px); height: auto; }
/* Preferred: drop the backdrop so the wordmark sits directly on the dark card. */
@supports (mix-blend-mode: screen) {
  .brand-mark { background: transparent; padding: 0; }
  .brand-mark img { mix-blend-mode: screen; }
}
.slogan {
  margin: calc(var(--rhythm) * .7) 0 0;
  font-size: clamp(.68rem, .62rem + .22vw, .82rem);
  letter-spacing: .06em; text-transform: uppercase; opacity: .6;
}
.portal-name {
  margin: calc(var(--rhythm) * 1.25) 0 0;
  font-size: clamp(.95rem, .89rem + .3vw, 1.05rem);
  font-weight: 600; letter-spacing: .01em;
  color: var(--accent-soft);
}
.tagline {
  margin: calc(var(--rhythm) * .5) auto 0;
  max-width: 46ch;
  font-size: clamp(.78rem, .74rem + .22vw, .875rem);
  line-height: 1.5; opacity: .68; text-wrap: pretty;
}

/* ---- Headings and body text ---------------------------------------------- */
h1 {
  margin: 0 0 calc(var(--rhythm) * .3);
  font-size: clamp(1.15rem, 1.02rem + .65vw, 1.45rem);
  line-height: 1.2;
}
.sub {
  margin: 0 0 calc(var(--rhythm) * 1.5);
  font-size: clamp(.83rem, .79rem + .25vw, .93rem);
  line-height: 1.5; opacity: .72; overflow-wrap: anywhere;
}
code { font-size: .85em; color: var(--accent-soft); }

/* ---- Portal selection cards (gateway) ------------------------------------ */
.grid { display: grid; gap: var(--rhythm); grid-template-columns: 1fr; }
@media (min-width: 30rem) { .grid { grid-template-columns: 1fr 1fr; } }

a.portal {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 3.25rem;
  padding: clamp(.8rem, 1.6vh, 1.1rem) clamp(.9rem, 2.5vw, 1.2rem);
  border: 1px solid var(--edge); border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s, background .15s;
}
a.portal:hover, a.portal:focus-visible {
  border-color: var(--accent-lit);
  transform: translateY(-2px);
  background: rgba(138,43,226,0.10);
  box-shadow: 0 14px 34px -18px rgba(138,43,226,0.6);
}
a.portal:focus-visible { outline: 2px solid var(--accent-lit); outline-offset: 2px; }
a.portal strong { display: block; font-size: clamp(.98rem, .94rem + .2vw, 1.06rem); margin-bottom: .15rem; }
a.portal span   { font-size: clamp(.8rem, .77rem + .18vw, .87rem); opacity: .72; }
@media (hover: none) { a.portal:hover { transform: none; } }

/* ---- Form controls (validation portal) ----------------------------------- */
/* Single column by default. On short-and-wide viewports (landscape phones) the
   two credential fields sit side by side, which reclaims a whole field of
   height so the submit button stays above the fold. */
.form-row { display: grid; grid-template-columns: 1fr; gap: 0 var(--rhythm); }
@media (min-width: 34rem) and (max-height: 30rem) {
  .form-row { grid-template-columns: 1fr 1fr; }
}
.field { display: block; margin-bottom: var(--rhythm); }
.field > label {
  display: block; margin-bottom: .35rem;
  font-size: clamp(.78rem, .75rem + .18vw, .85rem);
  font-weight: 600; letter-spacing: .01em; opacity: .85;
}
.field > input {
  width: 100%;
  font: inherit;
  font-size: clamp(.9rem, .87rem + .2vw, 1rem);
  padding: .7rem .85rem;
  min-height: 2.9rem;                    /* comfortable touch target */
  color: var(--ink);
  background: var(--field-bg);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
}
.field > input::placeholder { color: rgba(238,240,246,0.35); }
.field > input:focus {
  outline: none;
  border-color: var(--accent-lit);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-lit) 30%, transparent);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%;
  min-height: 3rem;
  padding: .75rem 1.2rem;
  font: inherit;
  font-size: clamp(.92rem, .89rem + .2vw, 1rem);
  font-weight: 600;
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  border: 1px solid var(--accent-lit);
  border-radius: var(--radius);
  cursor: pointer;
  box-shadow: 0 10px 30px -12px rgba(138,43,226,0.7);
  transition: filter .15s, transform .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.10); transform: translateY(-1px); box-shadow: 0 16px 40px -14px rgba(168,85,247,0.75); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
@media (hover: none) { .btn:hover { transform: none; } }

/* ---- Status messages ------------------------------------------------------ */
.alert {
  margin: var(--rhythm) 0 0;
  padding: clamp(.6rem, 1.2vh, .8rem) clamp(.7rem, 2vw, .95rem);
  border: 1px solid var(--rule);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--notice-bg);
  font-size: clamp(.82rem, .79rem + .18vw, .9rem);
  line-height: 1.45;
  text-align: center;
}
.alert--error   { border-left-color: var(--danger);  color: var(--danger);  font-weight: 600; }
.alert--success { border-left-color: var(--success); color: var(--success); font-weight: 600; }
.alert--warn    { border-left-color: var(--warn);    color: var(--warn);    font-weight: 600; }

/* ---- Notice, footnote, attribution --------------------------------------- */
.foot {
  margin-top: calc(var(--rhythm) * 1.5);
  font-size: clamp(.76rem, .73rem + .16vw, .82rem);
  line-height: 1.5; opacity: .6;
}
.notice {
  margin-top: calc(var(--rhythm) * .85);
  padding: clamp(.6rem, 1.2vh, .75rem) clamp(.7rem, 2vw, .9rem);
  border: 1px solid var(--rule); border-radius: 8px;
  background: var(--notice-bg);
  font-size: clamp(.72rem, .69rem + .14vw, .78rem);
  line-height: 1.5; opacity: .82;
}
.colophon {
  margin-top: calc(var(--rhythm) * 1.3);
  padding-top: calc(var(--rhythm) * 1);
  border-top: 1px solid var(--rule);
  text-align: center;
  font-size: clamp(.68rem, .66rem + .12vw, .74rem);
  letter-spacing: .04em; opacity: .5;
}

/* ---- Height tiers: nothing is hidden, only tightened --------------------- */
@media (max-height: 46rem) {
  :root { --card-pad-y: clamp(.9rem, 1.9vh, 1.4rem); }
  .brand-mark img { width: clamp(120px, 24vw, 156px); }
  .tagline { max-width: 60ch; }
}
@media (max-height: 42rem) {
  :root { --rhythm: clamp(.34rem, .95vh, .7rem); --card-pad-y: clamp(.8rem, 1.6vh, 1.15rem); }
  .brand-mark img { width: clamp(110px, 22vw, 140px); }
  .tagline { font-size: .75rem; line-height: 1.42; }
  .sub     { line-height: 1.42; }
  a.portal { min-height: 2.9rem; padding: .62rem .85rem; }
  .foot    { line-height: 1.42; }
  .notice  { padding: .5rem .7rem; line-height: 1.42; }
  .field > input { min-height: 2.7rem; padding: .58rem .8rem; }
  .btn { min-height: 2.8rem; }
}
@media (max-height: 30rem) and (min-width: 34rem) {
  .brand { display: flex; align-items: center; gap: 1rem; text-align: left; flex-wrap: wrap; }
  .brand-mark img { width: 132px; }
  .slogan, .portal-name, .tagline { margin-top: 0; }
  .tagline { flex: 1 1 18rem; }
  /* The narrow form card must widen here, otherwise the horizontal brand block
     wraps and saves nothing. */
  .card--narrow { width: min(100%, 40rem); }
}
@media (max-height: 26rem) {
  :root { --rhythm: clamp(.26rem, .7vh, .5rem); --card-pad-y: .75rem;
          --card-pad-x: clamp(.85rem, 3vw, 1.3rem); }
  body { padding-top: .3rem; padding-bottom: .3rem; }
  .brand-mark img { width: clamp(104px, 18vw, 124px); }
  .slogan { font-size: .63rem; }
  .portal-name { font-size: .88rem; }
  .tagline { font-size: .72rem; line-height: 1.38; max-width: 70ch; }
  h1 { font-size: 1.02rem; }
  .sub { font-size: .76rem; line-height: 1.38; }
  a.portal { min-height: 2.5rem; padding: .5rem .75rem; }
  a.portal strong { font-size: .88rem; margin-bottom: .05rem; }
  a.portal span { font-size: .72rem; }
  .foot, .notice { font-size: .69rem; line-height: 1.38; }
  .notice { padding: .42rem .6rem; }
  .colophon { font-size: .65rem; padding-top: calc(var(--rhythm) * .8); }
  .field { margin-bottom: calc(var(--rhythm) * 1.1); }
  .field > input { min-height: 2.5rem; }
  .btn { min-height: 2.6rem; }
}

/* Motion only — the fixed dark theme and its colours are unaffected here.
   particles.js additionally freezes to a single static frame under this query. */
@media (prefers-reduced-motion: reduce) {
  a.portal, .btn, .field > input { transition: none; }
  a.portal:hover, .btn:hover { transform: none; }
}
