/* -----------------------------------------------------------------
   Ruig — Obsidian dark theme
   Volcanic-glass palette: deep black with violet streaks.
----------------------------------------------------------------- */

:root {
  --bg-base:       #0c0c0e;
  --bg-aurora-1:   rgba(124, 58, 237, 0.10);
  --bg-aurora-2:   rgba(252, 76, 2, 0.05);
  --bg-surface:    #15151b;
  --bg-elevated:   #1c1c25;
  --bg-input:      #101015;
  --bg-snippet:    #0f0f14;

  --border:        #26262e;
  --border-strong: #34343f;
  --border-focus:  #6d4ed1;

  --text-primary:   #e8e8ec;
  --text-secondary: #b6b6c0;
  --text-muted:     #7a7a87;

  --accent:        #a78bfa;
  --accent-2:      #7c3aed;
  --accent-glow:   rgba(167, 139, 250, 0.18);

  --strava:        #fc4c02;
  --strava-soft:   rgba(252, 76, 2, 0.18);

  --success:       #4ade80;
  --danger:        #f87171;

  --gh-0: #26262e;
  --gh-1: #4c1d95;
  --gh-2: #7c3aed;
  --gh-3: #a78bfa;
  --gh-4: #c4b5fd;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset,
                 0 8px 24px -12px rgba(0, 0, 0, 0.6),
                 0 2px 8px -2px rgba(0, 0, 0, 0.4);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", "Consolas",
               "Roboto Mono", monospace;
}

/* -------------------- Reset / base -------------------- */

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-base);
  background-image:
    radial-gradient(900px 500px at 12% -10%, var(--bg-aurora-1), transparent 60%),
    radial-gradient(700px 400px at 95% 100%, var(--bg-aurora-2), transparent 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease, color 120ms ease;
}

a:hover {
  color: #c4b5fd;
  border-bottom-color: currentColor;
}

::selection {
  background: var(--accent-glow);
  color: var(--text-primary);
}

/* -------------------- Layout -------------------- */

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 64px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.page-wide {
  max-width: 760px;
}

/* -------------------- Hero -------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
  padding-bottom: 8px;
}

.hero-compact {
  gap: 14px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border-bottom: none;
  color: var(--text-primary);
}

.logo:hover {
  color: var(--text-primary);
}

.logo-mark {
  display: block;
  filter: drop-shadow(0 0 12px rgba(167, 139, 250, 0.25));
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.hero-accent {
  background: linear-gradient(120deg, #c4b5fd 0%, #a78bfa 50%, #fc4c02 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero .lead {
  margin: 0;
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 50ch;
}

.hero em {
  font-style: italic;
  color: var(--text-primary);
}

.check-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-glow);
  border: 1px solid rgba(167, 139, 250, 0.35);
  display: grid;
  place-items: center;
}

/* -------------------- Card -------------------- */

.card {
  background: linear-gradient(180deg, var(--bg-surface), var(--bg-elevated));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
}

.card-head {
  margin-bottom: 18px;
}

.card-head h2,
.card-head h3 {
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.card-head h2 {
  font-size: 20px;
  font-weight: 600;
}

.card-head h3 {
  font-size: 15px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
}

.sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* -------------------- Steps -------------------- */

.steps {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 2px;
  border-bottom: 1px dashed transparent;
}

.step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

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

.step-active .step-num {
  color: var(--accent);
  border-color: rgba(167, 139, 250, 0.5);
  background: var(--accent-glow);
}

/* -------------------- Form -------------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.input-row {
  display: flex;
  align-items: stretch;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.input-row:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-prefix {
  padding: 12px 4px 12px 14px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  user-select: none;
  display: inline-flex;
  align-items: center;
}

.input-row input {
  flex: 1;
  padding: 12px 14px 12px 4px;
  background: transparent;
  border: 0;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  outline: none;
  min-width: 0;
}

.input-row input::placeholder {
  color: var(--text-muted);
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.fine {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.fine code {
  font-family: var(--font-mono);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* -------------------- Picker (swatches) -------------------- */

.picker {
  border: 0;
  padding: 0;
  margin: 4px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.picker > legend {
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}

.picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.picker-row + .picker-row {
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.picker-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  min-width: 92px;
}

.swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.swatch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease,
              transform 80ms ease;
  color: var(--text-secondary);
  font-family: inherit;
}

.swatch:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.swatch:active {
  transform: translateY(1px);
}

.swatch.is-selected {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.10);
}

.swatch-strip {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
}

.swatch-cell {
  width: 8px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.swatch-ring {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.8px solid var(--strava);
  display: inline-block;
}

.swatch-fill {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: inline-block;
}

.swatch-fill-transparent {
  /* Subtle checkerboard so users can see "transparent" at a glance. */
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.18) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255,255,255,0.18) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255,255,255,0.18) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255,255,255,0.18) 75%);
  background-size: 6px 6px;
  background-position: 0 0, 0 3px, 3px -3px, -3px 0;
  background-color: var(--bg-input);
}

.swatch-name {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.swatch-loading {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
}

.picker-inline {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.link-reset {
  background: none;
  border: 0;
  padding: 0;
  margin: 0 0 0 6px;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px dashed transparent;
  transition: border-color 120ms ease, color 120ms ease;
}

.link-reset:hover {
  color: #c4b5fd;
  border-bottom-color: currentColor;
}

/* -------------------- Buttons -------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 80ms ease, background-color 120ms ease,
              border-color 120ms ease, color 120ms ease,
              box-shadow 120ms ease;
  letter-spacing: 0.01em;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-strava {
  background: var(--strava);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 1px rgba(252, 76, 2, 0.3),
              0 8px 22px -8px rgba(252, 76, 2, 0.55);
}

.btn-strava:hover:not(:disabled) {
  background: #ff5a14;
  box-shadow: 0 0 0 1px rgba(252, 76, 2, 0.45),
              0 12px 28px -8px rgba(252, 76, 2, 0.65);
}

.btn-icon {
  flex-shrink: 0;
}

.btn-ghost {
  background: var(--bg-input);
  color: var(--text-secondary);
  border-color: var(--border);
  padding: 6px 10px;
  font-size: 12px;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.btn-ghost.btn-success {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* -------------------- Preview -------------------- */

.preview-card {
  overflow: hidden;
}

.preview-svg-wrapper {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: grid;
  place-items: center;
  overflow-x: auto;
}

.preview-svg-wrapper svg,
.preview-svg-wrapper img {
  max-width: 100%;
  height: auto;
  display: block;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-label {
  margin-right: 4px;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
}

.dot-l0 { background: var(--gh-0); border: 1px solid var(--border); }
.dot-l1 { background: var(--gh-1); }
.dot-l2 { background: var(--gh-2); }
.dot-l3 { background: var(--gh-3); }
.dot-l4 { background: var(--gh-4); }

.dot-strava {
  background: transparent;
  border: 1.5px solid var(--strava);
  box-shadow: 0 0 0 1px rgba(252, 76, 2, 0.2);
}

/* -------------------- Snippets -------------------- */

.snippet-block + .snippet-block {
  margin-top: 14px;
}

.snippet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.snippet-head label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.snippet {
  margin: 0;
  padding: 12px 14px;
  background: var(--bg-snippet);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: auto;
}

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

/* -------------------- Footer -------------------- */

.footer {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.footer a {
  color: var(--text-secondary);
}

.footer-sep {
  opacity: 0.4;
}

/* -------------------- Responsive -------------------- */

@media (max-width: 540px) {
  .page {
    padding: 40px 18px 48px;
  }

  .card {
    padding: 18px;
  }

  .legend {
    gap: 12px;
  }
}

/* -------------------- Reduced motion -------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
