/* portal.css — StarFyre Account portal. Builds on shared.css tokens. No inline styles are used anywhere on the
   page so the Content-Security-Policy in _headers can forbid them. */
body { background: var(--brand-dark-base); color: var(--text-white); font-family: 'Inter', system-ui, sans-serif; min-height: 100vh; display: flex; flex-direction: column; line-height: 1.5; }
a { color: var(--brand-blue); }
a:hover { text-decoration: none; }
[hidden] { display: none !important; }

.site-header { padding: 22px 32px; border-bottom: 1px solid rgba(255,255,255,0.06); background: var(--brand-dark-surface); display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-mark { display: inline-flex; align-items: center; min-height: 44px; font-weight: 700; font-size: 1.4rem; letter-spacing: -0.02em; text-decoration: none; background: linear-gradient(135deg, var(--brand-blue), var(--brand-purple), var(--brand-pink)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.site-header nav { display: flex; gap: 20px; font-size: 0.95rem; }
.site-header nav a { color: var(--text-muted); text-decoration: none; padding: 8px 6px; min-height: 44px; display: inline-flex; align-items: center; }
.site-header nav a:hover { color: #fff; }

main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 40px 16px 64px; position: relative; display: flex; flex-direction: column; gap: 20px; }
main:focus { outline: none; }
/* WCAG AAA contrast (7:1) for white text on the brand gradient. The shared gradient (#C00FD1 to #FF00FF) is only
   3.1:1 against white, so this page uses deeper stops from the same purple/magenta family. Checked with the
   contrast probe in the account repo (test/e2e/contrast-probe.js): worst case over both stops is 8.4:1. */
main { --premium-from: #4b00b3; --premium-to: #85089a; --premium-glow: rgba(75, 0, 179, 0.45); --premium-glow-hover: rgba(133, 8, 154, 0.55); }
main .btn-premium { filter: none; }
main .btn-premium:hover { filter: none; }
main .btn-premium::after { display: none; }
.bg-glow { position: fixed; width: 640px; height: 640px; background: radial-gradient(circle, rgba(112,0,255,0.16) 0%, rgba(0,0,0,0) 70%); top: 40%; left: 50%; transform: translate(-50%, -50%); z-index: -1; pointer-events: none; }

.card { padding: 32px; }
.card h1 { font-size: clamp(1.6rem, 4.5vw, 2.1rem); margin-bottom: 8px; line-height: 1.15; }
.card h2 { font-size: 1.25rem; margin-bottom: 14px; }
.card h1:focus, .card h2:focus { outline: none; }
.lede { color: var(--text-muted); margin-bottom: 24px; }
.muted { color: var(--text-muted); }
.fineprint { color: var(--text-muted); font-size: 0.85rem; margin-top: 12px; }
.mono { font-family: 'Nova Mono', ui-monospace, monospace; }

/* Banners & live status */
.banner { padding: 14px 16px; border-radius: 10px; border: 1px solid var(--portal-border); background: var(--brand-dark-elevated); font-size: 0.95rem; }
.banner.error { border-color: var(--portal-danger); }
.banner.success { border-color: var(--portal-success); }
.banner.info { border-color: var(--brand-blue); }

/* OAuth buttons */
.oauth { display: grid; gap: 12px; }
.btn-oauth { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 48px; padding: 12px 18px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.25); background: #fff; color: #1f1f1f; font-weight: 600; font-size: 1rem; text-decoration: none; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.btn-oauth:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.35); }
.btn-oauth.github { background: #24292f; color: #fff; border-color: rgba(255,255,255,0.2); }
.btn-oauth svg { width: 20px; height: 20px; flex: none; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-muted); font-size: 0.85rem; margin: 24px 0 16px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--portal-border); }

/* Tabs */
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: rgba(0,0,0,0.3); border-radius: 10px; margin-bottom: 20px; }
.tab { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--brand-dark-elevated); color: #fff; box-shadow: inset 0 0 0 1px var(--portal-border); }
.tabs.tabs-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 0; }
.tabs.tabs-4 { grid-template-columns: repeat(4, 1fr); margin-bottom: 0; }
@media (max-width: 520px) { .tabs.tabs-4 { grid-template-columns: 1fr 1fr; } }

/* Header buttons from the shared stylesheet are 36px tall: AAA wants 44px. */
.btn.small, .btn-small { min-height: 44px; }
/* Forms */
/* The shared stylesheet removes the outline on focused fields and leaves only a faint glow. Keep a real 2px ring (WCAG 2.4.13). */
.portal-input:focus-visible, select.portal-input:focus-visible { outline: 2px solid var(--focus-ring, #00d2ff); outline-offset: 3px; }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 6px; }
.field .portal-input { margin-bottom: 0; min-height: 48px; }
.field .hint { font-size: 0.82rem; color: var(--text-muted); margin-top: 6px; }
.pw-wrap { display: flex; gap: 8px; }
.pw-wrap .portal-input { flex: 1; min-width: 0; }
.pw-toggle { min-width: 72px; min-height: 48px; border-radius: 8px; border: 1px solid var(--portal-border); background: transparent; color: var(--text-white); font: inherit; font-size: 0.85rem; cursor: pointer; }
.check { display: flex; gap: 12px; align-items: flex-start; min-height: 44px; margin: 4px 0 18px; font-size: 0.92rem; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--brand-purple); }
.btn[disabled], .btn-premium[disabled] { opacity: .6; cursor: progress; transform: none; }
.submit { width: 100%; min-height: 48px; }
.btn-premium.submit { padding: 14px 24px; font-size: 1rem; }
.link-btn { background: none; border: 0; min-height: 44px; padding: 10px 6px; color: var(--brand-blue); font: inherit; font-size: 0.9rem; cursor: pointer; text-decoration: underline; }
.link-row { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px 20px; }
.link-row a { display: inline-flex; align-items: center; min-height: 44px; }

/* Account */
.account-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1.3rem; background: linear-gradient(135deg, var(--premium-from), var(--premium-to)); flex: none; }
.account-head .who { flex: 1; min-width: 180px; }
.account-head h1 { margin-bottom: 2px; }
.email { word-break: break-all; color: var(--text-muted); }
.badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 700; letter-spacing: .03em; border: 1px solid var(--portal-border); background: rgba(255,255,255,0.06); }
.badge.admin { border-color: var(--brand-pink); color: #ffd0ff; background: rgba(255,0,255,0.12); }
.badge.ok { border-color: var(--portal-success); color: #b9ffd9; background: rgba(0,230,118,0.1); }
.signed-in-note { margin-top: 18px; }

.license { border: 1px solid var(--portal-border); border-radius: 12px; padding: 16px; background: rgba(0,0,0,0.25); margin-top: 14px; }
.license-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.license-key { font-size: 1.05rem; letter-spacing: 0.04em; word-break: break-all; }
.license-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-mini { min-height: 44px; padding: 6px 14px; border-radius: 8px; border: 1px solid var(--portal-border); background: transparent; color: var(--text-white); font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.btn-mini.danger { border-color: var(--portal-danger); color: #ffb3b3; }
.btn-mini:hover { background: rgba(255,255,255,0.08); }
.devices { list-style: none; margin-top: 12px; display: grid; gap: 8px; }
.devices li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 0.9rem; }
.empty { text-align: center; padding: 20px 8px; color: var(--text-muted); }

/* Downloads tab */
.dl-card { border: 1px solid var(--portal-border); border-radius: 12px; padding: 18px; background: rgba(0,0,0,0.25); margin-top: 14px; }
.card .dl-top { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 6px; }
.dl-top h3 { font-size: 1.1rem; }
.dl-files { list-style: none; display: grid; gap: 10px; margin-top: 12px; }
.dl-files li { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.dl-info { flex: 1; min-width: 200px; }
.dl-open { margin-top: 12px; }
.dl-btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 10px 22px; }
.dl-verify { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }
.dl-verify summary { cursor: pointer; padding: 13px 0; }
.dl-verify code { display: block; word-break: break-all; margin-top: 4px; }

/* AI & StarFuel tab */
.ai-section { display: grid; gap: 28px; margin-top: 8px; }
.ai-section h3 { font-size: 1.1rem; margin-bottom: 8px; }
.ai-section h4 { font-size: 1rem; margin: 18px 0 6px; }
.fuel-balance { font-size: 1.1rem; margin-bottom: 10px; }
.fuel-balance strong { font-size: 2rem; letter-spacing: -0.02em; }
.fuel-history summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.ledger { list-style: none; display: grid; gap: 6px; margin: 10px 0; }
.ledger li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,0.04); font-size: 0.9rem; }
.ledger .amt { font-weight: 700; white-space: nowrap; }
.keys, .routes { list-style: none; display: grid; gap: 12px; margin-top: 10px; }
.keys > li, .routes > li { border: 1px solid var(--portal-border); border-radius: 12px; padding: 16px; background: rgba(0,0,0,0.25); }
.key-head { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 10px; }
.key-head h4 { margin: 0; }
.key-form .pw-wrap { margin-bottom: 10px; }
.key-actions .confirm-text { flex-basis: 100%; }
.key-actions, .route-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
select.portal-input { appearance: auto; }
.route-row { display: grid; gap: 10px; }
.route-row .check { margin: 0; }
.route-add { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--portal-border); }

details.danger-zone { border: 1px solid rgba(255,77,77,0.45); border-radius: 12px; padding: 14px 16px; margin-top: 16px; }
details.danger-zone summary { cursor: pointer; font-weight: 600; padding: 10px 0; }
.danger-zone .field { margin-top: 14px; }
.btn-danger { background: var(--portal-danger); color: #1a0000; font-weight: 700; border: 0; border-radius: 10px; min-height: 46px; padding: 10px 20px; cursor: pointer; font: inherit; font-weight: 700; }
.btn-danger[disabled] { opacity: .5; cursor: not-allowed; }

.subhead { font-size: 1.05rem; margin: 26px 0 10px; }
.session-form .field { max-width: 360px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.spinner-row { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 40px 0; color: var(--text-muted); }

.site-footer { padding: 24px 16px 32px; text-align: center; color: var(--text-muted); font-size: 0.85rem; }
.site-footer a { color: var(--text-muted); margin: 0 4px; display: inline-block; padding: 12px 8px; }

@media (max-width: 520px) { .card { padding: 22px 18px; } .site-header { padding: 16px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .tab[aria-selected="true"] { outline: 2px solid Highlight; } }
