/* ================================================================
   voie.css — base layout for the Voie catalog
   ================================================================
   Contains ALL layout, components, and hover behavior.
   Contains NO color/font variables — load a theme file alongside.
   
   Usage in HTML:
     <link rel="stylesheet" href="/voie.css">
     <link rel="stylesheet" href="/themes/nordic.css" id="voie-theme">
   
   Switch theme by changing the href on #voie-theme.
   ================================================================ */

/* ---- Structural scales (theme-independent) ---- */
:root {
  font-size: 16px;

  /* Modular type scale — 1.2 ratio (minor third) */
  --ts-xs:   0.694em;
  --ts-sm:   0.833em;
  --ts-base: 1em;
  --ts-md:   1.125em;
  --ts-lg:   1.25em;
  --ts-xl:   1.5em;
  --ts-2xl:  1.875em;

  /* Spacing — rem-based, 4px grid */
  --s-1: 0.125rem;
  --s-2: 0.25rem;
  --s-3: 0.375rem;
  --s-4: 0.5rem;
  --s-5: 0.625rem;
  --s-6: 0.75rem;
  --s-8: 1rem;
  --s-10: 1.25rem;
  --s-12: 1.5rem;
  --s-16: 2rem;
  --s-20: 2.5rem;
  --s-24: 3rem;

  --line-height: 1.5;
  --content-max-width: 56rem;
  --transition-fast: 0.12s ease;
  --transition-base: 0.2s ease;
}


/* ================================================================
   RESET & BASE ELEMENTS
   ================================================================ */

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

body {
  font-family: var(--font-body);
  font-size: var(--ts-base);
  line-height: var(--line-height);
  background: var(--bg-root);
  color: var(--text-primary);
  padding: var(--s-12);
  max-width: var(--content-max-width);
  margin: 0 auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1 {
  font-family: var(--font-display);
  color: var(--header-text);
  font-size: var(--ts-xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  background: var(--header-bg);
  padding: var(--s-6) var(--s-8);
  margin: calc(-1 * var(--s-12)) calc(-1 * var(--s-12)) var(--s-12) calc(-1 * var(--s-12));
  width: calc(100% + var(--s-12) * 2);
}

h2 {
  font-family: var(--font-display);
  color: var(--text-secondary);
  font-size: var(--ts-lg);
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: var(--s-12);
}

h3 {
  color: var(--text-muted);
  font-size: var(--ts-sm);
  font-weight: 400;
  margin-bottom: var(--s-8);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h3 span {
  font-size: var(--ts-xs);
  color: var(--text-ghost);
  text-transform: none;
  letter-spacing: 0;
}

button, input, label {
  font-family: var(--font-body);
  font-size: inherit;
}

button { cursor: pointer; }

pre, code {
  font-family: var(--font-mono, var(--font-body));
  background: var(--bg-surface);
  color: var(--text-primary);
}

pre {
  border: 1px solid var(--border-default);
  padding: var(--s-8);
  overflow-x: auto;
  font-size: var(--ts-sm);
  line-height: 1.6;
  border-radius: var(--radius-md);
}

code {
  padding: 0.1em 0.3em;
  font-size: 0.9em;
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ts-sm);
}

th, td {
  text-align: left;
  padding: var(--s-4) var(--s-6);
  border-bottom: 1px solid var(--border-subtle);
}

th {
  color: var(--text-muted);
  font-size: var(--ts-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 400;
}

form {
  display: flex;
  gap: var(--s-6);
  flex-wrap: wrap;
}

hr {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--s-8) 0;
}

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

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


/* ================================================================
   NAVIGATION
   ================================================================ */

nav {
  display: flex;
  align-items: center;
  gap: var(--s-10);
  padding: var(--s-6) 0;
  margin-bottom: var(--s-8);
  border-bottom: 1px solid var(--border-default);
}

nav a {
  color: var(--text-secondary);
  font-size: var(--ts-sm);
  transition: color var(--transition-fast);
}

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

nav a strong {
  color: var(--header-text);
  font-size: var(--ts-base);
}


/* ================================================================
   COMPONENTS
   ================================================================ */

/* ---- Tabs ---- */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: var(--s-12);
  border-bottom: 1px solid var(--border-medium);
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  padding: var(--s-4) var(--s-8);
  font-size: var(--ts-sm);
  transition: color var(--transition-fast);
}

.tab:hover { color: var(--text-secondary); }

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

.panel { display: none; }
.panel.active { display: block; }


/* ---- Cards ---- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  padding: var(--s-6) var(--s-8);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base);
}

.card:hover { border-color: var(--border-strong); }
.card.expanded { border-color: var(--border-bright); }


/* ---- Input area ---- */
.input-area {
  display: flex;
  gap: var(--s-6);
  margin-bottom: var(--s-12);
  flex-wrap: wrap;
}

.input-area input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: var(--s-5) var(--s-6);
  border-radius: var(--radius-md);
  min-width: 8rem;
}

.input-area button {
  background: var(--border-medium);
  border: 1px solid var(--border-bright);
  color: var(--text-secondary);
  padding: var(--s-5) var(--s-10);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.input-area button:hover {
  background: var(--border-strong);
  color: var(--text-hover);
}

.input-area button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.input-area label {
  display: flex;
  align-items: center;
  gap: 0.3em;
  color: var(--text-muted);
  font-size: var(--ts-sm);
}


/* ---- Stat grid ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr));
  gap: var(--s-8);
  margin-bottom: var(--s-16);
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--s-8);
  text-align: center;
}

.stat-card h2 {
  font-size: var(--ts-2xl);
  color: var(--text-primary);
  margin-bottom: var(--s-2);
}

.stat-card p {
  color: var(--text-muted);
  font-size: var(--ts-sm);
}


/* ---- Status badges ---- */
.status-badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  font-size: var(--ts-xs);
  border-radius: var(--radius-sm);
}

.status-badge.success { background: var(--accent-subtle); color: var(--color-positive); }
.status-badge.error { color: var(--color-negative); }
.status-badge.stale { color: var(--color-warning); }
.status-badge.running { color: var(--accent); }


/* ---- Search bar ---- */
.search-bar {
  display: flex;
  gap: var(--s-6);
  margin-bottom: var(--s-12);
}

.search-bar input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: var(--s-5) var(--s-8);
  font-family: var(--font-body);
  font-size: var(--ts-base);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-bar input::placeholder {
  color: var(--text-faint);
}


/* ================================================================
   THEME SWITCHER
   ================================================================ */

.theme-switcher {
  position: relative;
}

.theme-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: var(--ts-xs);
  padding: var(--s-2) var(--s-4);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.theme-btn:hover {
  color: var(--text-hover);
}

.theme-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  min-width: 10rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--s-2) 0;
  margin-top: var(--s-2);
}

.theme-dropdown.open {
  display: block;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-6);
  color: var(--text-muted);
  font-size: var(--ts-xs);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.theme-option:hover {
  background: var(--bg-hover);
  color: var(--text-hover);
}

.theme-option.active {
  color: var(--text-primary);
}

.theme-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid;
  flex-shrink: 0;
}


/* ================================================================
   VOIE CATALOG TREE
   ================================================================ */

/* ---- Topic row ---- */
.topic-row {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-5) var(--s-6);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  font-size: var(--ts-base);
}

.topic-row:hover { background: var(--bg-elevated); }

.topic-row.expanded {
  background: var(--bg-elevated);
  border-bottom-color: var(--border-medium);
}

.topic-number {
  color: var(--text-faint);
  min-width: 2ch;
  text-align: right;
  font-size: var(--ts-sm);
  transition: color var(--transition-fast);
}

.topic-name {
  flex: 1;
  color: var(--text-primary);
  transition: color var(--transition-fast);
}

.topic-count {
  color: var(--text-muted);
  font-size: var(--ts-xs);
  transition: color var(--transition-fast);
}

.topic-content {
  border-left: 2px solid var(--border-medium);
  margin-left: var(--s-8);
}


/* ---- Subtopic row ---- */
.subtopic-row {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-6) var(--s-4) var(--s-8);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  font-size: var(--ts-sm);
}

.subtopic-row:hover { background: var(--bg-hover); }
.subtopic-row.expanded { background: var(--bg-hover); }

.subtopic-name {
  flex: 1;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
}

.subtopic-count {
  color: var(--text-faint);
  font-size: var(--ts-xs);
  transition: color var(--transition-fast);
}

.subtopic-content {
  border-left: 2px solid var(--border-default);
  margin-left: var(--s-16);
}


/* ---- Provider card ---- */
.provider-card {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-6) var(--s-4) var(--s-8);
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  font-size: var(--ts-base);
}

.provider-card:hover { background: var(--bg-elevated); }

.provider-card.expanded {
  background: var(--bg-elevated);
  border-bottom-color: var(--border-medium);
}

.provider-flag { font-size: var(--ts-md); }

.provider-name {
  color: var(--text-primary);
  font-weight: 600;
  transition: color var(--transition-fast);
}

.provider-city {
  color: var(--text-muted);
  font-size: var(--ts-sm);
  transition: color var(--transition-fast);
}

.provider-price {
  color: var(--text-dim);
  font-size: var(--ts-sm);
  transition: color var(--transition-fast);
}

.provider-content {
  border-left: 2px solid var(--border-default);
  margin-left: calc(var(--s-16) + var(--s-8));
}


/* ---- Tags ---- */
.tag {
  display: inline-block;
  padding: 0.1em 0.5em;
  margin: 0.1em;
  font-size: var(--ts-xs);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.free-badge {
  color: var(--color-positive);
  font-size: var(--ts-xs);
  font-weight: 600;
}


/* ---- Expand indicator ---- */
.expand-indicator {
  color: var(--text-ghost);
  font-size: var(--ts-sm);
  transition: transform var(--transition-fast), color var(--transition-fast);
  display: inline-block;
  width: 1.2em;
  text-align: center;
}

.expanded > .expand-indicator {
  transform: rotate(90deg);
}


/* ---- Provider detail panel ---- */
.provider-detail {
  padding: var(--s-8) var(--s-10);
  font-size: var(--ts-sm);
  line-height: var(--line-height);
}

.provider-detail .detail-header {
  margin-bottom: var(--s-8);
}

.provider-detail .detail-header a {
  color: var(--accent);
  font-size: var(--ts-sm);
}

.provider-detail .tagline {
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: var(--s-8);
  font-size: var(--ts-sm);
}

.offering-block {
  padding: var(--s-4) 0;
  border-top: 1px solid var(--border-subtle);
}

.offering-block .offering-context {
  color: var(--text-muted);
  font-size: var(--ts-xs);
  margin-bottom: var(--s-2);
}

.offering-block .offering-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-6);
  font-size: var(--ts-sm);
  color: var(--text-dim);
}


/* ---- Search results ---- */
.search-group { margin-bottom: var(--s-10); }

.search-group-header {
  color: var(--text-muted);
  font-size: var(--ts-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: var(--s-4) 0;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--s-4);
}

.search-result-row {
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-4) var(--s-6);
  font-size: var(--ts-base);
  border-bottom: 1px solid var(--border-subtle);
}

.search-result-row .result-subtopic {
  color: var(--text-faint);
  font-size: var(--ts-xs);
}


/* ---- Utilities ---- */
.muted { color: var(--text-muted); font-size: var(--ts-sm); }
.subtitle { color: var(--text-dim); font-size: var(--ts-base); margin-bottom: var(--s-12); }


/* ================================================================
   HOVER CONTRAST — universal behavior across all themes
   On hover, all text children shift toward --text-hover
   (near-white on dark themes, near-black on light themes)
   ================================================================ */

.topic-row:hover .topic-name,
.topic-row:hover .topic-count,
.topic-row:hover .topic-number,
.topic-row:hover .expand-indicator {
  color: var(--text-hover);
}

.subtopic-row:hover .subtopic-name,
.subtopic-row:hover .subtopic-count,
.subtopic-row:hover .expand-indicator {
  color: var(--text-hover);
}

.provider-card:hover .provider-name,
.provider-card:hover .provider-city,
.provider-card:hover .provider-price,
.provider-card:hover .expand-indicator {
  color: var(--text-hover);
}

.provider-card:hover .tag {
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.search-result-row:hover {
  background: var(--bg-hover);
}

.search-result-row:hover .provider-name,
.search-result-row:hover .result-subtopic {
  color: var(--text-hover);
}


/* ================================================================
   ACCESSIBILITY
   ================================================================
   - All text tiers in every theme meet WCAG 2.1 AA (4.5:1)
     for primary through dim. Muted meets 3:1 (AA large text).
   - Faint/ghost are decorative only — not relied upon for info.
   - Focus-visible outlines use accent color for keyboard nav.
   - Hover contrast boost ensures readability at all tiers.
   ================================================================ */

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

/* Skip link for keyboard users */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--s-4);
  background: var(--accent);
  color: var(--bg-root);
  padding: var(--s-4) var(--s-8);
  z-index: 9999;
  font-size: var(--ts-sm);
  border-radius: var(--radius-md);
}

.skip-link:focus {
  top: var(--s-4);
}


/* ================================================================
   SUGGEST OVERLAY & FORM
   ================================================================ */

.suggest-trigger {
  background: none;
  border: 1px solid var(--border-default);
  color: var(--text-muted);
  font-size: var(--ts-sm);
  padding: var(--s-2) var(--s-6);
  border-radius: var(--radius-md);
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.suggest-trigger:hover {
  color: var(--text-hover);
  border-color: var(--border-strong);
}

#suggest-overlay:empty { display: none; }

#suggest-overlay:not(:empty) {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-8);
}

.suggest-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  max-width: 28rem;
  width: 100%;
  padding: var(--s-12);
}

.suggest-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-10);
  color: var(--text-primary);
  font-size: var(--ts-lg);
}

.suggest-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: var(--ts-xl);
  line-height: 1;
  padding: var(--s-2);
  transition: color var(--transition-fast);
}

.suggest-close:hover { color: var(--text-hover); }

.suggest-panel form {
  display: flex;
  flex-direction: column;
  gap: var(--s-8);
}

.suggest-field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.suggest-field label {
  color: var(--text-muted);
  font-size: var(--ts-sm);
}

.suggest-field input,
.suggest-field select {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: var(--s-4) var(--s-6);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--ts-base);
}

.suggest-field input:focus,
.suggest-field select:focus {
  outline: none;
  border-color: var(--accent);
}

.suggest-error {
  border: 1px solid var(--color-negative);
  color: var(--color-negative);
  padding: var(--s-4) var(--s-6);
  border-radius: var(--radius-md);
  font-size: var(--ts-sm);
  margin-bottom: var(--s-4);
}

.suggest-submit {
  background: var(--accent);
  color: var(--bg-root);
  border: none;
  padding: var(--s-5) var(--s-10);
  border-radius: var(--radius-md);
  font-size: var(--ts-base);
  font-weight: 500;
  transition: opacity var(--transition-fast);
}

.suggest-submit:hover { opacity: 0.85; }

.suggest-message {
  color: var(--text-secondary);
  font-size: var(--ts-sm);
  line-height: var(--line-height);
}
