/* Art direction: DDNS dashboard — dual personality
   Light: soft pink, friendly, Pacifico + Nunito
   Dark:  dense technical, cool black, Geist Mono + Geist
   ──────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300..700&family=Geist+Mono:wght@400;500;600&family=Nunito:wght@300..800&family=Pacifico&display=swap');

/* ══════════════════════════════════════════════════════════
   LIGHT MODE — pink, bubbly, warm
   ══════════════════════════════════════════════════════════ */
:root, [data-theme="light"] {
  --font-body:    'Nunito', 'Segoe UI', sans-serif;
  --font-display: 'Pacifico', cursive;
  --font-mono:    'Geist Mono', monospace;

  --text-xs:   clamp(0.75rem,  0.7rem  + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem  + 0.35vw, 1rem);
  --text-base: clamp(1rem,     0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem    + 0.75vw, 1.5rem);

  --space-1: 0.25rem; --space-2: 0.5rem;  --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem; --space-12: 3rem;

  --radius-sm:   0.5rem;
  --radius-md:   0.875rem;
  --radius-lg:   1.25rem;
  --radius-xl:   1.75rem;
  --radius-full: 9999px;

  --transition: 200ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Surfaces */
  --color-bg:             #fff0f6;
  --color-surface:        #fff5f9;
  --color-surface-2:      #ffffff;
  --color-surface-offset: #fce8f3;
  --color-divider:        #f5c6e0;
  --color-border:         oklch(0.7 0.12 350 / 0.22);

  /* Text */
  --color-text:         #4a1535;
  --color-text-muted:   #a0547a;
  --color-text-faint:   #d4a0be;
  --color-text-inverse: #ffffff;

  /* Accent */
  --color-primary:       #e0458a;
  --color-primary-hover: #c4306e;
  --color-primary-subtle:#fce8f3;

  /* Status */
  --color-success:      #2d7a4f;
  --color-success-bg:   #e2f5ec;
  --color-warning:      #9a5c00;
  --color-warning-bg:   #fff3d6;
  --color-error:        #c0184a;
  --color-error-bg:     #ffe0ec;
  --color-progress:     #7c3aaa;
  --color-progress-bg:  #f0e4ff;

  /* Shadows */
  --shadow-sm: 0 2px 8px  oklch(0.6 0.15 350 / 0.12);
  --shadow-md: 0 6px 20px oklch(0.6 0.15 350 / 0.18);
  --shadow-lg: 0 12px 40px oklch(0.6 0.15 350 / 0.22);

  /* Header gradient */
  --header-bg: linear-gradient(135deg, #f472b6 0%, #e0458a 50%, #c026d3 100%);
  --header-text: #ffffff;
}

/* ══════════════════════════════════════════════════════════
   DARK MODE — black, sharp, technical
   ══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
  --font-body:    'Geist', 'Inter', sans-serif;
  --font-display: 'Geist', 'Inter', sans-serif;
  --font-mono:    'Geist Mono', 'Fira Code', monospace;

  --radius-sm:   0.25rem;
  --radius-md:   0.375rem;
  --radius-lg:   0.5rem;
  --radius-xl:   0.75rem;
  --radius-full: 9999px;

  --transition: 150ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Surfaces */
  --color-bg:             #0f0f0e;
  --color-surface:        #161614;
  --color-surface-2:      #1e1d1b;
  --color-surface-offset: #252422;
  --color-surface-dynamic:#2d2c2a;
  --color-divider:        #2a2927;
  --color-border:         oklch(1 0 0 / 0.08);

  /* Text */
  --color-text:         #e8e7e4;
  --color-text-muted:   #7a7976;
  --color-text-faint:   #4a4947;
  --color-text-inverse: #0f0f0e;

  /* Accent */
  --color-primary:       #3d9ea8;
  --color-primary-hover: #5ab8c2;
  --color-primary-subtle:#1a3035;

  /* Status */
  --color-success:     #5daa38;
  --color-success-bg:  #1a2e12;
  --color-warning:     #e09040;
  --color-warning-bg:  #2a1e08;
  --color-error:       #e05080;
  --color-error-bg:    #2a1020;
  --color-progress:    #9b7de0;
  --color-progress-bg: #1e1430;

  /* Shadows */
  --shadow-sm: 0 1px 2px  oklch(0 0 0 / 0.35);
  --shadow-md: 0 4px 12px oklch(0 0 0 / 0.45);
  --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.55);

  /* Header */
  --header-bg:   var(--color-surface-offset);
  --header-text: var(--color-text-muted);
}

/* System preference fallback */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --font-body: 'Geist', 'Inter', sans-serif;
    --font-display: 'Geist', 'Inter', sans-serif;
    --font-mono: 'Geist Mono', 'Fira Code', monospace;
    --radius-sm: 0.25rem; --radius-md: 0.375rem;
    --radius-lg: 0.5rem;  --radius-xl: 0.75rem;
    --radius-full: 9999px;
    --transition: 150ms cubic-bezier(0.16, 1, 0.3, 1);
    --color-bg: #0f0f0e; --color-surface: #161614;
    --color-surface-2: #1e1d1b; --color-surface-offset: #252422;
    --color-surface-dynamic: #2d2c2a; --color-divider: #2a2927;
    --color-border: oklch(1 0 0 / 0.08);
    --color-text: #e8e7e4; --color-text-muted: #7a7976;
    --color-text-faint: #4a4947; --color-text-inverse: #0f0f0e;
    --color-primary: #3d9ea8; --color-primary-hover: #5ab8c2;
    --color-primary-subtle: #1a3035;
    --color-success: #5daa38; --color-success-bg: #1a2e12;
    --color-warning: #e09040; --color-warning-bg: #2a1e08;
    --color-error: #e05080;   --color-error-bg: #2a1020;
    --color-progress: #9b7de0; --color-progress-bg: #1e1430;
    --shadow-sm: 0 1px 2px oklch(0 0 0 / 0.35);
    --shadow-md: 0 4px 12px oklch(0 0 0 / 0.45);
    --shadow-lg: 0 8px 24px oklch(0 0 0 / 0.55);
    --header-bg: #252422; --header-text: #7a7976;
  }
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100dvh;
  line-height: 1.5;
  padding: var(--space-4);
  padding-bottom: 4.5rem;
}

/* Pink bg blobs — light only */
[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse at 10% 10%, oklch(0.87 0.10 340 / 0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 90%, oklch(0.83 0.12 310 / 0.35) 0%, transparent 50%);
}

a, button, input, select {
  transition:
    color var(--transition),
    background var(--transition),
    border-color var(--transition),
    box-shadow var(--transition),
    transform var(--transition);
}
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
img { display: block; max-width: 100%; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1900px;
  margin: 0 auto var(--space-5);
  padding: var(--space-3) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 400;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

[data-theme="dark"] .page-title {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--text-sm);
  letter-spacing: -0.01em;
  color: var(--color-text);
}

.page-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header-clock {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  letter-spacing: 0.03em;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
}

.btn-refresh:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.theme-toggle:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: var(--color-primary-subtle);
}

/* ── Stats bar ────────────────────────────────────────────── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  max-width: 1900px;
  margin: 0 auto var(--space-5);
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

[data-theme="dark"] .stat-label { font-family: var(--font-mono); }

.stat-value {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.2;
}

.stat-card.stat-ok    .stat-value { color: var(--color-success); }
.stat-card.stat-err   .stat-value { color: var(--color-error); }
.stat-card.stat-upd   .stat-value { color: var(--color-progress); }

/* ── Table wrap ───────────────────────────────────────────── */
.table-wrap {
  max-width: 1900px;
  margin: 0 auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-offset);
}

.table-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-faint);
}

[data-theme="dark"] .table-title { font-family: var(--font-mono); }

.table-updated {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

/* ── Table ────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
}

thead {
  background: var(--header-bg);
  border-bottom: 1px solid var(--color-divider);
}

[data-theme="light"] th {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.9);
  text-align: center;
  padding: var(--space-4) var(--space-4);
  white-space: nowrap;
}

[data-theme="dark"] th {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  text-align: left;
  padding: var(--space-3) var(--space-4);
  white-space: nowrap;
}

td {
  font-size: var(--text-sm);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-divider);
  vertical-align: middle;
}

[data-theme="light"] td { text-align: center; }
[data-theme="dark"]  td { text-align: left; font-family: var(--font-body); }

/* mono cells in dark */
[data-theme="dark"] td.mono {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

tbody tr:last-child td { border-bottom: none; }

[data-theme="light"] tbody tr:nth-child(odd) td {
  background: color-mix(in oklch, var(--color-primary) 4%, var(--color-surface));
}
[data-theme="dark"] tbody tr:nth-child(odd) td {
  background: color-mix(in oklch, var(--color-surface-offset) 35%, transparent);
}

[data-theme="light"] tbody tr:hover td {
  background: color-mix(in oklch, var(--color-primary) 10%, var(--color-surface-2));
}
[data-theme="dark"] tbody tr:hover td {
  background: color-mix(in oklch, var(--color-primary) 6%, var(--color-surface-2));
}

/* ── Status badges ────────────────────────────────────────── */
.success, .uptodate, .error, .updating, .unset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  padding: 3px var(--space-3);
}

[data-theme="dark"] .success,
[data-theme="dark"] .uptodate,
[data-theme="dark"] .error,
[data-theme="dark"] .updating,
[data-theme="dark"] .unset {
  font-family: var(--font-mono);
  padding: 2px var(--space-2);
  letter-spacing: 0.02em;
}

.success::before, .uptodate::before, .error::before,
.updating::before, .unset::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

[data-theme="light"] .success::before,
[data-theme="light"] .uptodate::before,
[data-theme="light"] .error::before,
[data-theme="light"] .updating::before,
[data-theme="light"] .unset::before { width: 7px; height: 7px; }

.success, .uptodate { color: var(--color-success); background: var(--color-success-bg); }
.success::before, .uptodate::before { background: var(--color-success); }

.error { color: var(--color-error); background: var(--color-error-bg); }
.error::before { background: var(--color-error); }

.updating { color: var(--color-progress); background: var(--color-progress-bg); }
.updating::before {
  background: var(--color-progress);
  animation: badgepulse 1.2s ease-in-out infinite;
}

.unset { color: var(--color-warning); background: var(--color-warning-bg); }
.unset::before { background: var(--color-warning); }

@keyframes badgepulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.3; transform: scale(0.5); }
}

/* ── Links ────────────────────────────────────────────────── */
a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 600;
}

[data-theme="dark"] a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
}

a:hover {
  color: var(--color-primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ── Footer ───────────────────────────────────────────────── */
footer {
  position: fixed;
  bottom: 0; left: 0; width: 100%;
  padding: var(--space-2) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: color-mix(in oklch, var(--color-surface) 88%, transparent);
  z-index: 100;
}

[data-theme="dark"] footer { font-family: var(--font-mono); }

footer a { color: var(--color-text-faint); }
footer a:hover { color: var(--color-text-muted); text-decoration: underline; }

#refresh-countdown {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-text-faint);
}

.github-icon {
  vertical-align: text-bottom;
  fill: currentColor;
  height: 1em; width: 1em;
  display: inline;
}

/* ── Misc ─────────────────────────────────────────────────── */
.text-big { font-size: var(--text-base); font-weight: 700; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Responsive ───────────────────────────────────────────── */
@media only screen and (max-width: 760px) {
  body { padding: var(--space-3); padding-bottom: 5rem; }

  .stats-bar { grid-template-columns: repeat(2, 1fr); }

  .table-wrap { border-radius: var(--radius-md); }
  .page-header { border-radius: var(--radius-md); }

  table, thead, tbody, th, td, tr { display: block; }
  thead tr { position: absolute; top: -9999px; left: -9999px; }

  tr {
    margin-bottom: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-2);
    overflow: hidden;
  }

  tbody tr:nth-child(odd) td { background: transparent !important; }
  tbody tr:hover td { background: transparent !important; }

  td {
    border-bottom: 1px solid var(--color-divider);
    padding: var(--space-2) var(--space-3);
    display: grid;
    grid-template-columns: 42% 1fr;
    align-items: center;
    gap: var(--space-2);
    text-align: left !important;
  }
  td:last-child { border-bottom: none; }

  td::before {
    content: attr(data-label);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-faint);
    white-space: nowrap;
  }
  [data-theme="dark"] td::before { font-family: var(--font-mono); font-weight: 500; }
}

@media only screen and (max-width: 480px) {
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .header-clock { display: none; }
}
