/* Bitstream Hackers — shared site styles
   Palette/type roughly matched to saintcon.org's community pages. */

@import url("https://fonts.googleapis.com/css2?family=Aldrich&family=Armata&display=swap");

:root {
  --space-black: #0c1116;
  --space-deep: #141b24;
  --space-navy: #1e3034;
  --space-ink: #224968;
  --space-slate: #45767c;
  --space-divider: #587d80;

  --cream: #f3e5c3;
  --cream-soft: #f7e9c1;
  --cream-dim: #d9cba1;

  --ignition: #f8781e;
  --signal: #f9c401;
  --glow-cyan: #73e5f1;

  --bg: var(--space-black);
  --surface: var(--space-deep);
  --surface-2: var(--space-navy);
  --text: var(--cream);
  --text-dim: var(--cream-dim);
  --link: var(--ignition);
  --link-hover: var(--signal);
  --border: var(--space-slate);

  --font-display: "Aldrich", system-ui, -apple-system, sans-serif;
  --font-body: "Armata", system-ui, -apple-system, sans-serif;

  --radius: 6px;
  --radius-lg: 14px;
  --max-width: 1100px;
  --gutter: clamp(16px, 4vw, 40px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(115, 229, 241, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(248, 120, 30, 0.06), transparent 60%);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--cream-soft);
  margin: 1.1em 0 0.5em;
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.1; }
h2 { font-size: clamp(1.4rem, 3.4vw, 2rem); line-height: 1.2; }
h3 { font-size: clamp(1.1rem, 2.6vw, 1.4rem); }

p { margin: 0 0 1em; color: var(--text); }

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
a:hover { color: var(--link-hover); border-bottom-color: currentColor; }
a:focus-visible {
  outline: 2px solid var(--glow-cyan);
  outline-offset: 3px;
  border-radius: 2px;
}

img { max-width: 100%; display: block; }

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ---- Header / nav ---- */

.site-header {
  border-bottom: 1px solid var(--surface-2);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(6px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: none;
}
.brand:hover { border-bottom: none; }

.brand img {
  height: 44px;
  width: auto;
}

.brand-text {
  font-family: var(--font-display);
  color: var(--cream-soft);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.brand-text small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

nav.site-nav ul {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
}

nav.site-nav a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--text-dim);
  border-bottom: none;
  font-size: 0.92rem;
}

nav.site-nav a:hover,
nav.site-nav a[aria-current="page"] {
  color: var(--cream-soft);
  background: var(--surface-2);
  border-bottom: none;
}

nav.site-nav span.soon {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--space-divider);
  font-size: 0.92rem;
  cursor: default;
}

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

.hero {
  position: relative;
  padding: 56px 0 40px;
  overflow: hidden;
  border-bottom: 1px solid var(--surface-2);
}

.hero .inner {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  align-items: center;
}

.hero .copy { max-width: 60ch; }

.hero .eyebrow {
  font-family: var(--font-display);
  color: var(--ignition);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  margin-bottom: 0.6em;
}

.hero .subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  max-width: 55ch;
}

.hero .logo-art img {
  max-height: 260px;
  width: auto;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.5));
}

@media (max-width: 760px) {
  .hero .inner {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .hero .logo-art { order: -1; max-width: 180px; }
}

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

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  border: 1px solid var(--ignition);
  color: var(--cream-soft) !important;
  background: color-mix(in srgb, var(--ignition) 16%, transparent);
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn:hover {
  background: var(--ignition);
  color: var(--space-black) !important;
  border-color: var(--ignition);
}

/* ---- Cards / tier grid ---- */

.tier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin: 2em 0;
}

.tier-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-left: 4px solid var(--tier-color, var(--ignition));
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tier-card .tier-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--tier-color, var(--ignition));
}

.tier-card h3 { margin: 0; }

.tier-card p { color: var(--text-dim); margin: 0; }

.tier-card .prize {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--surface-2);
  font-size: 0.85rem;
  color: var(--cream-dim);
}

.tier-card.locked {
  opacity: 0.6;
}

.tier-card .status-chip {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
}

/* ---- Prose sections ---- */

.section {
  padding: 44px 0;
}

.section + .section {
  border-top: 1px solid var(--surface-2);
}

.prose :is(h2, h3)[id] { scroll-margin-top: 90px; }

.callout {
  margin: 1.4em 0;
  padding: 16px 20px;
  border-left: 4px solid var(--glow-cyan);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--glow-cyan) 8%, var(--space-deep));
}
.callout strong { color: var(--cream-soft); }

.callout.warn {
  border-left-color: var(--signal);
  background: color-mix(in srgb, var(--signal) 8%, var(--space-deep));
}

/* ---- Inline code in content ---- */

.prose code {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 0.92em;
  color: var(--signal);
  background: var(--surface-2);
  padding: 0.05em 0.35em;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

.prose pre.code-block {
  margin: 1em 0 1.4em;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
}
.prose pre.code-block code {
  background: none;
  padding: 0;
  color: var(--cream-soft);
  overflow-wrap: normal;
}

/* ---- Step list ---- */

.steps {
  list-style: none;
  counter-reset: step;
  margin: 1.6em 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.steps li {
  counter-increment: step;
  position: relative;
  padding-left: 52px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  padding-top: 16px;
  padding-bottom: 16px;
  padding-right: 20px;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 16px;
  font-family: var(--font-display);
  color: var(--space-black);
  background: var(--signal);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.steps h4 {
  margin: 0 0 6px;
  color: var(--cream-soft);
  font-family: var(--font-body);
  font-weight: 700;
}

.steps p:last-child { margin-bottom: 0; }

/* Photos inside a step (minibadge build guide). Capped so a lone photo
   doesn't stretch across the page; two sit side by side when they fit. */
.step-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 460px));
  gap: 12px;
  margin: 12px 0 0;
}
.step-photos.wide { grid-template-columns: minmax(0, 720px); }
/* Side-view solder joint diagrams: three small panels in a row. */
.step-photos.joints { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.step-photos svg.joint {
  display: block;
  width: 100%;
  height: auto;
  background: var(--space-ink);  /* not black: the part's body is black */
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
}
.step-photos figure { margin: 0; }
.step-photos img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--surface-2);
}
.step-photos figcaption {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--text-dim);
}

/* ---- Gear grid (photos) ---- */

.gear-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin: 1.6em 0;
}

.gear-card {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.gear-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #fff;
}

/* Portrait board render: show the whole board, don't crop to 4:3. */
.gear-card img.board-render {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 600px;
  aspect-ratio: auto;
  object-fit: contain;
  margin: 0 auto;
}

.gear-card figcaption {
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.gear-card figcaption strong {
  display: block;
  color: var(--cream-soft);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 0.85rem;
  margin-bottom: 2px;
}

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

.site-footer {
  border-top: 1px solid var(--surface-2);
  padding: 30px 0 50px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

.site-footer .prompt {
  font-family: "SFMono-Regular", Menlo, Monaco, ui-monospace, monospace;
  color: var(--glow-cyan);
}

/* ---- Worked-example swatches (palette/indexed color explainer) ---- */

.example-block {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  align-items: flex-start;
  margin: 1.6em 0;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(4, 28px);
  grid-template-rows: repeat(4, 28px);
  gap: 2px;
  flex-shrink: 0;
  border-radius: var(--radius);
  overflow: hidden;
}

.example-grid span {
  display: block;
}

.example-formats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  font-family: "SFMono-Regular", Menlo, Monaco, ui-monospace, monospace;
  font-size: 0.85rem;
}

.example-formats h4 {
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--cream-soft);
  font-size: 0.85rem;
}

.example-formats .bytes {
  color: var(--text-dim);
  line-height: 1.7;
}

.example-formats .bytes b {
  color: var(--signal);
  font-weight: 700;
}

/* ---- Protocol sub-pages: pin tables, history notes, timing diagrams ---- */

.protocol-hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 1.2em;
}

.protocol-hero-links a {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-dim);
  border-bottom: none;
  font-size: 0.85rem;
}
.protocol-hero-links a:hover,
.protocol-hero-links a[aria-current="page"] {
  color: var(--cream-soft);
  background: color-mix(in srgb, var(--ignition) 20%, var(--surface-2));
  border-bottom: none;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.4em 0;
  font-size: 0.92rem;
  background: var(--surface);
  border-radius: var(--radius);
  /* No overflow:hidden here on purpose — cells have no background of their
     own to clip (the table's own background already respects the radius),
     and clipping would also cut off any tooltip popup that opens from a
     button in the last row, which is exactly what GND's was hitting. */
}
table.data-table caption {
  caption-side: top;
  text-align: left;
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 9px 14px;
  border-bottom: 1px solid var(--surface-2);
}
table.data-table th {
  font-family: var(--font-display);
  font-weight: 400;
  color: var(--cream-soft);
  background: var(--surface-2);
  font-size: 0.82rem;
  letter-spacing: 0.03em;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table td code { color: var(--signal); }

.history-note {
  margin: 1.4em 0;
  padding: 16px 20px;
  border-left: 4px solid var(--space-divider);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--space-divider) 10%, var(--space-deep));
}
.history-note strong { color: var(--cream-soft); }

figure.diagram {
  margin: 1.8em 0;
  padding: 18px 18px 14px;
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius-lg);
}
figure.diagram svg {
  width: 100%;
  height: auto;
  display: block;
  color: var(--text-dim);
  font-family: "SFMono-Regular", Menlo, Monaco, ui-monospace, monospace;
}
figure.diagram figcaption {
  margin-top: 12px;
  font-size: 0.85rem;
  color: var(--text-dim);
  border-top: 1px dashed var(--surface-2);
  padding-top: 10px;
}
figure.diagram figcaption strong { color: var(--cream-soft); }

.spec-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 1.4em 0;
}
.spec-strip .spec {
  background: var(--surface);
  border: 1px solid var(--surface-2);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 0.85rem;
}
.spec-strip .spec b {
  display: block;
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 400;
  margin-bottom: 2px;
}

/* ---- Photo-coming-soon placeholder (no image, honest empty box) ---- */

.gear-card .photo-pending {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
}
.gear-card .photo-pending span {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ---- Glossary term tooltips: tap/click, not hover-only (works on mobile) ---- */

.term {
  all: unset;
  display: inline;
  position: relative;
  color: var(--glow-cyan);
  border-bottom: 1px dotted currentColor;
  cursor: pointer;
  font: inherit;
}
.term:hover { color: var(--signal); }
.term:focus-visible {
  outline: 2px solid var(--glow-cyan);
  outline-offset: 2px;
  border-radius: 2px;
}

.term-tip {
  display: none;
  position: absolute;
  z-index: 50;
  left: 0;
  top: calc(100% + 8px);
  width: max-content;
  max-width: 240px;
  background: var(--space-navy);
  border: 1px solid var(--space-slate);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: var(--font-body);
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--cream-soft);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}
.term[aria-expanded="true"] .term-tip { display: block; }
.term-tip strong { color: var(--signal); }
