/* ========================================================================
   GateKeepr — design tokens
   A dark editorial aesthetic with a purple accent.
   Serif display (Fraunces) paired with a clean sans (Public Sans).

   Light / dark is controlled by a `data-theme` attribute on <html>.
   Default is dark; adding data-theme="light" swaps the token values.
   ======================================================================== */

:root,
:root[data-theme="dark"] {
  --bg: #0e0d13;
  --bg-alt: #15131c;
  --bg-card: #1c1927;
  --ink: #ece8f5;
  --ink-dim: #9c95b3;
  --ink-faint: #6b6580;
  --accent: #a78bfa;          /* bright readable purple */
  --accent-bright: #c4b5fd;   /* hover/active */
  --accent-soft: #8b5cf6;     /* slightly deeper for buttons on light bg */
  --rule: #28243a;
  --rule-bright: #3b3554;
  --btn-primary-ink: #0e0d13; /* text color on filled purple button */
  --shadow-accent: rgba(167, 139, 250, 0.4);
  --grain-blend: overlay;
  --grain-opacity: 0.04;
}

:root[data-theme="light"] {
  --bg: #faf8ff;
  --bg-alt: #f3eefd;
  --bg-card: #ffffff;
  --ink: #1a1524;
  --ink-dim: #544d6b;
  --ink-faint: #8a839c;
  --accent: #6d28d9;          /* deeper purple for light bg readability */
  --accent-bright: #5b21b6;   /* hover */
  --accent-soft: #7c3aed;
  --rule: #e4dcf5;
  --rule-bright: #c9bae6;
  --btn-primary-ink: #ffffff;
  --shadow-accent: rgba(109, 40, 217, 0.25);
  --grain-blend: multiply;
  --grain-opacity: 0.035;
}

:root {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "Public Sans", -apple-system, "Segoe UI", sans-serif;

  --max: 1200px;
  --gutter: clamp(1.25rem, 4vw, 3rem);
}

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

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  width: 100%;
}

/* Decorative subtle grain overlay */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  mix-blend-mode: var(--grain-blend);
}

/* ========================================================================
   Links & inline
   ======================================================================== */

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-bright);
}

code, pre {
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.92em;
}

code {
  background: var(--bg-card);
  padding: 0.15em 0.45em;
  border-radius: 3px;
  color: var(--accent);
  border: 1px solid var(--rule);
  word-break: break-word;
  overflow-wrap: break-word;
}

pre {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1rem 0;
  line-height: 1.5;
  font-size: 0.88rem;
  max-width: 100%;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink);
  white-space: pre;
  word-break: normal;
}

em {
  font-style: italic;
  color: var(--accent);
}

/* ========================================================================
   Nav
   ======================================================================== */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem var(--gutter);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule);
  gap: 1rem;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  font-variation-settings: "SOFT" 50, "WONK" 0;
  flex-shrink: 0;
}

.nav__mark {
  color: var(--accent);
  font-size: 1.3rem;
  line-height: 1;
}

.nav__links {
  display: flex;
  gap: 2rem;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  align-items: center;
}

.nav__links a {
  color: var(--ink-dim);
  font-weight: 500;
  white-space: nowrap;
}

.nav__links a:hover {
  color: var(--ink);
}

@media (max-width: 720px) {
  .nav {
    padding: 1rem var(--gutter);
  }
  .nav__brand {
    font-size: 1rem;
  }
  .nav__mark {
    font-size: 1.15rem;
  }
  .nav__links {
    gap: 1.25rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .nav__brand {
    font-size: 0.95rem;
    gap: 0.45rem;
  }
  .nav__links {
    gap: 1rem;
    font-size: 0.8rem;
  }
  .nav__links a {
    /* Shorten "Admin Setup" wouldn't fit; let's hide About on very narrow screens */
  }
}

@media (max-width: 380px) {
  /* On the smallest phones, drop the About link to save space */
  .nav__links a[href*="about"] {
    display: none;
  }
}

/* Theme toggle button */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--rule-bright);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-dim);
  transition: all 0.25s ease;
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(15deg);
}

.theme-toggle__sun,
.theme-toggle__moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: inline;
}
:root[data-theme="light"] .theme-toggle__moon {
  display: inline;
}

@media (max-width: 420px) {
  .theme-toggle {
    width: 32px;
    height: 32px;
  }
}

/* ========================================================================
   Hero
   ======================================================================== */

.hero {
  position: relative;
  padding: clamp(4rem, 12vw, 9rem) var(--gutter) clamp(6rem, 14vw, 11rem);
  max-width: var(--max);
  margin: 0 auto;
  overflow: hidden;
}

.hero__eyebrow {
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: fade-up 0.8s ease both;
}

.hero__eyebrow::before {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.75rem, 8vw, 6.5rem);
  line-height: 0.98;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 2rem;
  font-variation-settings: "SOFT" 30, "WONK" 0, "opsz" 144;
  animation: fade-up 1s 0.1s ease both;
  max-width: 20ch;
}

.hero__title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
}

.hero__lede {
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
  line-height: 1.55;
  color: var(--ink-dim);
  max-width: 34rem;
  margin-bottom: 3rem;
  animation: fade-up 1s 0.25s ease both;
}

.hero__cta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  animation: fade-up 1s 0.4s ease both;
}

@media (max-width: 520px) {
  .hero__cta {
    flex-direction: column;
    align-items: stretch;
  }
  .hero__cta .btn {
    justify-content: center;
  }
}

.hero__pillars {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  height: 140px;
  opacity: 0.25;
  pointer-events: none;
}

.pillar {
  width: 3px;
  background: linear-gradient(to top, var(--accent) 0%, transparent 100%);
  border-radius: 2px;
  animation: pillar-rise 1.4s ease both;
}

.pillar:nth-child(1) { height: 60%; animation-delay: 0.2s; }
.pillar:nth-child(2) { height: 85%; animation-delay: 0.35s; }
.pillar:nth-child(3) { height: 100%; animation-delay: 0.5s; }
.pillar:nth-child(4) { height: 85%; animation-delay: 0.65s; }
.pillar:nth-child(5) { height: 60%; animation-delay: 0.8s; }

@keyframes pillar-rise {
  from { transform: scaleY(0); transform-origin: bottom; }
  to { transform: scaleY(1); transform-origin: bottom; }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(1.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========================================================================
   Buttons
   ======================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn--primary {
  background: var(--accent);
  color: var(--btn-primary-ink);
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  color: var(--btn-primary-ink);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -8px var(--shadow-accent);
}

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

.btn--ghost:hover {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--accent);
}

.btn--large {
  padding: 1.1rem 2rem;
  font-size: 1rem;
}

.btn__arrow {
  display: inline-block;
  transition: transform 0.25s ease;
}

.btn:hover .btn__arrow {
  transform: translateX(4px);
}

/* ========================================================================
   Sections
   ======================================================================== */

.section {
  padding: clamp(4rem, 10vw, 8rem) var(--gutter);
  max-width: var(--max);
  margin: 0 auto;
  position: relative;
}

.section--dark {
  background: var(--bg-alt);
  max-width: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

.section--dark > * {
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
}

.section__label {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section__label::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: var(--accent);
  opacity: 0.6;
}

.section__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.1;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin-bottom: 3rem;
  max-width: 22ch;
  font-variation-settings: "SOFT" 40, "opsz" 100;
}

.section__title--wide {
  max-width: 30ch;
}

/* ========================================================================
   About
   ======================================================================== */

.about {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

@media (max-width: 768px) {
  .about {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

.about__body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  color: var(--ink-dim);
  font-size: 1.05rem;
  line-height: 1.7;
}

.about__body code {
  color: var(--accent);
}

/* ========================================================================
   Features
   ======================================================================== */

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.feature {
  background: var(--bg-alt);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  transition: background 0.3s ease;
}

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

.feature__num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.8rem;
  color: var(--accent);
  margin-bottom: 1rem;
  font-variation-settings: "SOFT" 100, "WONK" 1;
}

.feature__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--ink);
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
}

.feature p {
  color: var(--ink-dim);
  font-size: 0.98rem;
  line-height: 1.6;
}

/* ========================================================================
   CTA
   ======================================================================== */

.cta {
  padding: clamp(5rem, 12vw, 10rem) var(--gutter);
  max-width: var(--max);
  margin: 0 auto;
  text-align: center;
}

.cta__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1.5rem;
  font-variation-settings: "SOFT" 60, "WONK" 1, "opsz" 144;
}

.cta__lede {
  font-size: 1.1rem;
  color: var(--ink-dim);
  max-width: 32rem;
  margin: 0 auto 3rem;
  line-height: 1.6;
}

.cta__actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

@media (max-width: 520px) {
  .cta__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .cta__actions .btn {
    justify-content: center;
  }
}

/* ========================================================================
   Footer
   ======================================================================== */

.footer {
  padding: 2.5rem var(--gutter);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  color: var(--ink-faint);
  font-size: 0.88rem;
  max-width: var(--max);
  margin: 0 auto;
}

.footer__mark {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--ink-dim);
}

.footer__meta {
  display: flex;
  gap: 2rem;
  letter-spacing: 0.02em;
}

@media (max-width: 640px) {
  .footer__meta {
    gap: 1rem;
  }
}

/* ========================================================================
   Setup page
   ======================================================================== */

.setup-page {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 6rem) var(--gutter);
}

.setup-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-dim);
  font-size: 0.88rem;
  margin-bottom: 3rem;
  letter-spacing: 0.02em;
}

.setup-back:hover {
  color: var(--accent);
}

.setup-page h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin-bottom: 1.5rem;
  font-variation-settings: "SOFT" 40, "opsz" 144;
}

.setup-page h1 em {
  font-style: italic;
  color: var(--accent);
  font-variation-settings: "SOFT" 100, "WONK" 1, "opsz" 144;
}

.setup-page .setup-lede {
  font-size: 1.15rem;
  color: var(--ink-dim);
  line-height: 1.6;
  margin-bottom: 3rem;
}

.setup-page h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.85rem;
  line-height: 1.2;
  color: var(--ink);
  margin-top: 3.5rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
  letter-spacing: -0.01em;
}

.setup-page h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.3;
  color: var(--ink);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.005em;
}

.setup-page p {
  margin: 1rem 0;
  color: var(--ink-dim);
  line-height: 1.7;
}

.setup-page strong {
  color: var(--ink);
  font-weight: 600;
}

.setup-page ul, .setup-page ol {
  margin: 1rem 0 1.5rem;
  padding-left: 1.5rem;
  color: var(--ink-dim);
  line-height: 1.7;
}

.setup-page li {
  margin-bottom: 0.5rem;
}

.setup-page li::marker {
  color: var(--accent);
}

.setup-page table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0 2rem;
  font-size: 0.95rem;
  border: 1px solid var(--rule);
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 640px) {
  .setup-page table {
    display: table;
    overflow-x: visible;
  }
}

.setup-page th, .setup-page td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}

.setup-page th {
  background: var(--bg-alt);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--rule-bright);
}

.setup-page td {
  color: var(--ink-dim);
}

.setup-page tr:last-child td {
  border-bottom: none;
}

.setup-page hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 3rem 0;
}

.setup-page .callout {
  margin: 1.5rem 0;
  padding: 1rem 1.25rem;
  background: var(--bg-alt);
  border-left: 3px solid var(--accent);
  border-radius: 2px;
  font-size: 0.95rem;
  color: var(--ink-dim);
}

.setup-page .callout strong {
  color: var(--accent);
}

.setup-page .toc {
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  padding: 1.5rem 2rem;
  border-radius: 2px;
  margin: 2rem 0 3rem;
}

.setup-page .toc-title {
  font-family: var(--font-body);
  font-size: 0.78rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  font-weight: 600;
}

.setup-page .toc ol {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.95rem;
}

.setup-page .toc li {
  margin-bottom: 0.35rem;
}

.setup-page .toc a {
  color: var(--ink-dim);
}

.setup-page .toc a:hover {
  color: var(--accent);
}
