/* ==========================================================================
   CiteMetrix PWA — refined dark instrument aesthetic
   Brand consistency with email template (#0a1015 dark, #10E07C accent)
   Type system: JetBrains Mono for numbers, Geist for prose
   ========================================================================== */

@font-face {
  font-family: 'Geist';
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/geist@5.0.4/files/geist-latin-400-normal.woff2') format('woff2');
}

@font-face {
  font-family: 'JetBrains Mono';
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/jetbrains-mono@5.0.18/files/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}

:root {
  --bg: #0a1015;
  --bg-card: #11181f;
  --bg-elev: #161e26;
  --border: #1f2933;
  --text: #e8edf2;
  --text-dim: #8593a3;
  --text-muted: #5e6b7c;
  --accent: #10E07C;
  --accent-dim: rgba(16, 224, 124, 0.18);
  --accent-line: rgba(16, 224, 124, 0.32);
  --warn: #ff6b5b;
  --warn-dim: rgba(255, 107, 91, 0.16);
  --info: #5b9aff;

  --font-display: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --safe-top: env(safe-area-inset-top);
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button { font-family: inherit; }

/* --------------------------------------------------------------------------
   Boot screen — first paint before JS runs
   -------------------------------------------------------------------------- */
.boot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  animation: fade-out 200ms ease 600ms forwards;
}
.boot-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.4px;
  opacity: 0;
  animation: fade-in 400ms ease 100ms forwards;
}
@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; visibility: hidden; } }

/* --------------------------------------------------------------------------
   Brand mark (used in login + header)
   -------------------------------------------------------------------------- */
.brand {
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.4px;
}
.brand-accent { color: var(--accent); }
.brand-sub {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

/* --------------------------------------------------------------------------
   Login screen
   -------------------------------------------------------------------------- */
.login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
  animation: rise 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.form {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.field input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color 120ms ease;
}
.field input:focus {
  border-color: var(--accent-line);
}
.btn-primary {
  margin-top: 10px;
  background: var(--accent);
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 15px;
  padding: 14px;
  cursor: pointer;
  transition: opacity 120ms ease;
  letter-spacing: 0.2px;
}
.btn-primary:active { opacity: 0.8; }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.form-error {
  background: var(--warn-dim);
  border-left: 2px solid var(--warn);
  color: var(--warn);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 4px;
}
.login-foot {
  margin-top: 28px;
  font-size: 12px;
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.hdr {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hdr-row--meta {
  margin-top: 10px;
}
.hdr-brand {
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.3px;
}
.hdr-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.live-dot {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}
.domain-switcher {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  max-width: 200px;
}
.domain-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.domain-caret {
  color: var(--text-dim);
  font-size: 10px;
}
.hdr-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.4px;
}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.cards {
  flex: 1;
  padding: 12px 12px 80px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 18px;
  animation: rise 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.card[data-card="modelscore"] { animation-delay: 80ms; }
.card[data-card="citation"]   { animation-delay: 140ms; }
.card[data-card="alerts"]     { animation-delay: 200ms; }

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

.card-label {
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-head .card-label { margin: 0; }
.card-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

/* --- ModelScore hero card --- */
.card--hero {
  padding: 22px 18px 16px;
}
.hero-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-bottom: 6px;
}
.hero-num {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -2px;
}
.hero-unit {
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--text-muted);
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

/* --- Delta indicator (used across cards) --- */
.delta {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
}
.delta--up   { color: var(--accent); }
.delta--down { color: var(--warn); }
.delta--flat { color: var(--text-muted); }
.delta-window {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- Sparkline (inline SVG) --- */
.spark {
  height: 36px;
  margin-top: 6px;
}
.spark svg { width: 100%; height: 100%; display: block; }
.spark-fill { fill: var(--accent-dim); }
.spark-line { stroke: var(--accent); stroke-width: 1.5; fill: none; }

/* --- Citation rate card --- */
.metric-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  margin-bottom: 6px;
}
.metric-value {
  font-family: var(--font-mono);
  font-size: 36px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -1px;
}
.metric-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}
.metric-detail {
  font-size: 12px;
  color: var(--text-dim);
}

/* --- Alerts list --- */
.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
}
.alert-item {
  background: var(--bg-card);
  padding: 12px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.alert-icon {
  width: 6px;
  align-self: stretch;
  border-radius: 2px;
  flex-shrink: 0;
}
.alert-icon--critical { background: var(--warn); }
.alert-icon--warn     { background: #f5a524; }
.alert-icon--info     { background: var(--info); }
.alert-icon--success  { background: var(--accent); }
.alert-body { flex: 1; min-width: 0; }
.alert-title {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 2px;
}
.alert-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.3px;
}
.alert-unread .alert-title::after {
  content: '';
  display: inline-block;
  margin-left: 8px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
}
.alerts-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-card);
}

/* --- Logout button --- */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 4px;
  padding: 12px;
  font-size: 13px;
  cursor: pointer;
  margin-top: 8px;
  font-family: inherit;
}
.btn-ghost:active { background: var(--bg-card); }

/* --- Notification banner (shown when push is supported but not subscribed) --- */
.notif-banner {
  background: linear-gradient(135deg, rgba(16, 224, 124, 0.12), rgba(16, 224, 124, 0.04));
  border: 1px solid var(--accent-line);
  border-radius: 4px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: rise 480ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  animation-delay: 260ms;
}
.notif-banner[hidden] {
  display: none;
}
.notif-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.notif-icon svg {
  width: 18px;
  height: 18px;
}
.notif-body {
  flex: 1;
  min-width: 0;
}
.notif-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}
.notif-sub {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}
.btn-primary--sm {
  margin-top: 0;
  padding: 8px 14px;
  font-size: 12px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Domain sheet (bottom sheet for switching domains)
   -------------------------------------------------------------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 21, 0.7);
  display: flex;
  align-items: flex-end;
  z-index: 50;
  animation: fade-in 180ms ease;
}
.sheet {
  background: var(--bg-card);
  border-radius: 12px 12px 0 0;
  width: 100%;
  max-height: 70vh;
  padding: 8px 0 calc(16px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  animation: sheet-up 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  border: 1px solid var(--border);
  border-bottom: none;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--text-muted);
  border-radius: 2px;
  margin: 8px auto 12px;
  opacity: 0.4;
}
.sheet-title {
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 18px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-list {
  overflow-y: auto;
}
.sheet-item {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.sheet-item:last-child { border-bottom: none; }
.sheet-item--active {
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
}
.sheet-item-name {
  font-size: 14px;
}
.sheet-item-check {
  color: var(--accent);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Error screen
   -------------------------------------------------------------------------- */
.error-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px;
  text-align: center;
}
.error-mark {
  font-size: 36px;
  color: var(--warn);
}
.error-msg {
  color: var(--text-dim);
  font-size: 14px;
  max-width: 320px;
}
