/* ===== Apex Dark Theme — Vector Faucet ===== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Source+Sans+3:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  /* Surfaces */
  --surface-0: #111714;
  --surface-1: #151d19;
  --surface-2: #1a2320;
  --surface-3: #222d28;
  --surface-4: #2a3631;

  /* Border */
  --border: #263330;

  /* Brand */
  --red: #F25041;
  --orange: #F27B50;
  --teal: #0d9e8f;
  --green: #1ED926;
  --warm: #F5841F;

  /* Text */
  --text: #e8ece9;
  --text-secondary: #c8d0ca;
  --text-muted: #b0bab3;
  --text-dim: #8a9a8f;
  --heading: #f5f7f5;
  --heading-top: #ffffff;

  /* Derived */
  --btn-gradient: linear-gradient(135deg, #F25041 0%, #F27B50 100%);
  --btn-shadow: 0 4px 20px rgba(242, 80, 65, 0.25);
  --btn-shadow-hover: 0 8px 30px rgba(242, 80, 65, 0.35);
  --btn-secondary-bg: rgba(255, 255, 255, 0.05);
  --btn-secondary-hover: rgba(255, 255, 255, 0.08);
  --hero-bg: linear-gradient(135deg, #081f1a 0%, #111714 40%, #1a120e 100%);
  --hero-border: rgba(13, 158, 143, 0.15);
  --hero-glow-1: rgba(242, 80, 65, 0.07);
  --hero-glow-2: rgba(13, 158, 143, 0.12);
  --card-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.4);
  --code-inline: #f0c674;
  --row-hover: rgba(13, 158, 143, 0.04);

  /* Fonts */
  --font-display: "Outfit", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Fira Code", monospace;

  /* Layout */
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.2s ease;
}

/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--surface-0);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.7;
  letter-spacing: 0.01em;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== Header ===== */
header {
  background: linear-gradient(180deg, #052e25 0%, #0a1f1a 60%, #111714 100%);
  border-bottom: 1px solid var(--hero-border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--btn-gradient);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 2px 12px rgba(242, 80, 65, 0.2);
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  color: var(--heading);
  white-space: nowrap;
  letter-spacing: -0.01em;
}

nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.nav-btn:hover {
  color: var(--orange);
  background: rgba(242, 123, 80, 0.06);
}

.nav-btn.active {
  color: var(--orange);
  background: rgba(242, 123, 80, 0.1);
  border-color: rgba(242, 123, 80, 0.25);
}

.nav-btn-logout {
  color: var(--text-dim);
  border-left: 1px solid var(--border);
  margin-left: 4px;
  padding-left: 16px;
}

.nav-btn-logout:hover {
  color: var(--red);
  background: rgba(242, 80, 65, 0.08);
}

/* Auth-gated nav: hidden by default, shown via JS */
.nav-btn[data-auth] {
  display: none;
}

.nav-btn[data-auth].auth-visible {
  display: inline-block;
}

/* ===== Main ===== */
main {
  flex: 1;
  max-width: 580px;
  width: 100%;
  margin: 48px auto;
  padding: 0 24px;
}

/* ===== Hero Section (landing) ===== */
.hero {
  background: var(--hero-bg);
  border: 1px solid var(--hero-border);
  border-radius: 1rem;
  padding: 3rem 2.5rem 2.5rem;
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
  text-align: center;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}

.hero::before {
  width: 300px;
  height: 300px;
  top: -100px;
  right: -80px;
  background: radial-gradient(circle, var(--hero-glow-1) 0%, transparent 70%);
  animation: pulseGlow 6s ease-in-out infinite;
}

.hero::after {
  width: 250px;
  height: 250px;
  bottom: -80px;
  left: -60px;
  background: radial-gradient(circle, var(--hero-glow-2) 0%, transparent 70%);
  animation: pulseGlow 8s ease-in-out infinite 2s;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.035em;
  background: linear-gradient(135deg, #ffffff 0%, #F27B50 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.75rem;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease both;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.65;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease 0.1s both;
}

.hero-stats {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
  justify-content: center;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  animation: fadeInUp 0.5s ease 0.2s both;
}

.stat {
  padding: 0.7rem 1.2rem;
  background: var(--btn-secondary-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 110px;
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--heading);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: var(--font-display);
  font-weight: 500;
}

/* ===== Card ===== */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--red), var(--orange), var(--teal));
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card:hover::before {
  opacity: 1;
}

.card:hover {
  border-color: rgba(242, 123, 80, 0.3);
}

.card h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-bottom: 28px;
  line-height: 1.6;
}

/* ===== Forms ===== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input[type="email"],
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

input[type="email"]:focus,
input[type="text"]:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 123, 80, 0.1);
}

input[type="email"]::placeholder,
input[type="text"]::placeholder {
  color: var(--text-dim);
}

/* ===== Range Slider ===== */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--surface-1);
  border-radius: 3px;
  outline: none;
  margin: 12px 0 8px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--btn-gradient);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--surface-2);
  box-shadow: 0 0 0 2px var(--red);
  transition: transform var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--btn-gradient);
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid var(--surface-2);
  box-shadow: 0 0 0 2px var(--red);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-dim);
  padding: 0 2px;
  font-family: var(--font-display);
  font-weight: 500;
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s ease;
  outline: none;
  letter-spacing: 0.01em;
}

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  background: var(--btn-gradient);
  color: #fff;
  margin-top: 4px;
  box-shadow: var(--btn-shadow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--btn-shadow-hover);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-danger {
  background: linear-gradient(135deg, #D4382A 0%, #F25041 100%);
  box-shadow: 0 4px 20px rgba(212, 56, 42, 0.25);
}

.btn-danger:hover {
  box-shadow: 0 8px 30px rgba(212, 56, 42, 0.35);
}

.btn-secondary {
  width: 100%;
  padding: 12px 20px;
  background: var(--btn-secondary-bg);
  color: var(--text);
  border: 1px solid var(--border);
  margin-top: 4px;
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: var(--orange);
  color: var(--orange);
  transform: translateY(-2px);
}

.btn-copy {
  padding: 6px 14px;
  background: var(--surface-3);
  color: var(--text-muted);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.btn-copy:hover {
  background: var(--surface-4);
  color: var(--text);
  border-color: var(--orange);
}

.btn-copy.copied {
  background: rgba(30, 217, 38, 0.1);
  color: var(--green);
  border-color: rgba(30, 217, 38, 0.3);
}

/* ===== Result Box ===== */
.result-box {
  margin-top: 24px;
  padding: 20px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.result-box label {
  display: block;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.key-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.key-display code {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--code-inline);
  word-break: break-all;
  line-height: 1.5;
}

.warning {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--warm);
  font-weight: 500;
  font-family: var(--font-display);
}

/* ===== Code Block (API usage example) ===== */
.code-block {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--code-inline);
  line-height: 1.7;
  white-space: pre;
}

/* ===== API Key Regenerate Section ===== */
.apikey-regenerate {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.regen-heading {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--heading);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.explorer-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--orange);
  text-decoration: none;
  font-weight: 500;
  font-family: var(--font-display);
  transition: color var(--transition);
}

.explorer-link:hover {
  color: var(--red);
  text-decoration: underline;
}

/* ===== Messages ===== */
.msg {
  margin-top: 20px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.5;
}

.msg.msg-success {
  background: rgba(30, 217, 38, 0.08);
  border: 1px solid rgba(30, 217, 38, 0.2);
  color: var(--green);
}

.msg.msg-error {
  background: rgba(242, 80, 65, 0.08);
  border: 1px solid rgba(242, 80, 65, 0.2);
  color: var(--red);
}

.msg.msg-info {
  background: rgba(13, 158, 143, 0.08);
  border: 1px solid rgba(13, 158, 143, 0.2);
  color: var(--teal);
}

/* ===== Usage Bars ===== */
.usage-section {
  margin-bottom: 20px;
}

.usage-section:last-child {
  margin-bottom: 0;
}

.usage-section label {
  margin-bottom: 8px;
}

.usage-bar-container {
  width: 100%;
  height: 8px;
  background: var(--surface-0);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 6px;
}

.usage-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--orange));
  border-radius: 4px;
  transition: width 400ms ease;
  width: 0%;
}

.usage-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-display);
  font-weight: 500;
}

/* ===== Turnstile ===== */
#turnstile-widget {
  margin: 4px 0;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  padding: 24px;
  color: var(--text-dim);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  background: #080c09;
  font-family: var(--font-display);
  font-weight: 400;
}

footer a {
  color: var(--orange);
  text-decoration: none;
  transition: color var(--transition);
}

footer a:hover {
  color: var(--red);
}

/* ===== Loading State ===== */
.btn-primary.loading {
  position: relative;
  color: transparent;
  transform: none;
}

.btn-primary.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ===== Animations ===== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 0.8; }
}

/* ===== View entry animation ===== */
[data-view] {
  animation: fadeInUp 0.3s ease both;
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 16px;
  }

  nav {
    width: 100%;
    gap: 3px;
  }

  .nav-btn {
    font-size: 0.72rem;
    padding: 6px 10px;
  }

  main {
    margin: 24px auto;
    padding: 0 16px;
  }

  .hero {
    padding: 2rem 1.5rem;
  }

  .hero h1 {
    font-size: 1.6rem;
  }

  .hero-stats {
    gap: 0.6rem;
  }

  .card {
    padding: 1.5rem;
  }

  .card h2 {
    font-size: 1.2rem;
  }
}
