/* vbot.co.kr — CSS variables are injected from config/theme.json in layout.php */
/* Design system: 2025/26 mobile-first, 360px base, 8pt/4pt grid, Pretendard Variable */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable-dynamic-subset.min.css");

/* ---- Design tokens ---- */
:root {
  /* Spacing scale: 4pt base */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Border radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* Typography scale */
  --text-xs:   0.6875rem; /* 11px */
  --text-sm:   0.8125rem; /* 13px */
  --text-base: 0.875rem;  /* 14px */
  --text-lg:   1rem;      /* 16px */
  --text-xl:   1.125rem;  /* 18px */
  --text-2xl:  1.375rem;  /* 22px */

  /* Surface tone aliases */
  --surface-1: var(--surface);
  --surface-2: var(--surface-alt);
  --surface-3: #25262d;

  /* Animation */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 220ms;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--base-px);
  line-height: 1.6;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01";
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

a {
  color: var(--accent);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

code, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--text-xs);
}

/* ---- Nav ---- */
.vbot-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--surface-2);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  /* iOS notch support */
  padding-top: env(safe-area-inset-top, 0px);
}

.vbot-nav-inner {
  display: flex;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  height: 52px;
  padding: 0 var(--space-4);
  gap: var(--space-1);
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0,
    black 16px,
    black calc(100% - 16px),
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0,
    black 16px,
    black calc(100% - 16px),
    transparent 100%
  );
}

.vbot-nav-inner::-webkit-scrollbar { display: none; }

.vbot-nav a {
  display: inline-flex;
  align-items: center;
  height: 100%;
  color: var(--muted);
  padding: 0 var(--space-3);
  white-space: nowrap;
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0;
  border-bottom: 2px solid transparent;
  transition:
    color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out);
  min-width: 44px;
  justify-content: center;
}

.vbot-nav a:hover { color: var(--text); }

.vbot-nav a.active {
  color: var(--text);
  font-weight: 700;
  border-bottom-color: var(--accent);
}

/* ---- Main layout ---- */
main {
  padding: var(--space-5) var(--space-4)
    calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
  max-width: 100%;
  animation: fade-up var(--dur-base) var(--ease-out) both;
}

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

main h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: var(--space-5);
  color: var(--text);
}

/* ---- Grid ---- */
.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr 1fr;
}

/* ---- Card ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  /* Do not clip — needed for table horizontal scroll bleed */
}

.card:last-child { margin-bottom: 0; }

.card-title {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
  line-height: 1;
}

/* ---- Big number ---- */
.big-number {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.0;
  font-feature-settings: "tnum";
  color: var(--text);
}

.big-number .unit {
  font-size: var(--text-base);
  color: var(--muted);
  margin-left: var(--space-1);
  font-weight: 400;
  letter-spacing: 0;
}

/* ---- Table ---- */
/* Card must not clip the scroll wrapper — override overflow for table-cards */
.card:has(.vbot-table-wrap) {
  overflow: visible;
}

.vbot-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Bleed to card edges on mobile */
  margin-left: calc(-1 * var(--space-5));
  margin-right: calc(-1 * var(--space-5));
  padding-left: var(--space-5);
  padding-right: var(--space-5);
  /* Show shadow hint on right to indicate scrollability */
  background:
    linear-gradient(to right, var(--surface-1) 30%, transparent) left,
    linear-gradient(to left, var(--surface-1) 30%, transparent) right;
  background-attachment: local, local;
  background-size: 40px 100%, 40px 100%;
  background-repeat: no-repeat;
}

table.vbot-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  /* Prevent table from collapsing columns — force horizontal scroll instead */
  table-layout: auto;
}

table.vbot-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--surface-2);
  white-space: nowrap;
  background: var(--surface-1);
  position: sticky;
  top: 0;
}

table.vbot-table td {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  border-bottom: 1px solid var(--surface-2);
  vertical-align: top;
  line-height: 1.5;
  /* Prevent catastrophic wrapping on short Korean words */
  word-break: keep-all;
  overflow-wrap: break-word;
}

table.vbot-table tr:last-child td { border-bottom: none; }

table.vbot-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}

table.vbot-table tbody tr:hover { background: var(--surface-2); }

/* First column slightly bolder */
table.vbot-table td:first-child {
  font-weight: 500;
  color: var(--text);
}

/* Numeric columns */
table.vbot-table td.num,
table.vbot-table th.num {
  text-align: right;
  font-feature-settings: "tnum";
}

/* Empty state row */
.vbot-table-empty {
  text-align: center;
  color: var(--muted);
  font-size: var(--text-sm);
  padding: var(--space-6) var(--space-5);
  line-height: 1.6;
}

/* ---- Pill ---- */
.pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  font-feature-settings: "tnum";
}

.pill.ok    { background: rgba(52, 211, 153, 0.12); color: var(--success); }
.pill.warn  { background: rgba(251, 191, 36,  0.12); color: var(--warn); }
.pill.error { background: rgba(248, 113, 113, 0.12); color: var(--error); }

/* ---- Pill group ---- */
.pill-group {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* ---- Timeline ---- */
.timeline { list-style: none; }

.timeline li {
  position: relative;
  padding: var(--space-2) 0 var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  color: var(--muted);
  line-height: 1.5;
  border-left: 2px solid var(--surface-3);
  margin-left: var(--space-2);
}

.timeline li::before {
  content: '';
  position: absolute;
  left: -5px;
  top: calc(var(--space-2) + 8px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--surface-3);
  border: 2px solid var(--bg);
}

.timeline li:first-child::before { background: var(--accent); }
.timeline li:last-child { border-left-color: transparent; }

.timeline li .ts {
  font-size: var(--text-xs);
  color: var(--muted);
  font-weight: 500;
  margin-right: var(--space-2);
  font-feature-settings: "tnum";
  white-space: nowrap;
}

/* ---- Severity helpers ---- */
.sev-critical { color: var(--error); }
.sev-error    { color: #fb923c; }
.sev-warn     { color: var(--warn); }
.sev-info     { color: #60a5fa; }
.sev-routine  { color: var(--muted); }

/* ---- Responsive: tablet ---- */
@media (min-width: 768px) {
  .vbot-nav-inner {
    height: 56px;
    padding: 0 var(--space-6);
  }

  .vbot-nav a {
    padding: 0 var(--space-4);
    font-size: var(--text-base);
  }

  main {
    padding: var(--space-6) var(--space-6) var(--space-8);
    max-width: 1200px;
    margin: 0 auto;
  }

  main h1 {
    font-size: 1.75rem;
    margin-bottom: var(--space-6);
  }

  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-5);
  }

  .card { margin-bottom: var(--space-6); }

  .vbot-table-wrap {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ---- Responsive: desktop ---- */
@media (min-width: 1024px) {
  main {
    padding: var(--space-6) clamp(var(--space-6), 4vw, var(--space-8)) var(--space-8);
  }
}

/* ---- Utility ---- */
.muted { color: var(--muted); }
