@import "_reset.css";
@import "_typography.css";
@import "_layout.css";
@import "_pages.css";

:root {
  --typography: 222 14% 67%;
  --muted: 222 11% 45%;
  --heading: 45 29% 97%;
  --link: 45 29% 97%;
  --accent: 184 100% 41%;
  --accent-secondary: 81 79% 62%;
  --brand-start: #b4ec51;
  --brand-end: #00c6d1;
  --on-brand: #050505;
  --background: 0 0% 2%;
  --surface: 0 0% 7%;
  --line: 0 0% 18%;
  --font-sans: "Inter", sans-serif;
  --text-caption: 0.825rem;
  --text-small: 0.945rem;
  --text-body: 1.125rem;
  --text-subheading: clamp(1.275rem, 1.3vw + 0.125rem, 1.475rem);
  --text-heading: clamp(2.125rem, 4vw + 0.125rem, 3.625rem);
  --text-display: clamp(2.875rem, 6vw + 0.125rem, 5.375rem);
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --measure: 65ch;
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --typography: 225 16% 28%;
    --muted: 218 10% 38%;
    --heading: 228 28% 8%;
    --link: 228 28% 8%;
    --accent: 183 100% 23%;
    --accent-secondary: 78 100% 21%;
      --brand-start: #4b6b00;
    --brand-end: #006f75;
    --on-brand: #ffffff;
    --background: 0 0% 100%;
    --surface: 220 20% 98%;
    --line: 225 12% 82%;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --typography: 225 16% 28%;
  --muted: 218 10% 38%;
  --heading: 228 28% 8%;
  --link: 228 28% 8%;
  --accent: 183 100% 23%;
  --accent-secondary: 78 100% 21%;
  --brand-start: #4b6b00;
  --brand-end: #006f75;
  --on-brand: #ffffff;
  --background: 0 0% 100%;
  --surface: 220 20% 98%;
  --line: 225 12% 82%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --typography: 222 14% 67%;
  --muted: 218 10% 56%;
  --heading: 45 29% 97%;
  --link: 45 29% 97%;
  --accent: 184 100% 41%;
  --accent-secondary: 81 79% 62%;
  --brand-start: #b4ec51;
  --brand-end: #00c6d1;
  --on-brand: #050505;
  --background: 0 0% 2%;
  --surface: 0 0% 7%;
  --line: 0 0% 18%;
}

html {
  scroll-behavior: smooth;
}

/* Cross-document view transitions: the sidebar, footer and background stay
   put while the content cross-fades between pages. Browsers without support
   just navigate normally. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }

  .sz-sidebar { view-transition-name: sidebar; }
  .sz-footer { view-transition-name: footer; }
  .theme-control { view-transition-name: theme-control; }
  main { view-transition-name: content; }

  ::view-transition-old(content),
  ::view-transition-new(content) {
    animation-duration: 220ms;
  }
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--typography));
  -webkit-font-smoothing: antialiased;
}

button,
a { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 1rem;
  left: 1rem;
  padding: 0.65rem 0.9rem;
  color: var(--on-brand);
  background: var(--brand-start);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 700;
  transform: translateY(-200%);
}

.skip-link:focus {
  color: var(--on-brand);
  transform: translateY(0);
}

.glow-canvas {
  position: fixed;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 600ms ease;
}

body.glow-live .glow-canvas {
  opacity: 1;
}

body.glow-live .sz-sidebar::before {
  opacity: 0;
}

a {
  text-decoration: none;
  color: hsl(var(--link));
  transition: color 180ms ease;
  &:hover {
    color: hsl(var(--accent));
  }
}

main :where(p, li) a:not([class]) {
  color: hsl(var(--heading));
  text-decoration: underline;
  text-decoration-color: hsl(var(--accent) / 0.45);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

main :where(p, li) a:not([class]):hover {
  text-decoration-color: hsl(var(--accent));
}

a:focus-visible {
  outline: 2px solid hsl(var(--accent));
  outline-offset: 5px;
  border-radius: 2px;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid hsl(var(--line));
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 180ms ease, border-color 180ms ease;
}

.text-link:hover {
  color: hsl(var(--accent));
  border-color: hsl(var(--accent) / 0.55);
}

main {
  min-width: 0;
}

main:focus {
  outline: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-header {
  padding-bottom: var(--space-8);
}

.eyebrow {
  margin: 0 0 var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-caption);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--accent));
}

.page-title {
  max-width: 13ch;
  font-size: var(--text-display);
}

.page-lead {
  max-width: 45rem;
  margin-top: var(--space-5);
  font-size: clamp(1.175rem, 1.4vw + 0.125rem, 1.375rem);
  line-height: 1.5;
  color: hsl(var(--heading));
}

.page-section { padding-top: var(--space-10); }

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: var(--space-5); }
.prose :where(h2, h3) { margin-top: var(--space-10); }
.prose :where(ul, ol) { padding-left: var(--space-6); }
.prose li + li { margin-top: var(--space-2); }
.prose img { margin-block: var(--space-8); border-radius: var(--radius-sm); }
.prose blockquote { margin-block: var(--space-8); }

main > * {
  animation: reveal 450ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

main section > h2,
main > h2,
main > h3 {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 var(--space-6);
  font-family: var(--font-sans);
  font-size: 0.845rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: hsl(var(--accent));
}

main section > h2::after,
main > h2::after,
main > h3::after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, hsl(var(--accent-secondary)), hsl(var(--accent)), transparent);
}

blockquote {
  font-style: italic;
  border-left: 4px solid hsl(var(--accent));
  padding-left: 1rem;
  margin: 1rem 0;
}

.theme-control {
  position: fixed;
  z-index: 20;
  bottom: clamp(1rem, 3vh, 1.75rem);
  right: clamp(1rem, 2vw, 1.5rem);
}

.theme-control summary {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid hsl(var(--line));
  border-radius: 50%;
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
  box-shadow: 0 10px 35px hsl(var(--accent) / 0.25);
  cursor: pointer;
  list-style: none;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.theme-control summary::-webkit-details-marker {
  display: none;
}

.theme-control summary:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 42px hsl(var(--accent) / 0.38);
}

.theme-control summary:focus-visible {
  outline: 2px solid hsl(var(--heading));
  outline-offset: 4px;
}

.theme-icon {
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: inset -0.28rem -0.18rem 0 -0.12rem currentColor;
}

.theme-menu {
  position: absolute;
  top: 50%;
  right: 1.5rem;
  display: flex;
  gap: 0.2rem;
  padding: 0.28rem 1.8rem 0.28rem 0.28rem;
  border: 1px solid hsl(var(--line));
  border-radius: 999px 0 0 999px;
  background: hsl(var(--surface) / 0.96);
  box-shadow: 0 14px 40px hsl(0 0% 0% / 0.22);
  transform: translateY(-50%);
  animation: theme-menu-in 180ms ease both;
}

.theme-menu button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.48rem 0.7rem;
  font-family: var(--font-sans);
  font-size: 0.805rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: hsl(var(--muted));
  background: transparent;
  cursor: pointer;
}

.theme-menu button:hover {
  color: hsl(var(--heading));
}

.theme-menu button[aria-pressed="true"] {
  color: var(--on-brand);
  background: linear-gradient(135deg, var(--brand-start), var(--brand-end));
}

.theme-menu button:focus-visible {
  outline: 2px solid hsl(var(--accent));
  outline-offset: 1px;
}

@keyframes theme-menu-in {
  from { opacity: 0; transform: translate(0.7rem, -50%); }
  to { opacity: 1; transform: translate(0, -50%); }
}

@media (max-width: 767px) {
  body.menu-active {
    overflow: hidden;
  }

  .theme-control {
    display: none;
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
