/* ============================
   MicroCloud — styles.css
   ============================ */

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

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

:root {
  /* Light theme (default) */
  --bg: #f4f2ec;
  --surface: #fbfaf6;
  --surface-2: #ebe8df;
  --ink: #16181d;
  --ink-2: #4a4e57;
  --line: #d8d4c8;
  --accent: #1f8a5b;
  --accent-soft: #d9efe3;
  --amber: #b7791f;
  --device: #2a2d33;
  --device-edge: #3a3e46;
}

/* Dark mode — system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1113;
    --surface: #16191c;
    --surface-2: #1d2125;
    --ink: #e9e7e1;
    --ink-2: #a3a7ae;
    --line: #2a2f34;
    --accent: #3ccf8e;
    --accent-soft: #143325;
    --amber: #e0a74a;
    --device: #23272c;
    --device-edge: #343a41;
  }
}

/* Dark mode — explicit toggle */
:root[data-theme="dark"] {
  --bg: #0f1113;
  --surface: #16191c;
  --surface-2: #1d2125;
  --ink: #e9e7e1;
  --ink-2: #a3a7ae;
  --line: #2a2f34;
  --accent: #3ccf8e;
  --accent-soft: #143325;
  --amber: #e0a74a;
  --device: #23272c;
  --device-edge: #343a41;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* --- Selection --- */
::-moz-selection {
  background: var(--accent-soft);
  color: var(--ink);
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

/* --- Typography helpers --- */
h1, h2, h3, h4 {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.25rem);
  line-height: 1.05;
}

p {
  max-width: 62ch;
}

/* Mono utility */
.mono,
.eyebrow,
.hw-hostname,
.hw-badge,
.stat-label,
.device-label,
.topo-label,
.bar-label,
.bar-total,
.consumo-note,
.footer-mono,
.logo-wordmark {
  font-family: "IBM Plex Mono", monospace;
}

/* --- Eyebrow (small uppercase labels) --- */
.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 0.75rem;
}

/* --- Container --- */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* --- Sections --- */
.section {
  padding-block: clamp(64px, 10vw, 120px);
  border-top: 1px solid var(--line);
}

.section:first-of-type {
  border-top: none;
}

.section h2 {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}

.section-sub {
  color: var(--ink-2);
  margin-bottom: 2rem;
}

/* Scroll margin for sticky header */
#inicio  { scroll-margin-top: 64px; }
#hardware { scroll-margin-top: 64px; }
#red     { scroll-margin-top: 64px; }
#consumo { scroll-margin-top: 64px; }
#usos    { scroll-margin-top: 64px; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

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

@media (min-width: 768px) {
  .header-inner {
    padding-left: 32px;
    padding-right: 32px;
  }
}

/* Logo */
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--ink);
}

.logo-wordmark {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 1rem;
  color: var(--ink);
}

.logo-dots circle {
  fill: var(--accent);
}

/* Navigation */
.header-nav {
  display: flex;
  gap: 8px;
}

.header-nav a {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ink-2);
  text-decoration: none;
  padding: 4px 8px;
  transition: color 0.15s;
}

.header-nav a:hover {
  color: var(--ink);
}

@media (max-width: 639px) {
  .header-nav {
    display: none;
  }
}

/* Theme toggle */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 4px;
}

.theme-toggle svg {
  display: block;
}

/* Show sun in dark, moon in light */
.icon-sun {
  display: none;
}

.icon-moon {
  display: block;
}

:root[data-theme="dark"] .icon-sun {
  display: block;
}

:root[data-theme="dark"] .icon-moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun {
    display: block;
  }

  :root:not([data-theme="light"]) .icon-moon {
    display: none;
  }
}

/* ============================================================
   HERO
   ============================================================ */
.hero-grid {
  display: grid;
  gap: 32px;
  padding-inline: 16px;
  max-width: 1120px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .hero-grid {
    padding-inline: 32px;
  }
}

@media (min-width: 900px) {
  .hero-grid {
    grid-template-columns: 1.1fr 1fr;
    align-items: center;
  }
}

/* Hero text */
.hero-text {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero h1 {
  margin-bottom: 0.5rem;
}

.hero-paragraph {
  color: var(--ink-2);
  max-width: 62ch;
  margin-bottom: 1.5rem;
}

/* Hero actions */
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 2rem;
}

.btn {
  display: inline-block;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 500;
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn:hover {
  opacity: 0.85;
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
  border: none;
}

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

/* Hero stats */
.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 639px) {
  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.stat-num {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.1;
  color: var(--ink);
}

.stat-label {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

/* Hero figure */
.hero-figure {
  margin: 0;
}

.rack-svg {
  width: 100%;
  height: auto;
  max-width: 280px;
  display: block;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .hero-figure {
    grid-column: 2;
  }
}

/* --- LED blink animation --- */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.led {
  animation: blink 2.4s infinite;
}

.led-1  { animation-delay: 0s; }
.led-2  { animation-delay: 0.4s; }
.led-3  { animation-delay: 0.8s; }
.led-4  { animation-delay: 0.2s; }
.led-5  { animation-delay: 0.6s; }
.led-6  { animation-delay: 1.0s; }
.led-7  { animation-delay: 1.4s; }
.led-8  { animation-delay: 0.1s; }
.led-9  { animation-delay: 0.5s; }
.led-10 { animation-delay: 0.3s; }
.led-11 { animation-delay: 0.7s; }
.led-12 { animation-delay: 1.1s; }

@media (prefers-reduced-motion: reduce) {
  .led {
    animation: none;
  }
}

/* Device SVG styling */
.device-label {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

/* Labels sit on the dark device cases in both themes. */
.device-label,
.topo-label {
  fill: #a3a7ae;
}

/* ============================================================
   HARDWARE
   ============================================================ */
.hw-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 32px;
}

@media (min-width: 900px) {
  .hw-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.hw-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.hw-card-wide {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}

.hw-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.hw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.hw-hostname {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.hw-badge {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin-left: auto;
}

/* Specs definition list */
.hw-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
}

.spec-row {
  display: contents;
}

.spec-row dt {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--ink-2);
}

.spec-row dd {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 400;
  font-size: 0.9375rem;
  color: var(--ink);
}

/* MikroTik wide card */
.hw-card-wide .hw-desc {
  color: var(--ink-2);
  margin-top: 8px;
}

/* ============================================================
   RED
   ============================================================ */
.topo-figure {
  margin: 2rem 0 0;
}

.topo-svg {
  width: 100%;
  height: auto;
  display: block;
}

.topo-label {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.topo-line-label {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.6875rem;
}

.topo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--ink-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================================
   CONSUMO
   ============================================================ */
.consumo-grid {
  display: grid;
  gap: 32px;
}

@media (min-width: 900px) {
  .consumo-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.bar-chart {
  background: transparent;
}

.bar-segments {
  display: flex;
  height: 40px;
  border-radius: 8px;
  overflow: hidden;
}

.bar-segment {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--amber);
  border-right: 1px solid color-mix(in srgb, var(--amber) 80%, #000 20%);
}

.bar-segment:last-child {
  border-right: none;
}

.bar-label {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 0.75rem;
  color: #16181d;
  letter-spacing: 0.04em;
}

.bar-total {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--ink-2);
  margin-top: 8px;
  text-align: center;
}

.consumo-note {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink-2);
  letter-spacing: 0.04em;
  margin-top: 16px;
}

/* ============================================================
   USOS
   ============================================================ */
.usos-grid {
  display: grid;
  gap: 24px;
}

@media (min-width: 768px) {
  .usos-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.uso-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.uso-icon {
  width: 24px;
  height: 24px;
  stroke: var(--accent);
  fill: none;
  margin-bottom: 4px;
}

.uso-icon rect,
.uso-icon circle,
.uso-icon line {
  stroke: var(--accent);
}

.uso-title {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 600;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.uso-desc {
  font-size: 0.9375rem;
  color: var(--ink-2);
  line-height: 1.5;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 32px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-logo svg circle {
  fill: var(--accent);
}

.footer-mono {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 400;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

/* ============================================================
   RESPONSIVE — misc adjustments
   ============================================================ */
@media (max-width: 639px) {
  .hero-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header {
    position: static;
    backdrop-filter: none;
    opacity: 1;
  }
}