/*
  static/css/home.css
  Maskset home page — oscilloscope / PCB phosphor theme.

  All rules are scoped to body.td-home or .ms-* classes.
  Nothing here affects blog posts, docs pages, or any other template.
  Injected only on the home page via layouts/partials/hooks/head-end.html.
*/

/* ── DESIGN TOKENS ───────────────────────────────────────────────── */
body.td-home {
  --bg:        #080c08;
  --bg2:       #0d120d;
  --bg3:       #111811;
  --panel:     #0c110c;
  --border:    rgba(0, 220, 80, .13);
  --border2:   rgba(0, 220, 80, .22);
  --green:     #00dc50;
  --green-dim: #00a038;
  --green-lo:  rgba(0, 220, 80, .06);
  --amber:     #e8a020;
  --amber-dim: rgba(232, 160, 32, .65);
  --text:      #b8d4b8;
  --text-dim:  #618061;
  --text-hi:   #d8f0d8;
  --mono:      'IBM Plex Mono', 'Courier New', monospace;
  --sans:      'IBM Plex Sans', system-ui, sans-serif;
  --glow:      0 0 12px rgba(0, 220, 80, .25), 0 0 40px rgba(0, 220, 80, .08);
  --glow-sm:   0 0 6px rgba(0, 220, 80, .2);
}

/* ── PAGE SHELL ──────────────────────────────────────────────────── */
body.td-home {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
  cursor: crosshair;
}

/* PCB grid */
body.td-home::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 220, 80, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 220, 80, .025) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Vignette */
body.td-home::after {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, .7) 100%);
  pointer-events: none;
  z-index: 0;
}

/* Scanlines overlay div (injected by body-begin hook) */
body.td-home .ms-scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, .08) 2px,
    rgba(0, 0, 0, .08) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* ── DOCSY CHROME OVERRIDES ──────────────────────────────────────── */

/* Strip Bootstrap/Docsy wrapper padding so full-bleed sections work */
body.td-home .td-outer,
body.td-home .td-default {
  background: transparent;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}

/* <main> element — remove Bootstrap row/col padding */
body.td-home main.td-main {
  background: transparent;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  width: 100% !important;
}

/* Navbar */
body.td-home .td-navbar {
  background: rgba(8, 12, 8, .94) !important;
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 200;
}

body.td-home .td-navbar .navbar-brand {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--green) !important;
  text-shadow: var(--glow-sm);
  letter-spacing: -.02em;
}

/* Pulsing dot before brand name */
body.td-home .td-navbar .navbar-brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  margin-right: .55rem;
  vertical-align: middle;
  box-shadow: 0 0 8px var(--green), 0 0 20px rgba(0, 220, 80, .4);
  animation: ms-pulse 2.5s ease-in-out infinite;
}

body.td-home .td-navbar .nav-link {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim) !important;
  border-radius: 0;
  padding: .4rem .85rem !important;
  border-right: 1px solid var(--border);
  transition: color .14s, background .14s;
}
body.td-home .td-navbar .nav-link:first-of-type { border-left: 1px solid var(--border); }
body.td-home .td-navbar .nav-link:hover,
body.td-home .td-navbar .nav-link.active {
  color: var(--green) !important;
  background: var(--green-lo);
}

body.td-home .td-search-input {
  background: rgba(0, 220, 80, .05);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 2px;
  font-family: var(--mono);
  font-size: .78rem;
}
body.td-home .td-search-input::placeholder { color: var(--text-dim); }
body.td-home .td-search-input:focus { border-color: var(--green-dim); outline: none; }

/* Footer */
body.td-home .td-footer {
  background: rgba(4, 8, 4, .97);
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  position: relative;
  z-index: 2;
}
body.td-home .td-footer a { color: var(--text-dim); transition: color .12s; }
body.td-home .td-footer a:hover { color: var(--green); }

/* ── LAYOUT SHELL ────────────────────────────────────────────────── */
.ms-shell {
  position: relative;
  z-index: 2;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ── HERO ────────────────────────────────────────────────────────── */
.ms-hero {
  padding: 5rem 0 4rem;
  position: relative;
  overflow: hidden;
}

.ms-hero__trace {
  position: absolute;
  top: 50%;
  left: -5%;
  width: 110%;
  height: 130px;
  transform: translateY(-50%);
  color: var(--green);
  opacity: .17;
  pointer-events: none;
}

.ms-hero__inner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 3rem;
  animation: ms-fadein .6s ease both;
}

.ms-hero__label {
  font-size: .68rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--green-dim);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.ms-hero__label::before {
  content: '';
  display: block;
  width: 24px;
  height: 1px;
  background: var(--green-dim);
}

.ms-hero__title {
  font-family: var(--mono);
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  font-weight: 600;
  color: var(--green);
  line-height: 1.05;
  letter-spacing: -.03em;
  text-shadow: var(--glow);
  margin-bottom: 1.25rem;
}
.ms-hero__title em {
  font-style: normal;
  color: var(--text-hi);
  font-weight: 300;
}

.ms-hero__desc {
  font-family: var(--sans);
  font-size: .95rem;
  font-weight: 300;
  color: var(--text-dim);
  max-width: 480px;
  line-height: 1.75;
  border-left: 2px solid var(--border2);
  padding-left: 1rem;
  margin-bottom: 2rem;
}

.ms-hero__actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}

/* Buttons */
.ms-btn {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-decoration: none;
  padding: .55rem 1.25rem;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  transition: all .18s;
}
.ms-btn--primary {
  background: var(--green);
  color: #050a05;
  border: 1px solid var(--green);
  box-shadow: var(--glow-sm);
}
.ms-btn--primary:hover {
  background: #00ff60;
  color: #020602;
  box-shadow: var(--glow);
  transform: translateY(-1px);
  text-decoration: none;
}
.ms-btn--ghost {
  background: transparent;
  color: var(--green-dim);
  border: 1px solid var(--border2);
}
.ms-btn--ghost:hover {
  color: var(--green);
  background: var(--green-lo);
  border-color: var(--green-dim);
  text-decoration: none;
}

/* Hero stats */
.ms-hero__stats {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  text-align: right;
  animation: ms-fadein .6s ease .15s both;
}
.ms-stat__num {
  font-size: 2rem;
  font-weight: 600;
  color: var(--green);
  line-height: 1;
  text-shadow: var(--glow-sm);
}
.ms-stat__label {
  font-size: .65rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: .2rem;
}

/* ── DIVIDER ─────────────────────────────────────────────────────── */
.ms-rule {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border2) 20%, var(--border2) 80%, transparent);
  position: relative;
  z-index: 2;
}

/* ── PAGE AREA ───────────────────────────────────────────────────── */
.ms-page { padding-bottom: 4rem; }

/* ── SECTION HEADERS ─────────────────────────────────────────────── */
.ms-section { margin-bottom: .5rem; }

.ms-section__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-top: 2.5rem;
}
.ms-section__title {
  font-size: .7rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
  white-space: nowrap;
  margin: 0;
}
.ms-section__line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border2), transparent);
  display: block;
}
.ms-section__more {
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  text-decoration: none;
  white-space: nowrap;
  transition: color .12s;
}
.ms-section__more:hover { color: var(--green); }

/* ── PRODUCTS GRID ───────────────────────────────────────────────── */
.ms-products {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 2.5rem;
  animation: ms-fadein .5s ease .2s both;
}

.ms-product {
  background: var(--panel);
  padding: 1.5rem 1.5rem 2.25rem;
  text-decoration: none;
  display: block;
  position: relative;
  overflow: hidden;
  transition: background .18s;
}
.ms-product::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: var(--green-dim);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .25s;
}
.ms-product:hover,
.ms-product:focus { background: var(--bg3); text-decoration: none; }
.ms-product:hover::before { transform: scaleX(1); }

.ms-product__tag {
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--amber-dim);
  margin-bottom: .6rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.ms-product__tag::before { content: '◆'; font-size: .5rem; color: var(--amber); }

.ms-product__title {
  font-family: var(--mono);
  font-size: .95rem;
  font-weight: 600;
  color: var(--text-hi);
  line-height: 1.3;
  margin-bottom: .55rem;
}
.ms-product__desc {
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--text-dim);
  line-height: 1.6;
  margin: 0;
}
.ms-product__arrow {
  position: absolute;
  bottom: 1rem;
  right: 1.25rem;
  font-size: .8rem;
  color: var(--green-dim);
  opacity: 0;
  transform: translateX(-4px);
  transition: all .2s;
}
.ms-product:hover .ms-product__arrow { opacity: 1; transform: translateX(0); }

/* ── TWO-COLUMN FEED ─────────────────────────────────────────────── */
.ms-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2.5rem;
  animation: ms-fadein .5s ease .3s both;
}

/* ── POST LISTS ──────────────────────────────────────────────────── */
.ms-list {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: ms-item;
}
.ms-list__item {
  border-bottom: 1px solid var(--border);
  counter-increment: ms-item;
}
.ms-list__item a {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  padding: .7rem 0;
  text-decoration: none;
  transition: padding-left .15s;
}
.ms-list__item a::before {
  content: counter(ms-item, decimal-leading-zero);
  font-size: .63rem;
  color: var(--text-dim);
  opacity: .45;
  flex-shrink: 0;
  width: 1.5rem;
  font-weight: 300;
}
.ms-list__item a:hover { padding-left: .45rem; text-decoration: none; }
.ms-list__item a:hover .ms-list__title { color: var(--green); }

.ms-list__title {
  font-size: .88rem;
  color: var(--text);
  font-weight: 400;
  line-height: 1.35;
  flex: 1;
  transition: color .14s;
}
.ms-list__cat {
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: .6;
  flex-shrink: 0;
}

/* ── CATEGORY STRIP ──────────────────────────────────────────────── */
.ms-cats {
  display: flex;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 3rem;
  flex-wrap: wrap;
}
.ms-cat {
  flex: 1;
  min-width: 120px;
  background: var(--panel);
  padding: 1.25rem 1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .75rem;
  transition: background .15s;
}
.ms-cat:hover { background: var(--bg3); text-decoration: none; }
.ms-cat:hover .ms-cat__label { color: var(--green); }
.ms-cat__icon { font-size: 1.1rem; width: 2rem; text-align: center; opacity: .7; }
.ms-cat__label {
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 600;
  transition: color .14s;
}

/* ── TERMINAL BLOCK ──────────────────────────────────────────────── */
.ms-terminal {
  background: #040804;
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 3rem;
}
.ms-terminal__bar {
  font-size: .55rem;
  letter-spacing: .5rem;
  color: var(--text-dim);
  opacity: .3;
  display: block;
  margin-bottom: .75rem;
}
.ms-terminal__line {
  font-size: .82rem;
  line-height: 1.9;
  color: var(--text-dim);
  font-family: var(--mono);
}
.ms-t-prompt  { color: var(--green-dim); }
.ms-t-cmd     { color: var(--text-hi); }
.ms-t-dim     { color: var(--text-dim); opacity: .75; }
.ms-t-hi      { color: var(--green); }
.ms-t-amber   { color: var(--amber); }
.ms-t-link    { color: var(--green-dim); text-decoration: none; transition: color .12s; }
.ms-t-link:hover { color: var(--green); }

.ms-cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--green);
  vertical-align: middle;
  animation: ms-blink .9s step-end infinite;
  box-shadow: var(--glow-sm);
}

/* ── KEYFRAMES ───────────────────────────────────────────────────── */
@keyframes ms-fadein {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes ms-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px var(--green), 0 0 20px rgba(0, 220, 80, .4); }
  50%      { opacity: .55; box-shadow: 0 0 4px var(--green); }
}
@keyframes ms-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}


/* ══════════════════════════════════════════════════════════════════
   LIGHT / DARK MODE
   Docsy's theme switcher sets data-bs-theme="light"|"dark" on <html>.
   "auto" inherits from the OS via the media query fallback below.
   The existing dark tokens are the default (dark-first design).
   ══════════════════════════════════════════════════════════════════ */

/* ── LIGHT MODE TOKENS ───────────────────────────────────────────── */
[data-bs-theme="light"] body.td-home {
  --bg:        #f0f4f0;
  --bg2:       #e6ede6;
  --bg3:       #dce6dc;
  --panel:     #eaf1ea;
  --border:    rgba(0, 130, 40, .18);
  --border2:   rgba(0, 130, 40, .32);
  --green:     #007a28;
  --green-dim: #005a1c;
  --green-lo:  rgba(0, 130, 40, .08);
  --amber:     #9a5c00;
  --amber-dim: rgba(154, 92, 0, .7);
  --text:      #1a2e1a;
  --text-dim:  #4a6e4a;
  --text-hi:   #0d1a0d;
  --glow:      0 0 10px rgba(0, 130, 40, .2), 0 0 30px rgba(0, 130, 40, .06);
  --glow-sm:   0 0 5px rgba(0, 130, 40, .18);
}

/* PCB grid — lighter dots in light mode */
[data-bs-theme="light"] body.td-home::before {
  background-image:
    linear-gradient(rgba(0, 130, 40, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 130, 40, .08) 1px, transparent 1px);
}

/* Vignette — subtle warm tint instead of black */
[data-bs-theme="light"] body.td-home::after {
  background: radial-gradient(ellipse at center, transparent 50%, rgba(200, 220, 200, .5) 100%);
}

/* Scanlines — barely visible in light mode */
[data-bs-theme="light"] body.td-home .ms-scanlines {
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, .025) 2px,
    rgba(0, 0, 0, .025) 4px
  );
}

/* Navbar in light mode */
[data-bs-theme="light"] body.td-home .td-navbar {
  background: rgba(235, 245, 235, .95) !important;
  border-bottom: 1px solid var(--border);
}

[data-bs-theme="light"] body.td-home .td-navbar .navbar-brand {
  color: var(--green) !important;
  text-shadow: none;
}

[data-bs-theme="light"] body.td-home .td-navbar .navbar-brand::before {
  box-shadow: 0 0 6px var(--green);
}

[data-bs-theme="light"] body.td-home .td-navbar .nav-link {
  color: var(--text-dim) !important;
  border-color: var(--border);
}
[data-bs-theme="light"] body.td-home .td-navbar .nav-link:hover,
[data-bs-theme="light"] body.td-home .td-navbar .nav-link.active {
  color: var(--green) !important;
}

[data-bs-theme="light"] body.td-home .td-search-input {
  background: rgba(0, 130, 40, .05);
  border-color: var(--border2);
  color: var(--text);
}

/* Hero trace — use the green token so it recolors automatically */
[data-bs-theme="light"] body.td-home .ms-hero__trace {
  opacity: .2;
}

/* Products / panels need an explicit background in light mode */
[data-bs-theme="light"] .ms-products {
  background: var(--border);
  border-color: var(--border);
}
[data-bs-theme="light"] .ms-product {
  background: var(--panel);
}
[data-bs-theme="light"] .ms-product:hover { background: var(--bg3); }

[data-bs-theme="light"] .ms-cats {
  background: var(--border);
  border-color: var(--border);
}
[data-bs-theme="light"] .ms-cat { background: var(--panel); }
[data-bs-theme="light"] .ms-cat:hover { background: var(--bg3); }

/* Terminal — paper-white look */
[data-bs-theme="light"] .ms-terminal {
  background: #f8fdf8;
  border-color: var(--border2);
}

/* Footer */
[data-bs-theme="light"] body.td-home .td-footer {
  background: rgba(220, 235, 220, .98);
  border-top: 1px solid var(--border);
}

/* Primary button stays readable in light */
[data-bs-theme="light"] .ms-btn--primary {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: var(--glow-sm);
}
[data-bs-theme="light"] .ms-btn--primary:hover {
  background: var(--green-dim);
  color: #fff;
}

/* ── OS-LEVEL FALLBACK (auto mode) ───────────────────────────────── */
/* When data-bs-theme="auto" or is absent, follow the OS preference  */
@media (prefers-color-scheme: light) {
  :not([data-bs-theme="dark"]) body.td-home {
    --bg:        #f0f4f0;
    --bg2:       #e6ede6;
    --bg3:       #dce6dc;
    --panel:     #eaf1ea;
    --border:    rgba(0, 130, 40, .18);
    --border2:   rgba(0, 130, 40, .32);
    --green:     #007a28;
    --green-dim: #005a1c;
    --green-lo:  rgba(0, 130, 40, .08);
    --amber:     #9a5c00;
    --amber-dim: rgba(154, 92, 0, .7);
    --text:      #1a2e1a;
    --text-dim:  #4a6e4a;
    --text-hi:   #0d1a0d;
    --glow:      0 0 10px rgba(0, 130, 40, .2), 0 0 30px rgba(0, 130, 40, .06);
    --glow-sm:   0 0 5px rgba(0, 130, 40, .18);
  }
}

/* ── RESPONSIVE ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .ms-two-col { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 760px) {
  .ms-hero__inner { grid-template-columns: 1fr; }
  .ms-hero__stats { flex-direction: row; text-align: left; gap: 2rem; }
  .ms-hero__title { font-size: 2rem; }
  .ms-shell { padding: 0 1rem; }
  .ms-products { grid-template-columns: 1fr; }
  .ms-cats { flex-direction: column; }
  .ms-cat { min-width: unset; }
}
