/* Demos Network Faucet — visual identity adopted from scan.demos.network
   Tokens mirror the explorer's design system: near-black bg ladder, emerald
   accent, white primary text, Inter + Fira Code, 1px hairline borders, small
   radii. ponytail: flat surfaces over the old glassmorphism, no 3D tilt/glow. */

@font-face {
  font-family: 'Inter';
  font-weight: 100 900;
  font-style: normal;
  src: url('/styles/fonts/Inter/Inter-VariableFont_slnt,wght.ttf') format('truetype-variations');
  font-display: swap;
}

/* ponytail: mono uses the system stack (SF Mono/Menlo/Monaco) like scan does —
   no extra font file to bundle. Add a Fira Code @font-face here if you want the
   exact webfont and drop the .ttf in /styles/fonts/. */

:root {
  /* Background ladder — straight from scan.demos.network */
  --color-bg-primary: #08080a;
  --color-bg-secondary: #0e0e11;
  --color-bg-tertiary: #16161a;
  --color-bg-hover: #1d1d22;

  /* Borders — hairline whites */
  --color-border: #ffffff17;
  --color-border-subtle: #ffffff0e;
  --color-border-strong: #ffffff26;

  /* Text */
  --color-text-primary: #f4f4f5;
  --color-text-secondary: #b4b4bb;
  --color-text-muted: #8a8a93;
  --color-text-faint: #5c5c64;

  /* Accent — emerald is the brand signal on scan; white is the neutral accent */
  --color-success: #34d399;
  --color-success-rgb: 52, 211, 153;
  --color-success-muted: #34d39921;
  --color-warning: #fbbf24;
  --color-warning-muted: #fbbf2421;
  --color-error: #f87171;
  --color-error-rgb: 248, 113, 113;
  --color-error-muted: #f8717121;
  --color-info: #818cf8;
  --color-focus-ring: #2b36d98c;

  /* Legacy aliases kept so existing markup/JS keep working.
     main.ts sets link.style.color = var(--accent-primary). */
  --accent-primary: var(--color-success);
  --text-primary: var(--color-text-primary);
  --text-secondary: var(--color-text-secondary);
  --text-muted: var(--color-text-muted);
  --success-green: var(--color-success);
  --warning-yellow: var(--color-warning);
  --error-red: var(--color-error);
  --glass-surface: var(--color-bg-secondary);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'Fira Code', 'SF Mono', 'Fira Mono', Menlo, Monaco, monospace;

  /* Radii — small, like the explorer (6/8/12) */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows — subtle, ring-style */
  --shadow-sm: 0 1px 2px #0006;
  --shadow-md: 0 0 0 1px #ffffff0e, 0 2px 6px #0006;
  --shadow-lg: 0 0 0 1px #ffffff0e, 0 8px 24px #00000080;

  --transition-base: 150ms ease;
  --transition-fast: 100ms ease;
  --ease-out-quart: cubic-bezier(0.25, 1, 0.5, 1);
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --focus-ring: 0 0 0 3px var(--color-focus-ring);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
}

/* Old decorative layers — neutralized, not removed (JS still references nodes) */
body::before,
body::after,
.faucet-card::before,
.faucet-card::after,
.faucet-card .shine,
.button-glow,
.floating-logo {
  display: none !important;
}

#app {
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-success);
  color: #08080a;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.4rem;
  letter-spacing: 0;
}

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: clamp(2rem, 6vw, 5rem) clamp(1rem, 4vw, 2rem) clamp(2rem, 5vw, 4rem);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

/* Card — flat, hairline border, small radius, ring shadow (scan card style) */
.faucet-card {
  position: relative;
  width: 100%;
  padding: clamp(1.5rem, 4vw, 2.25rem);
  border-radius: var(--radius-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: fadeIn 0.3s var(--ease-out-quart);
}

.faucet-card > * {
  position: relative;
  z-index: 1;
}

.faucet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.demos-logo {
  width: 32px;
  height: 32px;
  filter: brightness(12);
  flex-shrink: 0;
}

.faucet-header h1 {
  font-family: var(--font-sans);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--color-text-primary);
}

/* Network badge — like the live pill on scan: emerald dot + muted text */
.network-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--color-text-secondary);
  background: var(--color-success-muted);
  border: 1px solid transparent;
}

.network-badge .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--color-success-muted);
}

/* Status panel + cards — flat tertiary surfaces */
.faucet-status,
.message-card,
.transaction-card,
.transaction-history {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.faucet-status {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.status-label {
  color: var(--color-text-muted);
  font-weight: 400;
}

.status-value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}

.status-value.connected { color: var(--color-success); }
.status-value.error { color: var(--color-error); }
.status-value.offline { color: var(--color-warning); }
.status-value.low-balance { color: var(--color-warning); font-weight: 600; }
.status-value.fetching { color: var(--color-text-muted); }

.clickable-address {
  cursor: pointer;
  color: var(--color-success);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed var(--color-success-muted);
  transition: color var(--transition-base), border-color var(--transition-base);
  border-radius: 2px;
  padding: 0 2px;
}

.clickable-address:hover {
  color: #5ee0b0;
  border-bottom-color: var(--color-success);
}

.clickable-address:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.faucet-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.faucet-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Input — scan search-field style: tertiary bg, hairline, 8px radius */
.input-group {
  position: relative;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
}

.input-group .input-label {
  position: absolute;
  top: -0.5rem;
  left: 0.7rem;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  background: var(--color-bg-secondary);
  padding: 0 0.35rem;
  border-radius: 2px;
}

.input-group:focus-within {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-muted);
  background: var(--color-bg-hover);
}

.input-group input {
  width: 100%;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  font-size: 16px; /* >=16px prevents iOS auto-zoom */
  font-family: var(--font-mono);
}

.input-group input::placeholder {
  color: var(--color-text-faint);
  font-family: var(--font-sans);
}

.input-group input:focus { outline: none; }

.input-group.valid {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-muted);
}

.input-group.invalid {
  border-color: var(--color-error);
  box-shadow: 0 0 0 3px var(--color-error-muted);
  animation: inputShake 0.4s var(--ease-out-quart);
}

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.amount-display {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
}

.amount-display .label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.amount-display .amount {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-success);
  font-variant-numeric: tabular-nums;
}

.amount-display .amount-note {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

/* Button — solid emerald, flat. No gradient/glow. */
.request-button {
  position: relative;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font-sans);
  letter-spacing: 0;
  color: #08080a;
  background: var(--color-success);
  cursor: pointer;
  transition: background var(--transition-base), opacity var(--transition-base), transform var(--transition-fast);
  min-height: 48px;
}

.request-button:hover:not(:disabled) {
  background: #5ee0b0;
}

.request-button:active:not(:disabled) {
  transform: scale(0.99);
}

.request-button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.request-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.request-button .button-text {
  position: relative;
  z-index: 2;
  color: #08080a;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.request-button.loading { pointer-events: none; }

.request-button.success {
  background: var(--color-success);
}

.button-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(8, 8, 10, 0.25);
  transform: scale(0);
  animation: ripple 0.6s var(--ease-out-quart);
  pointer-events: none;
  z-index: 3;
}

@keyframes ripple {
  to { transform: scale(4); opacity: 0; }
}

.spinner {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  border: 2px solid rgba(8, 8, 10, 0.35);
  border-top-color: rgba(8, 8, 10, 0.9);
  border-radius: 50%;
  margin-right: 0.4rem;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.request-button.loading .button-text { color: rgba(8, 8, 10, 0.7); }

.message-container.hidden,
.transaction-info.hidden { display: none; }

.message-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color var(--transition-base);
}

.message-card h3,
.transaction-card h3,
.transaction-history h3 {
  font-family: var(--font-sans);
  letter-spacing: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.message-card.error {
  border-color: var(--color-error);
  background: var(--color-error-muted);
  animation: messageEnter 0.3s var(--ease-out-quart);
}

.message-card.error h3 { color: var(--color-error); }
.message-card.error .message-content { color: #fca5a5; }

.message-card.success {
  border-color: var(--color-success);
  background: var(--color-success-muted);
  animation: messageEnter 0.3s var(--ease-out-quart);
}

.message-card.success h3 { color: var(--color-success); }
.message-card.success .message-content { color: #6ee7b7; }

@keyframes messageEnter {
  0% { opacity: 0; transform: translateY(-6px); }
  100% { opacity: 1; transform: translateY(0); }
}

.message-content {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  line-height: 1.6;
}

.transaction-details {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
}

.detail-row .label {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  letter-spacing: 0;
  flex-shrink: 0;
}

.detail-row .value {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text-primary);
  word-break: break-all;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-row .value a {
  color: var(--color-success);
  text-decoration: none;
  transition: color var(--transition-base);
}

.detail-row .value a:hover {
  color: #5ee0b0;
  text-decoration: underline;
}

.detail-row .value a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 2px;
}

.transaction-history {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-subtle);
  animation: floatIn 300ms ease both;
}

.history-address {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--color-text-primary);
}

.history-amount {
  font-family: var(--font-mono);
  color: var(--color-success);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Footer — scan style: muted links, separator dot */
.footer {
  width: 100%;
}

.footer-content {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  text-align: center;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.footer-links a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-base);
  border-radius: 2px;
  padding: 2px 4px;
}

.footer-links a:hover { color: var(--color-text-secondary); }

.footer-links a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  color: var(--color-text-secondary);
}

.footer-links .separator { opacity: 0.4; }

.footer-branding {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text-faint);
  font-size: 0.75rem;
}

.footer-logo {
  width: 18px;
  filter: brightness(10);
  opacity: 0.5;
}

.hidden { display: none !important; }

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.faucet-status { animation: fadeIn 0.4s var(--ease-out-quart) 0.05s both; }
.faucet-form { animation: fadeIn 0.4s var(--ease-out-quart) 0.1s both; }
.status-value.fetching { animation: pulse 1.5s ease-in-out infinite; }
.message-container:not(.hidden) { animation: floatIn 0.25s var(--ease-out-quart); }
.transaction-info:not(.hidden) { animation: floatIn 0.25s var(--ease-out-quart); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 640px) {
  .container {
    padding: 1.5rem 1rem 2rem;
  }

  .faucet-card {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }

  .faucet-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .network-badge { align-self: flex-start; }

  .status-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .status-value { word-break: break-all; }

  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .detail-row .value { text-align: left; }

  .footer-links {
    flex-direction: column;
    gap: 0.5rem;
  }

  .footer-links .separator { display: none; }
}

@media print {
  body { background: white; color: black; }
  .faucet-card { background: white; border: 1px solid #ccc; box-shadow: none; }
  .request-button, .faucet-form, .footer { display: none; }
  a { color: black; text-decoration: underline; }
}
