/* ── Design Tokens ── */
:root {
  --bg-page: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2129;
  --border: #21262d;
  --border-hover: #ffc451;
  --accent: #ffc451;
  --accent-glow: rgba(255, 196, 81, 0.25);
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-heading: #f0f6fc;
  --radius: 12px;
  --radius-sm: 8px;
  --gap: 16px;
  --container: 1200px;
  --header-h: 64px;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Container ── */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(13, 17, 23, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.3s, box-shadow 0.3s;
}

#header.scrolled {
  background: rgba(13, 17, 23, 0.95);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.header-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-heading);
  flex-shrink: 0;
}

.logo span {
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 8px;
}

.nav-links a {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}

.nav-links a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}

.nav-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 768px) {
  .nav-links {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    flex-direction: column;
    background: rgba(13, 17, 23, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 24px;
    gap: 4px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 99;
  }

  .nav-links.open {
    transform: translateX(0);
  }

  .nav-links a {
    font-size: 18px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
  }

  .nav-links a:hover {
    background: rgba(255, 255, 255, 0.08);
  }

  .nav-toggle {
    display: block;
  }
}

/* ── Hero ── */
#hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background: url("../img/mainBackground.jpg") center / cover no-repeat;
  text-align: center;
}

#hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
}

.hero-content {
  position: relative;
  z-index: 1;
  padding: 60px 24px;
}

.hero-content h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
}

.hero-content p {
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--text-muted);
}

/* ── Section Titles ── */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 20px;
}

.section-title i {
  font-size: 20px;
  color: var(--accent);
}

/* ── Category Sections ── */
.category {
  padding: 40px 0;
}

.category + .category {
  padding-top: 0;
}

/* ── Card Grid ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--gap);
}

/* ── Service Cards ── */
.service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 16px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
  cursor: pointer;
  animation: fadeInUp 0.5s ease both;
}

.service-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 8px 32px var(--accent-glow);
  background: var(--bg-card-hover);
}

.service-card i {
  font-size: 32px;
  color: var(--accent);
  margin-bottom: 12px;
  transition: transform 0.25s ease;
}

.service-card:hover i {
  transform: scale(1.1);
}

.card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  font-family: 'Inter', monospace;
  opacity: 0.7;
}

/* Staggered animation */
.service-card:nth-child(1) { animation-delay: 0.02s; }
.service-card:nth-child(2) { animation-delay: 0.04s; }
.service-card:nth-child(3) { animation-delay: 0.06s; }
.service-card:nth-child(4) { animation-delay: 0.08s; }
.service-card:nth-child(5) { animation-delay: 0.10s; }
.service-card:nth-child(6) { animation-delay: 0.12s; }
.service-card:nth-child(7) { animation-delay: 0.14s; }

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

/* ── Status Bar ── */
#status-bar {
  padding: 32px 0 8px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
}

.status-card:hover {
  border-color: var(--border-hover);
  box-shadow: 0 4px 16px var(--accent-glow);
}

/* Status dots */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.status-dot.loading {
  background: var(--yellow);
  box-shadow: 0 0 8px var(--yellow);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-dot.error {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: none;
}

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

.status-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.status-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.status-value {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Footer ── */
#footer {
  border-top: 1px solid var(--border);
  padding: 48px 24px;
  text-align: center;
}

#footer blockquote {
  max-width: 640px;
  margin: 0 auto;
}

#footer blockquote p {
  font-size: 16px;
  font-style: italic;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 12px;
}

#footer cite {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.7;
  font-style: normal;
}

/* ── Card Status Dots ── */
.card-status-dot {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.3;
  transition: background 0.3s, opacity 0.3s, box-shadow 0.3s;
}

.card-status-dot.loading {
  background: var(--yellow);
  opacity: 1;
  box-shadow: 0 0 6px var(--yellow);
  animation: pulse 1.5s ease-in-out infinite;
}

.card-status-dot.ok {
  background: var(--green);
  opacity: 1;
  box-shadow: 0 0 6px var(--green);
  animation: none;
}

.card-status-dot.error {
  background: var(--red);
  opacity: 1;
  box-shadow: 0 0 6px var(--red);
  animation: none;
}

.card-status-dot.unknown {
  background: var(--text-muted);
  opacity: 0.3;
  box-shadow: none;
  animation: none;
}

/* ── Search Overlay ── */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}

.search-overlay.hidden {
  display: none;
}

.search-container {
  width: 100%;
  max-width: 560px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.search-input-wrap > i {
  font-size: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-input-wrap input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
}

.search-input-wrap input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.search-input-wrap kbd {
  padding: 2px 8px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
}

.search-results {
  max-height: 320px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  cursor: pointer;
  transition: background 0.15s;
}

.search-result-item:hover,
.search-result-item.active {
  background: rgba(255, 196, 81, 0.08);
}

.search-result-item i {
  font-size: 18px;
  color: var(--accent);
  flex-shrink: 0;
}

.search-result-item span {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.search-result-empty {
  padding: 24px 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Search Card Visibility ── */
.search-hidden {
  display: none !important;
}

.search-highlight {
  border-color: var(--accent) !important;
  box-shadow: 0 0 12px var(--accent-glow) !important;
}

/* ── Nav Search Button ── */
.nav-search-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  font-family: inherit;
}

.nav-search-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ── Hero Widget ── */
.hero-greeting {
  font-size: clamp(16px, 2.5vw, 20px);
  color: var(--text-muted);
  margin-bottom: 4px;
}

.hero-clock {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 700;
  color: var(--text-heading);
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  line-height: 1.1;
  margin-bottom: 4px;
}

.hero-date {
  font-size: clamp(14px, 2vw, 16px);
  color: var(--text-muted);
  margin-bottom: 12px;
}

.hero-weather {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.hero-weather i {
  font-size: 16px;
  color: var(--accent);
}

/* ── Spin animation for loading icon ── */
.ri-spin {
  display: inline-block;
  animation: riSpin 1s linear infinite;
}

@keyframes riSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Mobile Adjustments ── */
@media (max-width: 768px) {
  .search-overlay {
    padding: 8vh 16px 0;
  }

  .search-input-wrap kbd {
    display: none;
  }

  .nav-search-btn {
    padding: 14px 16px;
    font-size: 18px;
  }
}

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

  html {
    scroll-behavior: auto;
  }
}
