@import url("https://fonts.googleapis.com/css2?family=Chivo:wght@400;500;700;900&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Chivo+Mono:wght@400;500&display=swap");

/* ==========================================================================
   DITHERSMITH
   Forge-dark product system. One gold hue, quantized into visible pixels.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. TOKENS
   -------------------------------------------------------------------------- */

:root {
  color-scheme: dark;

  /* Color */
  --color-bg: #0a0a08;
  --color-surface: #141410;
  --color-surface-raised: #1d1c16;
  --color-border: #2a2921;
  --color-border-strong: #4a4839;

  --color-primary: #edd150;
  --color-primary-hover: #f8e071;
  --color-primary-deep: #6a5813;
  --color-on-primary: #0a0a08;

  --color-on-surface: #f4f2e8;
  --color-on-surface-muted: #96927c;

  --color-focus: #fff35c;
  --color-error: #f5325b;
  --color-error-deep: #5c0c1e;

  /* Type */
  --font-ui: "Chivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Chivo Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --tracking-tight: -0.03em;
  --tracking-snug: -0.02em;
  --tracking-normal: 0em;

  /* Space (8px base) */
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-xxxl: 64px;
  --space-section: 112px;
  --space-section-tight: 56px;

  /* Structure */
  --container: 1120px;
  --gutter: 24px;
  --hairline: 1px;

  /* Radius: two values only. Structure is square, actions are round. */
  --rounded-none: 0px;
  --rounded-full: 999px;

  /* Depth */
  --shadow-hairline: inset 0 0 0 1px var(--color-border);
  --glow-gold: 0 0 0 1px rgba(237, 209, 80, 0.9), 0 6px 24px -8px rgba(237, 209, 80, 0.55);
  --glow-gold-strong: 0 0 0 1px rgba(248, 224, 113, 0.95), 0 10px 34px -8px rgba(237, 209, 80, 0.72);
  --glow-error: 0 0 0 1px rgba(245, 50, 91, 0.9), 0 6px 24px -8px rgba(245, 50, 91, 0.5);

  /* Raster */
  --dither-cell-lg: 8px;
  --dither-cell-sm: 4px;
  --dither-ramp-h: 192px;
  --dither-ink: var(--color-primary);
  --dither-ink-far: var(--color-primary-deep);

  --dith-25: conic-gradient(var(--dither-ink) 25%, #0000 0);
  --dith-50: conic-gradient(var(--dither-ink) 25%, #0000 0 50%, var(--dither-ink) 0 75%, #0000 0);
  --dith-75: conic-gradient(var(--dither-ink) 75%, #0000 0);
  --dith-100: linear-gradient(var(--dither-ink) 0 100%);
  --dith-25-far: conic-gradient(var(--dither-ink-far) 25%, #0000 0);
}

/* --------------------------------------------------------------------------
   2. BASE
   -------------------------------------------------------------------------- */

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

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

body {
  margin: 0;
  background-color: var(--color-bg);
  color: var(--color-on-surface);
  font-family: var(--font-ui);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

::selection {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

a {
  color: var(--color-on-surface);
  text-decoration-color: var(--color-border-strong);
  text-underline-offset: 4px;
}

a:hover {
  text-decoration-color: var(--color-primary);
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY
   -------------------------------------------------------------------------- */

h1,
h2,
h3,
h4,
p,
figure,
ul,
ol {
  margin: 0;
}

.display,
h1,
h2,
h3,
h4 {
  font-family: var(--font-ui);
  font-weight: 900;
  letter-spacing: var(--tracking-tight);
  color: var(--color-on-surface);
  text-wrap: balance;
}

.display {
  font-size: clamp(3.25rem, 8vw, 5.75rem);
  line-height: 0.95;
}

h1,
.headline-lg {
  font-size: clamp(2.5rem, 5vw, 3.75rem);
  line-height: 1;
}

h2,
.headline-md {
  font-size: clamp(1.875rem, 3.2vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: var(--tracking-snug);
}

h3,
.headline-sm {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: var(--tracking-snug);
}

h4,
.title-sm {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: var(--tracking-snug);
}

.lede {
  font-size: 1.125rem;
  line-height: 1.6;
  color: var(--color-on-surface-muted);
  max-width: 62ch;
}

.body-md {
  font-size: 1rem;
  line-height: 1.65;
}

.body-sm {
  font-size: 0.9375rem;
  line-height: 1.6;
}

.muted {
  color: var(--color-on-surface-muted);
}

.label {
  display: block;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: var(--tracking-normal);
  color: var(--color-on-surface);
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-normal);
}

.figure-lg {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 500;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: var(--color-on-surface);
}

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

/* --------------------------------------------------------------------------
   4. LAYOUT
   -------------------------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section {
  padding-block: var(--space-section);
}

.section--tight {
  padding-block: var(--space-xxxl);
}

.section + .section {
  border-top: var(--hairline) solid var(--color-border);
}

.bleed {
  width: 100vw;
  margin-left: calc(50% - 50vw);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  align-items: flex-start;
}

.stack--lg {
  gap: var(--space-lg);
}

.stack--center {
  align-items: center;
  text-align: center;
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--space-lg);
}

.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-12 { grid-column: span 12; }

.rule {
  height: var(--hairline);
  border: 0;
  margin: 0;
  background: var(--color-border);
}

.measure {
  max-width: 62ch;
}

/* Faint alignment grid for large empty surfaces. Never on text blocks. */
.grid-veil {
  background-image:
    linear-gradient(to right, rgba(150, 146, 124, 0.07) 1px, #0000 1px),
    linear-gradient(to bottom, rgba(150, 146, 124, 0.07) 1px, #0000 1px);
  background-size: 32px 32px;
}

/* --------------------------------------------------------------------------
   5. THE DITHER RAMP  (signature element)
   Fixed 8px cells. Row density steps 1/4 -> 1/2 -> 3/4 -> solid, interleaved
   so the raster reads as an ordered dither and never as a smooth gradient.
   -------------------------------------------------------------------------- */

.dither-ramp {
  height: var(--dither-ramp-h);
  background-image:
    var(--dith-25-far), var(--dith-25-far), var(--dith-25-far), var(--dith-25),
    var(--dith-25), var(--dith-25), var(--dith-50), var(--dith-25),
    var(--dith-50), var(--dith-50), var(--dith-75), var(--dith-50),
    var(--dith-75), var(--dith-75), var(--dith-100), var(--dith-75),
    var(--dith-100);
  background-size:
    8px 8px, 8px 8px, 8px 8px, 8px 8px, 8px 8px, 8px 8px,
    8px 8px, 8px 8px, 8px 8px, 8px 8px, 8px 8px, 8px 8px,
    8px 8px, 8px 8px, 8px 8px, 8px 8px, 8px 8px;
  background-repeat: repeat-x;
  background-position:
    4px 8px, 0 32px, 4px 56px, 0 72px,
    4px 88px, 0 96px, 4px 104px, 0 112px,
    4px 120px, 0 128px, 4px 136px, 0 144px,
    4px 152px, 0 160px, 0 168px, 4px 176px,
    0 184px;
}

.dither-ramp--void {
  --dither-ink: var(--color-bg);
  --dither-ink-far: var(--color-bg);
}

.dither-ramp--deep {
  --dither-ink: var(--color-primary-deep);
  --dither-ink-far: var(--color-primary-deep);
}

/* Full-bleed band: ramp on top, solid gold below. One per screen. */
.dither-band {
  position: relative;
  height: auto;
  min-height: 360px;
}

.dither-band::after {
  content: "";
  position: absolute;
  inset: var(--dither-ramp-h) 0 0 0;
  background: var(--dither-ink);
}

.dither-band--flip {
  transform: scaleY(-1);
}

/* Uniform raster fills, 4px cells. */
.dither-fill {
  background-image: var(--dith-75);
  background-size: var(--dither-cell-sm) var(--dither-cell-sm);
}

.dither-veil {
  background-image: var(--dith-50);
  background-size: var(--dither-cell-sm) var(--dither-cell-sm);
}

/* --------------------------------------------------------------------------
   6. CORNER BRACKETS
   -------------------------------------------------------------------------- */

.bracketed {
  position: relative;
}

.bracketed::before,
.bracketed::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-primary);
  pointer-events: none;
}

.bracketed::before {
  top: -8px;
  left: -8px;
  border-right: 0;
  border-bottom: 0;
}

.bracketed::after {
  right: -8px;
  bottom: -8px;
  border-left: 0;
  border-top: 0;
}

/* --------------------------------------------------------------------------
   7. BUTTONS
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  height: 48px;
  padding-inline: var(--space-lg);
  border: var(--hairline) solid transparent;
  border-radius: var(--rounded-full);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: var(--tracking-snug);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 120ms linear, color 120ms linear,
    border-color 120ms linear, box-shadow 120ms linear;
}

.btn .icon {
  order: 2;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-on-primary);
  box-shadow: var(--glow-gold);
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--glow-gold-strong);
}

.btn--primary:active {
  background: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(237, 209, 80, 0.9);
}

.btn--secondary {
  background: transparent;
  color: var(--color-on-surface);
  border-color: var(--color-border-strong);
}

.btn--secondary:hover {
  background: var(--color-surface);
  border-color: var(--color-on-surface-muted);
}

.btn--ghost {
  background: transparent;
  color: var(--color-on-surface-muted);
  padding-inline: var(--space-md);
}

.btn--ghost:hover {
  color: var(--color-on-surface);
}

.btn--danger {
  background: var(--color-error);
  color: var(--color-on-primary);
  box-shadow: var(--glow-error);
}

.btn--danger:hover {
  background: #ff5478;
}

.btn--lg {
  height: 56px;
  padding-inline: var(--space-xl);
  font-size: 1rem;
}

.btn--sm {
  height: 38px;
  padding-inline: var(--space-md);
  font-size: 0.875rem;
}

.btn--icon {
  width: 44px;
  height: 44px;
  padding: 0;
  justify-content: center;
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon--sm { width: 16px; height: 16px; }
.icon--lg { width: 24px; height: 24px; }

/* --------------------------------------------------------------------------
   8. NAVIGATION
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding-block: var(--space-lg);
}

.nav__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  font-weight: 900;
  font-size: 1.0625rem;
  letter-spacing: var(--tracking-tight);
  color: var(--color-on-surface);
  text-decoration: none;
}

.nav__brand svg,
.nav__brand img {
  width: 60px;
  height: 60px;
}

.nav__brand svg {
  color: var(--color-primary);
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--space-xxs);
  list-style: none;
  padding: 0;
  margin: 0;
}

.nav__link {
  display: inline-block;
  padding: 8px 16px;
  border-radius: var(--rounded-full);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-on-surface-muted);
  text-decoration: none;
  transition: color 120ms linear, background-color 120ms linear;
}

.nav__link:hover,
.nav__link[aria-current="page"] {
  color: var(--color-on-surface);
  background: var(--color-surface);
}

/* --------------------------------------------------------------------------
   9. FORM FIELDS
   -------------------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  width: 100%;
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 14px var(--space-md);
  background: var(--color-surface);
  color: var(--color-on-surface);
  border: var(--hairline) solid var(--color-border);
  border-radius: var(--rounded-none);
  font-family: var(--font-ui);
  font-size: 1rem;
  line-height: 1.4;
  transition: border-color 120ms linear, box-shadow 120ms linear;
}

.textarea {
  min-height: 132px;
  resize: vertical;
}

.select {
  padding-right: var(--space-sm);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--color-on-surface-muted);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: inset 0 -2px 0 0 var(--color-primary);
}

.input:focus-visible,
.textarea:focus-visible,
.select:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.hint {
  font-size: 0.875rem;
  color: var(--color-on-surface-muted);
}

.field--error .input,
.field--error .textarea,
.field--error .select {
  border-color: var(--color-error);
}

.field--error .hint {
  color: var(--color-error);
}

/* Checkbox */

.check {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-sm);
  cursor: pointer;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.check input {
  position: absolute;
  opacity: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
}

.check__box {
  position: relative;
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  border: var(--hairline) solid var(--color-border-strong);
  border-radius: var(--rounded-none);
  background-color: var(--color-surface);
  background-size: var(--dither-cell-sm) var(--dither-cell-sm);
  color: var(--color-on-primary);
  display: grid;
  place-items: center;
}

.check__box .icon {
  width: 14px;
  height: 14px;
  stroke-width: 3;
  opacity: 0;
}

.check input:checked + .check__box {
  border-color: var(--color-primary);
  background-image: var(--dith-75);
}

.check input:checked + .check__box .icon {
  opacity: 1;
}

.check input:focus-visible + .check__box {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   10. SURFACES
   -------------------------------------------------------------------------- */

.card {
  position: relative;
  padding: var(--space-xl);
  background: var(--color-surface);
  border: var(--hairline) solid var(--color-border);
  border-radius: var(--rounded-none);
}

.card--raised {
  background: var(--color-surface-raised);
}

.card--featured {
  border-color: transparent;
  padding-bottom: var(--space-xxxl);
}

.card__wash {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 96px;
  background-image: var(--dith-25), var(--dith-50), var(--dith-75), var(--dith-100);
  background-size: 8px 8px, 8px 8px, 8px 8px, 8px 8px;
  background-repeat: repeat-x;
  background-position: 4px 56px, 0 72px, 4px 80px, 0 88px;
  pointer-events: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  height: 30px;
  padding-inline: var(--space-sm);
  border: var(--hairline) solid var(--color-border-strong);
  border-radius: var(--rounded-full);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-on-surface-muted);
  font-variant-numeric: tabular-nums;
}

.chip--active {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.chip--error {
  border-color: var(--color-error);
  color: var(--color-error);
}

.code {
  padding: var(--space-lg);
  background: var(--color-surface);
  border: var(--hairline) solid var(--color-border);
  border-radius: var(--rounded-none);
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  line-height: 1.7;
  color: var(--color-on-surface);
  overflow-x: auto;
  white-space: pre;
}

.code .tok-key { color: var(--color-primary); }
.code .tok-muted { color: var(--color-on-surface-muted); }

/* --------------------------------------------------------------------------
   11. TABS
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: var(--hairline) solid var(--color-border);
}

.tab {
  position: relative;
  padding: var(--space-sm) var(--space-lg);
  background: none;
  border: 0;
  border-radius: var(--rounded-none);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-on-surface-muted);
  cursor: pointer;
  transition: color 120ms linear;
}

.tab:hover {
  color: var(--color-on-surface);
}

.tab[aria-selected="true"] {
  color: var(--color-on-surface);
  font-weight: 700;
}

.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--color-primary);
}

.tab[aria-selected="true"]::before {
  content: "";
  position: absolute;
  left: 100%;
  bottom: -1px;
  width: 48px;
  height: 2px;
  background-image: var(--dith-50);
  background-size: var(--dither-cell-sm) var(--dither-cell-sm);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   12. TABLE
   -------------------------------------------------------------------------- */

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table th {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  font-weight: 500;
  color: var(--color-on-surface-muted);
  border-bottom: var(--hairline) solid var(--color-border);
}

.table td {
  padding: var(--space-md);
  border-bottom: var(--hairline) solid var(--color-border);
  color: var(--color-on-surface);
}

.table .num,
.table th.num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   13. METER
   -------------------------------------------------------------------------- */

.meter {
  width: 100%;
  height: 12px;
  background: var(--color-surface-raised);
  border: var(--hairline) solid var(--color-border);
  border-radius: var(--rounded-none);
  overflow: hidden;
}

.meter__fill {
  height: 100%;
  background-image: var(--dith-75);
  background-size: var(--dither-cell-sm) var(--dither-cell-sm);
}

/* --------------------------------------------------------------------------
   14. MEDIA
   Duotone: grayscale image multiplied over a gold plate, then eaten away
   at the bottom edge by a void dither ramp.
   -------------------------------------------------------------------------- */

.media {
  position: relative;
  margin: 0;
  background: var(--color-primary);
  border-radius: var(--rounded-none);
  overflow: hidden;
  isolation: isolate;
}

.media__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: grayscale(1) contrast(1.15) brightness(1.05);
  mix-blend-mode: multiply;
}

.media__dissolve {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   15. RESPONSIVE
   -------------------------------------------------------------------------- */

@media (max-width: 900px) {
  :root {
    --space-section: var(--space-section-tight);
    --gutter: 20px;
  }

  .col-3,
  .col-4,
  .col-5,
  .col-6,
  .col-7,
  .col-8 {
    grid-column: span 12;
  }

  .nav__links {
    display: none;
  }

  .card {
    padding: var(--space-lg);
  }

  .dither-band {
    min-height: 280px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
