/* ===== Public portal look (landing, account, invoice, logins, error pages) =====
   Midnight aurora background, white cards with a translucent border, and the
   navy "stub" header whose bottom line shows progress (--stub-progress, 0–1). */

/* Colour tokens (--midnight, --signal, --ice, --frame, --glow…) are in theme.css. */
body.portal {
  display: block;
  min-height: 100vh;
  margin: 0;
  color: #fff;
  font-family: 'Geist', sans-serif;
  background: var(--midnight);
  overflow-x: hidden;
}

/* Slowly drifting base gradient behind the aurora canvas */
body.portal::before {
  content: ""; position: fixed; inset: -20%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 25%, rgba(61,111,196,.55), transparent 70%),
    radial-gradient(35% 45% at 80% 70%, rgba(124,58,237,.30), transparent 70%),
    radial-gradient(50% 60% at 60% 10%, rgba(22,48,94,.9), transparent 70%),
    linear-gradient(160deg, #0c1f4a 0%, var(--midnight) 60%);
  animation: portal-drift 28s ease-in-out infinite alternate;
}
@keyframes portal-drift {
  0%   { transform: translate3d(0, 0, 0) rotate(0deg) scale(1); }
  50%  { transform: translate3d(4%, -3%, 0) rotate(6deg) scale(1.05); }
  100% { transform: translate3d(-3%, 4%, 0) rotate(-4deg) scale(1.02); }
}

/* Drawn at low resolution by aurora.js; the blur hides the upscaled pixels.
   It overhangs the viewport so the blur doesn't fade out at the screen edges. */
.portal-aurora {
  position: fixed; inset: -40px; width: calc(100% + 80px); height: calc(100% + 80px);
  z-index: 0; pointer-events: none; filter: blur(14px);
}

/* Logo (a link home on inner pages) */
.portal-logo { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.portal-logo img { width: 38px; height: 38px; border-radius: 10px; object-fit: contain; }
.portal-logo .brand-name { display: block; font-size: .92rem; font-weight: 700; }
.portal-logo .brand-sub  { display: block; font-size: .76rem; color: rgba(255,255,255,.55); }

/* Headline on the dark background */
.portal-title {
  font-size: clamp(2.2rem, 4.6vw, 3.6rem); font-weight: 800; line-height: 1.04;
  letter-spacing: -.035em; color: #fff; margin: 0 0 18px;
}
.portal-lede { font-size: 1.02rem; line-height: 1.6; color: rgba(255,255,255,.72); max-width: 42ch; margin: 0; }

/* Links and quiet text on the dark background */
.portal-link { color: #fff; font-weight: 600; text-decoration: underline; text-decoration-color: rgba(255,255,255,.35); text-underline-offset: 3px; }
.portal-link:hover { text-decoration-color: #fff; }
.portal-footer { font-size: .74rem; color: rgba(255,255,255,.45); }
.portal-footer a { color: rgba(255,255,255,.7); }

/* ── Card ───────────────────────────────────────────────────────────── */

.portal-card {
  position: relative; overflow: hidden;
  /* Navy behind the stub's rounded corners so no white fringes through where they're clipped,
     and kept out from under the border so it stays see-through. */
  background: linear-gradient(var(--navy) 40px, #fff 40px) padding-box; color: var(--text);
  border: 3px solid var(--frame);
  border-radius: 20px; padding: 0 30px 26px;
  box-shadow: 0 30px 80px -20px rgba(3,10,30,.65);
}
/* A card without a stub is white to the top. */
.portal-card.is-plain { background: #fff padding-box; padding-top: 26px; }

/* The stub: navy header strip. Its bottom line fills to --stub-progress.
   --card-pad is the side padding of the card it sits in (bleeds edge to edge). */
.portal-stub {
  --card-pad: 30px;
  position: relative; margin: 0 calc(-1 * var(--card-pad)) 24px; padding: 18px var(--card-pad) 20px;
  background: linear-gradient(135deg, var(--navy), #16305E); color: #fff;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; align-items: center;
}
.portal-stub::before,
.portal-stub::after { content: ""; position: absolute; left: 0; bottom: 0; height: 3px; }
.portal-stub::before { right: 0; background: rgba(255,255,255,.12); }
.portal-stub::after {
  width: 100%; transform: scaleX(var(--stub-progress, 0)); transform-origin: left;
  background: var(--glow);
  box-shadow: 0 0 12px rgba(124,58,237,.55);
  transition: transform .35s cubic-bezier(.2,.8,.2,1), background .3s, box-shadow .3s;
}
.portal-stub.is-complete::after { box-shadow: 0 0 16px rgba(56,189,248,.7); }
.portal-stub.is-error::after { background: #F87171; box-shadow: 0 0 14px rgba(248,113,113,.6); }
.portal-stub.is-muted::after { background: rgba(255,255,255,.35); box-shadow: none; }
/* In progress (e.g. a bank payment clearing): a glow travels along the line */
.portal-stub.is-pending::after {
  transform: none; box-shadow: none;
  background: linear-gradient(90deg, transparent, #7C3AED, #38BDF8, transparent) no-repeat;
  background-size: 35% 100%; animation: portal-pending 2.4s ease-in-out infinite;
}
@keyframes portal-pending { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.portal-stub-label { font-size: .74rem; color: rgba(255,255,255,.6); }
.portal-stub-status { font-size: .86rem; font-weight: 600; }
.portal-stub.is-complete .portal-stub-status { color: var(--ice); }
.portal-stub.is-error .portal-stub-status { color: #FCA5A5; }
/* Right-hand side: spans both rows (a code, an amount…) */
.portal-stub-aside { grid-row: 1 / span 2; grid-column: 2; justify-self: end; text-align: right; }

/* ── Form pieces inside a card ──────────────────────────────────────── */

.portal-label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.portal-input {
  -webkit-appearance: none; appearance: none;
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1.5px solid #DCE3EF; background: var(--bg);
  font: 500 1rem 'Geist', sans-serif; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.portal-input:focus { border-color: var(--signal); background: #fff; box-shadow: 0 0 0 4px rgba(61,111,196,.18); }
.portal-input::placeholder { color: var(--faint); }
.portal-input:disabled { background: var(--gray-dim); color: var(--muted); }
.portal-input.has-error { border-color: rgba(220,38,38,.55); }
.portal-field + .portal-field { margin-top: 16px; }
.portal-error { margin: 8px 0 0; font-size: .78rem; color: var(--red); }

.portal-check { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: .82rem; color: var(--muted); cursor: pointer; }
.portal-check input { width: 16px; height: 16px; accent-color: var(--signal); }

.portal-btn {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; margin-top: 20px; padding: 15px; border: 0; border-radius: 12px;
  background: var(--navy); color: #fff; font: 700 .95rem 'Geist', sans-serif; text-decoration: none; cursor: pointer;
  transition: background-color .2s, transform .2s, box-shadow .2s, opacity .2s;
}
.portal-btn:hover:not(:disabled) { background: #16305E; transform: translateY(-1px); box-shadow: 0 10px 28px -8px rgba(12,31,74,.55); }
.portal-btn:focus-visible { outline: 3px solid var(--ice); outline-offset: 3px; }
.portal-btn:disabled { opacity: .45; cursor: not-allowed; }
.portal-btn.is-inline { display: inline-flex; width: auto; padding: 12px 22px; }
/* On the dark background itself (not in a card) */
.portal-btn.is-light { background: #fff; color: var(--navy); }
.portal-btn.is-light:hover:not(:disabled) { background: #E8EFFB; box-shadow: 0 10px 28px -8px rgba(0,0,0,.5); }
/* Busy: swap the label for a spinner + busy text (data-busy-label) */
.portal-btn.is-busy { pointer-events: none; }
.portal-btn.is-busy::before {
  content: ""; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: portal-spin .7s linear infinite;
}
@keyframes portal-spin { to { transform: rotate(360deg); } }

/* Secondary button on a light surface */
.portal-btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; border: 1.5px solid #DCE3EF; background: #fff;
  color: var(--text); font: 600 .88rem 'Geist', sans-serif; text-decoration: none; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.portal-btn-ghost:hover { border-color: #B8C7E3; background: var(--bg); }
.portal-btn-ghost:focus-visible { outline: 3px solid var(--ice); outline-offset: 3px; }

/* Messages inside a card */
.portal-note { margin: 0 0 18px; padding: 12px 14px; border-radius: 12px; font-size: .84rem; line-height: 1.5; }
.portal-note.is-success { background: var(--green-dim); color: #166534; }
.portal-note.is-error   { background: var(--red-dim);   color: #991B1B; }
.portal-note.is-info    { background: #E8EFFB;          color: var(--navy); }

/* Divider paragraph at the foot of a card */
.portal-alt { margin: 20px 0 0; padding-top: 18px; border-top: 1px solid #E6ECF5; font-size: .8rem; line-height: 1.5; color: var(--muted); text-align: center; }
.portal-alt a { color: var(--navy); font-weight: 600; }

/* Status chip (invoice status) on a light surface */
.portal-chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 100px; font-size: .72rem; font-weight: 600; text-transform: capitalize; background: var(--gray-dim); color: var(--muted); }
.portal-chip.is-paid { background: var(--green-dim); color: var(--green); }
.portal-chip.is-open { background: var(--blue-dim); color: var(--blue); }
.portal-chip.is-void, .portal-chip.is-uncollectible { background: var(--red-dim); color: var(--red); }
.portal-chip.is-refunded { background: var(--purple-dim); color: var(--purple); }

.portal-mono { font-family: 'Geist Mono', monospace; }

/* ── Layouts ────────────────────────────────────────────────────────── */

/* Headline on the left, card on the right (logins). Stacks on phones. */
.portal-split {
  position: relative; z-index: 1;
  max-width: 1120px; min-height: 100vh; margin: 0 auto; padding: 36px 32px 28px;
  display: grid; gap: 0 72px;
  grid-template-columns: 1fr 420px;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "logo   logo"
    "intro  card"
    "footer footer";
  align-items: center;
}
.portal-split > .portal-logo { grid-area: logo; align-self: start; justify-self: start; }
.portal-split-intro { grid-area: intro; }
.portal-split-card { grid-area: card; }
.portal-split > .portal-footer { grid-area: footer; padding-top: 28px; }
.portal-under { margin: 18px 0 0; text-align: center; font-size: .84rem; color: rgba(255,255,255,.65); }

/* Inner pages: logo bar on top, content below */
.portal-page { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 36px 32px 28px; min-height: 100vh; display: flex; flex-direction: column; }
.portal-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 44px; }
.portal-bar-action { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 100px; border: 1px solid rgba(255,255,255,.22); background: rgba(255,255,255,.06); color: rgba(255,255,255,.85); font: 600 .8rem 'Geist', sans-serif; text-decoration: none; cursor: pointer; transition: background-color .15s, color .15s; }
.portal-bar-action:hover { background: rgba(255,255,255,.14); color: #fff; }
.portal-bar-action:focus-visible { outline: 3px solid var(--ice); outline-offset: 3px; }
.portal-page > .portal-footer { margin-top: auto; padding-top: 40px; }

@media (max-width: 920px) {
  .portal-split {
    grid-template-columns: 1fr; gap: 0;
    grid-template-areas: "logo" "intro" "card" "footer";
    grid-template-rows: none;
    max-width: 520px; padding: 22px 16px 24px;
  }
  .portal-split-intro { padding-top: 36px; }
  .portal-split-card { padding-top: 28px; }
  .portal-split > .portal-footer { text-align: center; }
  .portal-title { font-size: 2.2rem; }
  .portal-lede { font-size: .95rem; }
  .portal-page { padding: 22px 16px 24px; }
  .portal-bar { margin-bottom: 32px; }
  .portal-page > .portal-footer { text-align: center; }
}
@media (max-width: 480px) {
  .portal-bar .portal-logo .brand-name { white-space: nowrap; }
}
@media (max-width: 400px) {
  .portal-card { padding: 0 18px 22px; }
  .portal-card.is-plain { padding-top: 22px; }
  .portal-card .portal-stub { --card-pad: 18px; margin-bottom: 20px; padding-top: 16px; padding-bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  body.portal::before { animation: none; }
  .portal-btn, .portal-stub::after { transition: none; }
  .portal-stub.is-pending::after { animation: none; background: rgba(169,196,245,.6); }
  .portal-btn.is-busy::before { animation-duration: 2s; }
}
