/* ==========================================================================
   The Computation Society — stylesheet
   --------------------------------------------------------------------------
   Pages are generated by events.py from templates/; see README.md.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap");

/* 1. Design tokens
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Color */
  --bg: #0d0f12;
  --surface: #13171c;
  --surface-hover: #181d24;
  --text: #dfe6ec;
  --text-muted: #a9adb5;
  --text-subtle: #80868f;
  --border: #242a32;
  --border-strong: #353d48;
  --accent: #002ffe;
  --accent-hover: #2344d5;
  --accent-soft: rgba(83, 76, 223, 0.08);
  --grid-minor: rgba(83, 76, 223, 0.035);
  --grid-major: rgba(83, 76, 223, 0.07);

  /* Type */
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --fs-display: clamp(2.5rem, 1.2rem + 5.4vw, 5.75rem);
  --fs-lead: clamp(1.1875rem, 1.05rem + 0.55vw, 1.5rem);
  --fs-body: 1.0625rem;
  --fs-small: 0.9375rem;
  --fs-label: 0.75rem;

  --lh-tight: 1.02;
  --lh-snug: 1.45;
  --lh-body: 1.65;

  /* Spacing scale (4px base) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;
  --space-9: 6rem;
  --space-10: 8rem;

  /* Layout */
  --max-width: 72rem;
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --radius: 6px;
  --radius-sm: 3px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur-fast: 150ms;
  --dur: 250ms;
  --dur-reveal: 700ms;
}

/* 2. Base
   ========================================================================== */

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

html {
  background: var(--bg);
  border-top: 3px solid var(--accent);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scrollbar-color: var(--border-strong) var(--bg);
}

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  padding-block: var(--space-5) var(--space-7);
  overflow-x: hidden;

  display: grid;
  grid-template-columns:
    [full-start] minmax(var(--gutter), 1fr)
    [content-start] minmax(0, var(--max-width))
    [content-end] minmax(var(--gutter), 1fr)
    [full-end];
  align-content: start;

  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body > * {
  grid-column: content;
  position: relative;
  z-index: 1;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur-fast) var(--ease);
}

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* 3. Background texture — coordinate grid + graph structure
   ========================================================================== */

/* Fine coordinate grid that fades out below the hero */
body::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: min(52rem, 100vh);
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid-minor) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-minor) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: center -1px;
  -webkit-mask-image: radial-gradient(ellipse 85% 75% at 65% 0%, #000 25%, transparent 78%);
  mask-image: radial-gradient(ellipse 85% 75% at 65% 0%, #000 25%, transparent 78%);
}

/* A small tree/graph plotted on the grid, top right of the hero */
body::after {
  content: "";
  position: absolute;
  top: clamp(var(--space-7), 6vw, var(--space-9));
  right: max(var(--gutter), calc((100% - var(--max-width)) / 2));
  width: clamp(15rem, 28vw, 24rem);
  aspect-ratio: 1;
  z-index: 0;
  pointer-events: none;
  background: var(--accent);
  opacity: 0.5;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 384' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M288 48 L216 120 M288 48 L336 144 M216 120 L144 192 M216 120 L264 216 M144 192 L72 288 M144 192 L192 312 M336 144 L360 240'/%3E%3Cpath d='M264 216 L360 240 M72 288 L192 312' stroke-dasharray='3 5'/%3E%3Ccircle cx='288' cy='48' r='7'/%3E%3Cg fill='black' stroke='none'%3E%3Ccircle cx='216' cy='120' r='4'/%3E%3Ccircle cx='336' cy='144' r='4'/%3E%3Ccircle cx='144' cy='192' r='4'/%3E%3Ccircle cx='264' cy='216' r='4'/%3E%3Ccircle cx='72' cy='288' r='3'/%3E%3Ccircle cx='192' cy='312' r='3'/%3E%3Ccircle cx='360' cy='240' r='3'/%3E%3Ccircle cx='288' cy='48' r='2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 384 384' fill='none' stroke='black' stroke-width='1.4'%3E%3Cpath d='M288 48 L216 120 M288 48 L336 144 M216 120 L144 192 M216 120 L264 216 M144 192 L72 288 M144 192 L192 312 M336 144 L360 240'/%3E%3Cpath d='M264 216 L360 240 M72 288 L192 312' stroke-dasharray='3 5'/%3E%3Ccircle cx='288' cy='48' r='7'/%3E%3Cg fill='black' stroke='none'%3E%3Ccircle cx='216' cy='120' r='4'/%3E%3Ccircle cx='336' cy='144' r='4'/%3E%3Ccircle cx='144' cy='192' r='4'/%3E%3Ccircle cx='264' cy='216' r='4'/%3E%3Ccircle cx='72' cy='288' r='3'/%3E%3Ccircle cx='192' cy='312' r='3'/%3E%3Ccircle cx='360' cy='240' r='3'/%3E%3Ccircle cx='288' cy='48' r='2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

/* 4. Header, navigation and footer
   ========================================================================== */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  margin-bottom: clamp(var(--space-7), 9vw, var(--space-9));
  border-bottom: 1px solid var(--border);
}

.brand {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.site-nav {
  display: flex;
  gap: var(--space-2);
}

.site-footer {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-8);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* 5. Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 2.75rem;
  padding: var(--space-2) var(--space-5);

  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;

  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease),
    background-color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

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

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

.btn-ghost {
  min-height: 2.25rem;
  padding-inline: var(--space-4);
  color: var(--text-muted);
}

.btn-ghost:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-ghost.is-current {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.btn-small {
  min-height: 2.25rem;
  padding-inline: var(--space-4);
  align-self: flex-start;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-6);
}

/* 6. Hero
   ========================================================================== */

.hero {
  margin-bottom: clamp(var(--space-8), 8vw, var(--space-9));
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-6);

  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* Small accent square marker before the label */
.eyebrow::before {
  content: "";
  width: var(--space-2);
  height: var(--space-2);
  background: var(--accent);
}

.hero h1 {
  max-width: 15ch;
  margin: 0;
  font-size: var(--fs-display);
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: -0.035em;
  color: var(--text);
  text-wrap: balance;
}

.hero-compact {
  margin-bottom: var(--space-8);
}

/* Measurement ruler under the heading */
.ruler {
  height: 11px;
  margin-top: clamp(var(--space-6), 5vw, var(--space-8));
  border-bottom: 1px solid var(--border-strong);
  background:
    repeating-linear-gradient(90deg, var(--text-subtle) 0 1px, transparent 1px 120px) left bottom / 100% 11px no-repeat,
    repeating-linear-gradient(90deg, var(--border-strong) 0 1px, transparent 1px 24px) left bottom / 100% 5px no-repeat;
  transform-origin: left center;
}

/* 7. Sections
   ========================================================================== */

.section {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--space-5);
  row-gap: var(--space-5);
  margin-bottom: var(--space-8);
  scroll-margin-top: var(--space-6);
}

.section-label {
  grid-column: 1 / span 3;
  margin: 0;
  padding-top: 0.55em;

  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.lead {
  grid-column: 4 / span 8;
  max-width: 38ch;
  margin: 0 0 var(--space-6);

  font-size: var(--fs-lead);
  line-height: var(--lh-snug);
  letter-spacing: -0.01em;
  color: var(--text);
  text-wrap: pretty;
}

/* 8. Cards
   ========================================================================== */

.cards {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-5);
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-6);

  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--fs-small);
  line-height: var(--lh-body);
  text-wrap: pretty;

  transition:
    transform var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.card p {
  margin: 0;
}

.card-label {
  padding-bottom: var(--space-4);
  border-bottom: 1px dashed var(--border-strong);

  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
  transition: color var(--dur) var(--ease);
}

/* Registration mark in the corner, like a technical drawing */
.card::after,
.event::after {
  content: "";
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  width: 9px;
  height: 9px;
  border-top: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong);
  transition: border-color var(--dur) var(--ease);
}

.card:hover,
.event:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

.card:hover::after,
.event:hover::after {
  border-color: var(--accent);
}

.card:hover .card-label {
  color: var(--text-muted);
}

/* Featured card — the next meeting */
.card-featured {
  background:
    linear-gradient(var(--accent-soft), var(--accent-soft)),
    var(--surface);
  border-color: rgba(76, 107, 233, 0.28);
  box-shadow: inset 0 2px 0 var(--accent);
  color: var(--text);
}

.card-featured .card-label,
.card-featured:hover .card-label {
  color: var(--accent);
  border-bottom-color: rgba(76, 100, 233, 0.3);
}

.card-featured::after {
  border-color: var(--accent);
}

.card-featured:hover {
  background:
    linear-gradient(rgba(76, 94, 233, 0.12), rgba(76, 107, 233, 0.12)),
    var(--surface-hover);
  border-color: rgba(76, 107, 233, 0.45);
}

.card-featured .btn {
  margin-top: auto;
}

/* 9. Events
   ========================================================================== */

.event-list {
  grid-column: 4 / span 9;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.event {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);

  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  transition:
    transform var(--dur) var(--ease),
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.event-date {
  font-family: var(--font-mono);
  font-size: var(--fs-label);
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.event-title {
  margin: 0;
  font-size: 1.375rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}

.event-description {
  margin: 0;
  max-width: 60ch;
  font-size: var(--fs-small);
  color: var(--text-muted);
}

.event-past {
  border-left-color: var(--border-strong);
}

.event-past .event-date {
  color: var(--text-subtle);
}

.event-past .event-title {
  color: var(--text-muted);
}

.empty {
  margin: 0;
  padding: var(--space-5) var(--space-6);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-subtle);
  font-size: var(--fs-small);
}

/* 10. Motion — load reveal
   ========================================================================== */

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

@keyframes fade {
  from { opacity: 0; }
}

@keyframes draw {
  from { transform: scaleX(0); }
}

body::before,
body::after {
  animation: fade 1200ms var(--ease) both;
}

.eyebrow       { animation: reveal var(--dur-reveal) var(--ease) both; }
.hero h1       { animation: reveal var(--dur-reveal) var(--ease) 60ms both; }
.button-row    { animation: reveal var(--dur-reveal) var(--ease) 160ms both; }
.ruler         { animation: draw 1100ms var(--ease) 250ms both; }
.section-label,
.lead          { animation: reveal var(--dur-reveal) var(--ease) 300ms both; }
.card,
.event,
.empty         { animation: reveal var(--dur-reveal) var(--ease) 420ms both; }
.card:nth-child(2),
.event:nth-child(2) { animation-delay: 500ms; }
.card:nth-child(3),
.event:nth-child(n + 3) { animation-delay: 580ms; }

/* 11. Responsive
   ========================================================================== */

/* ≤ 1199px — slightly tighter section gutters */
@media (max-width: 74.9375em) {
  .section,
  .cards {
    column-gap: var(--space-4);
    row-gap: var(--space-4);
  }
}

/* ≤ 991px — two-column cards, featured card spans full width */
@media (max-width: 61.9375em) {
  .section-label {
    grid-column: 1 / -1;
    padding-top: 0;
  }

  .lead,
  .event-list {
    grid-column: 1 / -1;
  }

  .lead {
    max-width: 34ch;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-featured {
    grid-column: 1 / -1;
  }

  body::after {
    opacity: 0.32;
  }
}

/* ≤ 767px — single column, graph removed so it never sits behind text */
@media (max-width: 47.9375em) {
  :root {
    --fs-body: 1rem;
  }

  body::after {
    display: none;
  }

  body::before {
    background-size: 96px 96px, 96px 96px, 24px 24px, 24px 24px;
    -webkit-mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 75%);
    mask-image: radial-gradient(ellipse 120% 80% at 50% 0%, #000 20%, transparent 75%);
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
  }

  .card,
  .event {
    padding: var(--space-5);
  }

  .lead {
    margin-bottom: var(--space-4);
  }
}

/* ≤ 479px — small phones */
@media (max-width: 29.9375em) {
  .hero h1 {
    letter-spacing: -0.03em;
  }

  .eyebrow {
    margin-bottom: var(--space-5);
    letter-spacing: 0.08em;
  }

  .ruler {
    background-size: 100% 9px, 100% 4px;
    height: 9px;
  }

  .lead {
    max-width: none;
  }

  .button-row .btn {
    flex: 1 1 auto;
  }
}

/* 12. Accessibility preferences
   ========================================================================== */

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

  .card:hover,
  .event:hover,
  .btn:hover {
    transform: none;
  }
}

@media (forced-colors: active) {
  body::before,
  body::after,
  .ruler {
    display: none;
  }

  .card,
  .event,
  .btn {
    border: 1px solid CanvasText;
  }
}
