/* ===========================================
   HTTP Toolbox – Flat, Mobile-First UI
   =========================================== */

:root {
  /* Section backgrounds – lighter at top, darker at bottom */
  --bg-header: #3d4555;
  --bg-progress: #252b38;
  --bg-status: #2a313f;
  --bg-desc: #232936;
  --bg-info: #1c212b;
  --bg-hud: #161a22;
  --bg-log: #12151b;
  --bg-body: #0d1015;

  /* Text */
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* Accents */
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --success: #4ade80;
  --warning: #fbbf24;
  --error: #f87171;

  /* Borders */
  --border: rgba(255, 255, 255, 0.08);
  --border-subtle: rgba(255, 255, 255, 0.04);

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--bg-body);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===========================================
   Header Bar – Lightest, sticky at top
   =========================================== */

.statusbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 8px;
  min-height: 44px;
}

.statusbar__left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
  flex-shrink: 1;
}

.statusbar__test-num {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.statusbar__title {
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusbar__right {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-shrink: 0;
}

.statusbar__metric {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.statusbar__label {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.statusbar__value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* ===========================================
   Progress Bar – Tiny sliver
   =========================================== */

.progress-bar {
  height: 3px;
  background: var(--bg-progress);
  position: relative;
  overflow: hidden;
}

.progress-bar__fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-strong));
  transition: width 100ms ease-out;
}

/* ===========================================
   Main Content Area
   =========================================== */

main {
  display: flex;
  flex-direction: column;
}

/* ===========================================
   Sections – Full width, stacked, bg colors
   =========================================== */

.section {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.section:last-child {
  border-bottom: none;
}

.section--status {
  background: var(--bg-status);
  padding: 10px 12px;
}

.section--desc {
  background: var(--bg-desc);
}

.section--info {
  background: var(--bg-info);
}

.section--hud {
  background: var(--bg-hud);
  padding: 0;
}

.section--log {
  background: var(--bg-log);
}

/* Legacy card/panel support */
.panel,
.card {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card:nth-child(1) { background: var(--bg-status); }
.card:nth-child(2) { background: var(--bg-desc); }
.card:nth-child(3) { background: var(--bg-info); }
.card:nth-child(4) { background: var(--bg-hud); }
.card:nth-child(5) { background: var(--bg-log); }

.card:last-child,
.panel:last-child {
  border-bottom: none;
}

/* ===========================================
   Typography
   =========================================== */

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

h1,
h2,
.heading {
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

h1 {
  font-size: 18px;
  margin-bottom: 6px;
}

h2,
.heading {
  font-size: 14px;
  margin-bottom: 6px;
}

p,
.subheading {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.subheading + .subheading,
p + p {
  margin-top: 8px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.06);
  padding: 1px 4px;
  color: var(--accent);
}

/* ===========================================
   Status Pill – Full width block
   =========================================== */

.status-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 100%;
  text-align: center;
}

.status-pill.success {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.3);
  background: rgba(74, 222, 128, 0.1);
}

.status-pill.warning {
  color: var(--warning);
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(251, 191, 36, 0.1);
}

.status-pill.error {
  color: var(--error);
  border-color: rgba(248, 113, 113, 0.3);
  background: rgba(248, 113, 113, 0.1);
}

.status-pill.running {
  color: var(--accent);
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.1);
}

/* ===========================================
   HUD / Info Blocks
   =========================================== */

.hud {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border-subtle);
}

.hud__tile {
  background: var(--bg-hud);
  padding: 10px 12px;
}

.hud__label {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.hud__value {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

/* ===========================================
   Buttons
   =========================================== */

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--bg-info);
}

button,
.btn,
a.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  color: #0d1117;
  border: none;
  cursor: pointer;
  transition: background 150ms ease;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}

button:hover,
.btn:hover,
a.button:hover {
  background: var(--accent-strong);
  text-decoration: none;
}

button:active,
.btn:active,
a.button:active {
  transform: scale(0.98);
}

button:disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.secondary,
.btn.secondary,
a.button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover,
.btn.secondary:hover,
a.button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===========================================
   Log Area
   =========================================== */

.log-area {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  padding: 8px;
  min-height: 80px;
  max-height: 200px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.log-entry {
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.02);
  border-left: 2px solid var(--border);
}

.log-entry:last-child {
  margin-bottom: 0;
}

.log-entry.success {
  border-left-color: var(--success);
  background: rgba(74, 222, 128, 0.05);
}

.log-entry.warning {
  border-left-color: var(--warning);
  background: rgba(251, 191, 36, 0.05);
}

.log-entry.error {
  border-left-color: var(--error);
  background: rgba(248, 113, 113, 0.05);
}

.log-entry-meta {
  margin-top: 4px;
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  font-size: 10px;
  overflow-x: auto;
}

/* ===========================================
   Lists
   =========================================== */

.list {
  padding-left: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.list li {
  margin-bottom: 6px;
  line-height: 1.4;
}

.list li:last-child {
  margin-bottom: 0;
}

/* ===========================================
   Links
   =========================================== */

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.link-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===========================================
   Navigation Controls
   =========================================== */

.section--nav {
  background: var(--bg-hud);
  padding: 0;
  border-top: 1px solid var(--border);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* Add padding to main content so it's not hidden behind fixed nav */
main {
  padding-bottom: 60px;
}

.nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  gap: 12px;
}

.nav-controls__left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-controls__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toggle button */
.nav-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  min-height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
  -webkit-tap-highlight-color: transparent;
}

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

.nav-toggle--active {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
  color: var(--accent);
}

.nav-toggle--active:hover {
  background: rgba(96, 165, 250, 0.2);
}

.nav-toggle__indicator {
  width: 32px;
  height: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border);
  position: relative;
  transition: background 150ms ease, border-color 150ms ease;
}

.nav-toggle__indicator::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: var(--text-muted);
  transition: transform 150ms ease, background 150ms ease;
}

.nav-toggle--active .nav-toggle__indicator {
  background: rgba(96, 165, 250, 0.2);
  border-color: var(--accent);
}

.nav-toggle--active .nav-toggle__indicator::after {
  transform: translateX(14px);
  background: var(--accent);
}

.nav-toggle__label {
  white-space: nowrap;
}

/* Countdown */
.nav-countdown {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* Next button */
.nav-next {
  min-height: 40px;
  padding: 0 14px;
  font-size: 13px;
}

/* ===========================================
   Grid layout for homepage cards
   =========================================== */

.grid {
  display: grid;
  gap: 1px;
  background: var(--border-subtle);
}

.grid > .card {
  background: var(--bg-info);
  padding: 12px;
  border-bottom: none;
}

.grid > .card h2 {
  margin-bottom: 4px;
}

.grid > .card p {
  margin-bottom: 10px;
}

/* ===========================================
   Page layouts (index, completion)
   =========================================== */

/* Legacy page-header support - prefer statusbar for consistency */
.page-header {
  background: var(--bg-header);
  padding: 12px;
}

.page-header .eyebrow {
  margin-bottom: 2px;
}

.page-header h1 {
  margin-bottom: 4px;
}

.page-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.page-section:last-child {
  border-bottom: none;
}

.page-section--cards {
  background: var(--bg-desc);
  padding: 0;
}

.page-section--meta {
  background: var(--bg-info);
}

/* Grid cards need consistent styling */
.grid > .card {
  background: var(--bg-info);
  padding: 16px;
  border-bottom: none;
}

.grid > .card h2 {
  margin-bottom: 8px;
  color: var(--text);
}

.grid > .card p {
  margin-bottom: 12px;
  color: var(--text-muted);
}

/* ===========================================
   Static pages - ensure no bottom padding for nav
   =========================================== */

/* Pages without nav controls don't need the padding */
body:not(:has(.section--nav)) main {
  padding-bottom: 0;
}

/* Fallback for browsers without :has() support */
@supports not selector(:has(*)) {
  .page-static main {
    padding-bottom: 0;
  }
}

/* ===========================================
   Responsive – Tablet & Desktop
   =========================================== */

@media (min-width: 480px) {
  .hud {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  }
}

@media (min-width: 600px) {
  html {
    font-size: 15px;
  }

  .statusbar {
    padding: 12px 16px;
  }

  .statusbar__left {
    font-size: 14px;
  }

  .statusbar__value {
    font-size: 13px;
  }

  .nav-controls {
    padding: 12px 16px;
  }

  main {
    padding-bottom: 68px;
  }

  .nav-toggle {
    padding: 8px 14px;
    font-size: 14px;
  }

  .nav-next {
    min-height: 44px;
    padding: 0 16px;
    font-size: 14px;
  }

  .section,
  .panel,
  .card {
    padding: 16px;
  }

  .section--status {
    padding: 12px 16px;
  }

  h1 {
    font-size: 20px;
  }

  h2,
  .heading {
    font-size: 15px;
  }

  p,
  .subheading {
    font-size: 14px;
  }

  .hud__tile {
    padding: 12px 16px;
  }

  .hud__value {
    font-size: 16px;
  }

  .log-area {
    min-height: 100px;
    max-height: 250px;
    padding: 10px;
    font-size: 12px;
  }

  .log-entry {
    padding: 8px 10px;
    font-size: 12px;
  }

  .status-pill {
    padding: 10px 16px;
    font-size: 14px;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  }

  .nav-countdown {
    font-size: 13px;
  }

  .section--nav {
    max-width: 900px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ===========================================
   Large screens – constrain width
   =========================================== */

@media (min-width: 900px) {
  body {
    background: #08090c;
  }

  .statusbar {
    max-width: 900px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .progress-bar {
    max-width: 900px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  main {
    max-width: 900px;
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  .hud {
    grid-template-columns: repeat(4, 1fr);
  }

  .page-header,
  .page-section {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }

  /* Ensure grid cards fill available space */
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}