/* WISP Livestream — shared base stylesheet
   Loaded AFTER tokens.css, BEFORE any page-specific <style>.
   Defines the site-nav, cards, buttons, save-bar, toast, modal,
   and the a11y helpers (sr-only, :focus-visible). */

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--fg-bright);
}

/* --- A11y helpers --- */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
}
.skip-link:focus {
  position: fixed; top: 0; left: 0;
  background: var(--bush-green); color: var(--paper);
  padding: 12px 20px; z-index: 9999;
  font-weight: 600; text-decoration: none;
  border-radius: 0 0 var(--r-md) 0;
}

/* Global focus ring — overrides any `outline: none` the page-level styles
   may still declare (base.css is loaded last in the cascade). */
:focus-visible {
  outline: var(--focus-ring) !important;
  outline-offset: var(--focus-offset) !important;
}
/* Pointer focus doesn't need a ring; keyboard focus does. */
:focus:not(:focus-visible) { outline: none; }

/* --- Site nav (shared) --- */
.site-nav {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  font-size: 0.9em;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--accent);
  text-decoration: none;
  padding: 4px 0;
  transition: color var(--dur) var(--ease);
}
.site-nav a:hover { color: var(--accent-hover); }
.site-nav a.active {
  color: var(--fg-bright);
  border-bottom: 2px solid var(--accent);
}
.site-nav a.livestream-cta {
  color: var(--brass-bright);
  font-weight: 600;
}
.site-nav a.livestream-cta::before {
  content: "▶";
  margin-right: 4px;
  font-size: 0.8em;
}

/* --- Buttons --- */
.btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 10px 18px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 0.9em;
  font-family: inherit;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.2;
}
.btn:hover { background: var(--surface-alt); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }

.btn--primary {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--paper);
  font-weight: 600;
}
.btn--primary:hover {
  background: var(--brass-dark);
  border-color: var(--brass-dark);
}

.btn--danger {
  border-color: var(--danger);
  color: var(--danger-bright);
}
.btn--danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.btn--success {
  background: var(--success-dark);
  border-color: var(--success-dark);
  color: var(--paper);
}
.btn--success:hover { background: var(--success); border-color: var(--success); }

.btn--ghost {
  background: transparent;
  border-color: var(--border);
}

.btn--link {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 4px 8px;
  text-decoration: underline;
}
.btn--link:hover { color: var(--accent-hover); background: transparent; }

/* --- Segmented control (replaces mutually-exclusive button groups) --- */
.seg {
  display: inline-flex;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
  gap: 2px;
}
.seg button {
  background: transparent;
  border: none;
  color: var(--fg-muted);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.85em;
  font-family: inherit;
  transition: all var(--dur) var(--ease);
}
.seg button:hover { color: var(--fg-bright); }
.seg button[aria-pressed="true"],
.seg button.active {
  background: var(--accent);
  color: var(--bush-green-dark);
  font-weight: 600;
}

/* --- Cards (accordion pattern) --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin: 16px 0;
  overflow: hidden;
}
.accordion-header,
button.accordion-header {
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: inherit;
  font-family: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  text-align: left;
}
.accordion-header h2,
.accordion-header h3 {
  font-size: 1.15em;
  color: var(--fg-bright);
  font-weight: 600;
}
.accordion-header .toggle-icon {
  color: var(--fg-muted);
  font-size: 1.1em;
  transition: transform var(--dur) var(--ease);
}
.accordion-header[aria-expanded="false"] .toggle-icon,
.accordion-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}
.accordion-body { padding: 16px 20px; }
.accordion-body.collapsed,
.accordion-body[hidden] { display: none; }

/* --- Save bar --- */
.save-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-raised);
  border-top: 1px solid var(--border-strong);
  padding: 10px 20px;
  display: none;
  justify-content: center;
  align-items: center;
  gap: 12px;
  z-index: 100;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
}
.save-bar.visible { display: flex; }
.save-bar .save-bar-label {
  color: var(--fg-muted);       /* neutral — let the button carry colour */
  font-size: 0.9em;
}
.save-bar .save-btn {
  background: var(--success-dark);
  color: var(--paper);
  border: none;
  padding: 10px 28px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: background var(--dur) var(--ease);
}
.save-bar .save-btn:hover { background: var(--success); }
.save-bar .reset-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 16px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 0.85em;
}

/* --- Toast --- */
.toast {
  position: fixed;
  top: 20px; right: 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--fg-bright);
  border-radius: var(--r-md);
  padding: 14px 20px;
  z-index: 3000;
  font-size: 0.9em;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger-bright); }
.toast.warning { border-color: var(--warning); color: var(--warning); }

/* --- Modal / dialog (WCAG role="dialog" aria-modal="true") --- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  padding: 24px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  position: relative;
}
.modal-close {
  position: absolute;
  top: 12px; right: 12px;
  background: transparent;
  border: none;
  color: var(--fg-muted);
  font-size: 1.5em;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--surface-alt); color: var(--fg-bright); }

/* --- Status dots (with accessible label requirement) --- */
.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
}
.dot.green  { background: var(--success); box-shadow: 0 0 6px rgba(63, 185, 80, 0.53); }
.dot.red    { background: var(--danger);  box-shadow: 0 0 6px rgba(218, 54, 51, 0.53); }
.dot.yellow { background: var(--warning); box-shadow: 0 0 6px rgba(210, 153, 34, 0.53); }
.dot.grey   { background: var(--fg-faint); }

/* --- Reclassify pill groups (used in nightsky-index modal) --- */
.pill-group {
  margin: 10px 0;
}
.pill-group-label {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--fg-muted);
  margin-bottom: 6px;
  display: block;
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* --- Auth bar (3-column flex header pattern) --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 40px;
  background: linear-gradient(135deg, var(--bg-raised) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
}
.site-header .header-logo {
  height: 80px;
  width: auto;
  filter: brightness(1.1);
}
.site-header .header-title {
  flex: 1;
  text-align: center;
}
.site-header .header-title h1 {
  font-size: 2em;
  color: var(--fg-bright);
  margin-bottom: 4px;
}
.site-header .header-title p {
  color: var(--fg-muted);
  font-size: 1em;
}
.site-header .auth-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* --- Responsive --- */
@media (max-width: 720px) {
  .site-header { flex-direction: column; padding: 16px; gap: 12px; }
  .site-header .header-logo { height: 50px; }
  .site-header .header-title h1 { font-size: 1.5em; }
  .site-nav { gap: 14px; font-size: 0.85em; }
}
