/* ==========================================================================
   LOCAL FONT DEFINITION (JetBrains Mono from assets)
   ========================================================================== */
@font-face {
  font-family: 'JetBrains Mono';
  src: url('assets/JetBrainsMono-VariableFont_wght.ttf') format('truetype-variations'),
       url('assets/JetBrainsMono-VariableFont_wght.ttf') format('truetype');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   DESIGN TOKENS & SYSTEM VARIABLES
   ========================================================================== */
:root {
  /* Subtle Teal Accent */
  --ds-teal-500: #009688;
  --ds-teal-400: #26a69a;
  --ds-teal-subtle: rgba(0, 150, 136, 0.1);
  --ds-teal-border: rgba(0, 150, 136, 0.35);

  /* Status Colors */
  --status-up: #009688;
  --status-up-subtle: rgba(0, 150, 136, 0.12);
  --status-up-border: rgba(0, 150, 136, 0.35);
  
  --status-degraded: #d29922;
  --status-degraded-subtle: rgba(210, 153, 34, 0.12);
  --status-degraded-border: rgba(210, 153, 34, 0.35);

  --status-down: #f85149;
  --status-down-subtle: rgba(248, 81, 73, 0.12);
  --status-down-border: rgba(248, 81, 73, 0.35);

  /* Clean Dark Theme Palette */
  --bg-color: #0b0e14;
  --card-bg: rgba(255, 255, 255, 0.015);
  --card-bg-hover: rgba(255, 255, 255, 0.03);
  --text-primary: #ededed;
  --text-secondary: #9aa4b2;
  --text-muted: #555e6d;
  --border-color: #21262d;
  --border-hover: #30363d;

  /* Typography */
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* ==========================================================================
   RESET & BASE STYLES
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  overflow-x: hidden;
}

::selection {
  background-color: var(--ds-teal-500);
  color: #ffffff;
}

/* ==========================================================================
   LAYOUT STRUCTURE (Centered & Responsive)
   ========================================================================== */
.site-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem clamp(1rem, 4vw, 2.5rem);
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  box-sizing: border-box;
  position: relative;
}

.site-wrapper.status-wrapper {
  padding-top: 1.5rem;
  padding-bottom: 5rem;
}

.status-frame {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 680px;
  width: 100%;
  margin: 0 auto;
}

/* Subpages (Privacy, 404, etc.) */
.site-wrapper.privacy-wrapper,
.site-wrapper.subpage-wrapper,
.site-wrapper:has(.privacy-page-frame),
.site-wrapper:has(.subpage-frame) {
  justify-content: center;
  padding: 3rem clamp(1.25rem, 5vw, 2.5rem);
}

.privacy-page-frame,
.subpage-frame {
  max-width: 480px;
  gap: 1.5rem;
  width: 100%;
}

/* ==========================================================================
   TOP HEADER / NAVIGATION (Minimal: Title + Link to Main Site)
   ========================================================================== */
.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.nav-title {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--ds-teal-500);
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.action-btn:hover,
.action-btn:focus-visible {
  border-color: var(--ds-teal-500);
  background: var(--ds-teal-subtle);
  color: #ffffff;
  outline: none;
}

/* ==========================================================================
   GLOBAL STATUS HERO BANNER
   ========================================================================== */
.status-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.25rem;
  background: rgba(0, 150, 136, 0.05);
  border: 1px solid var(--ds-teal-border);
  border-radius: 6px;
  gap: 1rem;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.status-hero.is-degraded {
  background: var(--status-degraded-subtle);
  border-color: var(--status-degraded-border);
}

.status-hero.is-down {
  background: var(--status-down-subtle);
  border-color: var(--status-down-border);
}

.status-hero-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-pulse-dot {
  width: 10px;
  height: 10px;
  background-color: var(--ds-teal-500);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(0, 150, 136, 0.6);
  animation: pulse-glow 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
  flex-shrink: 0;
}

@keyframes pulse-glow {
  0% {
    box-shadow: 0 0 0 0 rgba(0, 150, 136, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(0, 150, 136, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(0, 150, 136, 0);
  }
}

.status-hero-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.3;
}

.status-hero-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ==========================================================================
   SERVICES & 90-DAY UPTIME BARS (Clean GitHub Status Style)
   ========================================================================== */
.services-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  width: 100%;
}

#services-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.25rem;
}

.section-title {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.service-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.service-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.service-name {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
}

.service-uptime-pct {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* 90-Day Uptime Bars Container */
.uptime-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.uptime-bars {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  height: 28px;
  padding: 2px 0;
}

.uptime-bar {
  flex: 1;
  min-width: 2px;
  height: 100%;
  border-radius: 2px;
  cursor: pointer;
}

.uptime-bar.is-operational {
  background-color: var(--ds-teal-500);
}

.uptime-bar.is-degraded {
  background-color: var(--status-degraded);
}

.uptime-bar.is-down {
  background-color: var(--status-down);
}

.uptime-bar.is-empty {
  background-color: #161b22;
  cursor: default;
}

/* Timeline Legend */
.uptime-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==========================================================================
   METRICS & RESPONSE TIME
   ========================================================================== */
.metrics-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.metrics-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.metrics-title {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-primary);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.25rem;
}

.metric-item {
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.metric-label {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ds-teal-500);
}

.metrics-notice {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ==========================================================================
   INCIDENT HISTORY (Hidden when 0 incidents)
   ========================================================================== */
.incidents-card {
  display: none; /* hidden when empty */
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1.15rem 1.25rem;
  flex-direction: column;
  gap: 1rem;
}

.incidents-card.has-incidents {
  display: flex;
}

.incident-day {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.incident-day:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.incident-date {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
}

/* ==========================================================================
   TOOLTIPS
   ========================================================================== */
.custom-tooltip {
  position: absolute;
  background: #141922;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 0.45rem 0.65rem;
  font-size: 0.72rem;
  color: var(--text-primary);
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translate(-50%, -100%);
  margin-top: -8px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.custom-tooltip.visible {
  opacity: 1;
}

/* ==========================================================================
   PRIVACY PAGE & SUBPAGES
   ========================================================================== */
.privacy-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.publ-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.header-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  line-height: 1.2;
}

.btn-exit {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-exit-icon {
  font-size: 0.85rem;
}

.btn-exit:hover,
.btn-exit:focus-visible {
  border-color: var(--ds-teal-500);
  color: var(--ds-teal-500);
  background: var(--ds-teal-subtle);
  outline: none;
}

.privacy-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.privacy-body p {
  font-size: 0.8rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

.privacy-body strong {
  color: var(--text-primary);
  font-weight: 500;
}

.privacy-links-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.text-link {
  color: var(--ds-teal-500);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 0.78rem;
  transition: color 0.15s ease;
}

.text-link:hover {
  color: #ffffff;
}

/* ==========================================================================
   CORNER PRIVACY LINK
   ========================================================================== */
.corner-privacy {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom, 1.5rem));
  right: max(1.75rem, env(safe-area-inset-right, 1.75rem));
  z-index: 100;
  margin: 0;
  display: flex;
}

@media (max-width: 600px) {
  .corner-privacy {
    bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem));
    right: max(1.25rem, env(safe-area-inset-right, 1.25rem));
  }
}

.privacy-link {
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-decoration-color: var(--border-color);
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

.privacy-link:hover,
.privacy-link:focus-visible {
  color: var(--ds-teal-500);
  text-decoration-color: var(--ds-teal-500);
  outline: none;
}

/* ==========================================================================
   MOBILE & RESPONSIVE REFINEMENTS
   ========================================================================== */
@media (max-width: 600px) {
  .status-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .uptime-bars {
    gap: 1.5px;
    height: 24px;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }
}
