@layer reset, tokens, base, components, layout, responsive;

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

  html {
    scroll-behavior: smooth;
  }

  body,
  h1,
  h2,
  h3,
  p,
  ul {
    margin: 0;
  }

  ul {
    padding: 0;
    list-style: none;
  }

  button,
  input {
    font: inherit;
  }

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

@layer tokens {
  :root {
    color-scheme: light;
    --cds-background: #fbfcfc;
    --cds-layer-01: #f0f4f4;
    --cds-layer-02: #e2e9e9;
    --cds-text-primary: #102126;
    --cds-text-secondary: #4b6067;
    --cds-border-subtle: #c6d1d3;
    --cds-interactive: #0f62fe;
    --cds-interactive-hover: #0043ce;
    --science-deep: #071f2a;
    --science-teal: #007d79;
    --science-teal-surface: #007d79;
    --science-teal-bright: #08a5a0;
    --science-mint: #d9f2ef;
    --control-hover-background: #d9f2ef;
    --control-hover-text: #071f2a;
    --science-blue-soft: #e8f1ff;
    --science-grid: rgba(7, 31, 42, 0.08);
    --font-sans: 'IBM Plex Sans', 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
    --page-gutter: clamp(1rem, 3vw, 3rem);
    --content-max: 94rem;
    --header-height: 4rem;
    --focus-ring: 0 0 0 3px var(--cds-background), 0 0 0 5px var(--science-teal);
  }

  [data-theme="dark"] {
    color-scheme: dark;
    --cds-background: #08181e;
    --cds-layer-01: #10262e;
    --cds-layer-02: #18343d;
    --cds-text-primary: #edf6f5;
    --cds-text-secondary: #adc0c3;
    --cds-border-subtle: #36515a;
    --cds-interactive: #78a9ff;
    --cds-interactive-hover: #a6c8ff;
    --science-deep: #020d11;
    --science-teal: #32c7bf;
    --science-teal-surface: #006b68;
    --science-teal-bright: #66e0d8;
    --science-mint: #143d3d;
    --science-blue-soft: #152d4a;
    --science-grid: rgba(237, 246, 245, 0.07);
  }
}

@layer base {
  body {
    min-width: 20rem;
    background: var(--cds-background);
    color: var(--cds-text-primary);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
  }

  body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    background-image:
      linear-gradient(var(--science-grid) 1px, transparent 1px),
      linear-gradient(90deg, var(--science-grid) 1px, transparent 1px);
    background-size: 4rem 4rem;
    content: '';
    pointer-events: none;
  }

  a {
    color: inherit;
  }

  a:hover {
    text-decoration-thickness: 2px;
    text-underline-offset: 0.22em;
  }

  :focus-visible {
    outline: 0;
    box-shadow: var(--focus-ring);
  }

  ::selection {
    background: var(--science-teal-surface);
    color: #fff;
  }

  h1,
  h2,
  h3 {
    font-weight: 400;
    text-wrap: balance;
  }

  h1 {
    max-width: 15ch;
    font-size: clamp(2.7rem, 6.2vw, 6.8rem);
    font-weight: 300;
    letter-spacing: -0.045em;
    line-height: 0.98;
  }

  h2 {
    font-size: clamp(2rem, 4vw, 4.5rem);
    font-weight: 300;
    letter-spacing: -0.035em;
    line-height: 1.04;
  }

  h3 {
    font-size: clamp(1.2rem, 2vw, 1.55rem);
    line-height: 1.25;
  }
}

@layer components {
  .skip-link {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 100;
    padding: 0.75rem 1rem;
    background: var(--cds-text-primary);
    color: var(--cds-background);
    transform: translateY(-200%);
  }

  .skip-link:focus {
    transform: translateY(0);
  }

  .eyebrow,
  .panel-index,
  .profile-banner-label,
  .section-kicker,
  .profile-label,
  .timeline-dates,
  .education-dates {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .eyebrow {
    color: var(--science-teal);
    font-weight: 500;
  }

  .button {
    display: inline-flex;
    min-height: 3rem;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    padding: 0.8rem 1rem;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
  }

  .button-primary {
    background: var(--science-teal-surface);
    color: #fff;
  }

  .button-primary:hover {
    background: var(--science-deep);
  }

  [data-theme="dark"] .button-primary:hover {
    background: var(--science-teal-bright);
    color: #021315;
  }

  .button-secondary {
    border-color: var(--cds-text-primary);
  }

  .button-secondary:hover {
    background: var(--cds-text-primary);
    color: var(--cds-background);
  }

  .button-light {
    min-width: min(100%, 22rem);
    background: #fff;
    color: #071f2a;
  }

  .button-light:hover {
    background: var(--control-hover-background);
    color: var(--control-hover-text);
  }

  .text-link-light {
    color: #fff;
    text-underline-offset: 0.25em;
  }

  .profile-banner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1rem;
    padding: 0.55rem var(--page-gutter);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    background: var(--science-teal-surface);
    color: #fff;
  }

  .profile-banner[hidden] {
    display: none;
  }

  .profile-banner a {
    font-size: 0.85rem;
  }

  .focus-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .focus-list li {
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--cds-border-subtle);
    background: var(--cds-background);
    font-family: var(--font-mono);
    font-size: 0.74rem;
  }

  .sequence-ruler {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    border-block: 1px solid rgba(255, 255, 255, 0.25);
    font-family: var(--font-mono);
    font-size: 0.72rem;
  }

  .sequence-ruler span {
    display: grid;
    min-height: 2rem;
    place-items: center;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
  }

  .access-form {
    margin-top: auto;
  }

  .access-form label {
    display: block;
    margin-bottom: 0.35rem;
    font-family: var(--font-mono);
    font-size: 0.74rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
  }

  .access-field-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .access-field-row input {
    width: 100%;
    min-height: 3.25rem;
    padding: 0 0.9rem;
    border: 0;
    border-bottom: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-family: var(--font-mono);
    text-transform: uppercase;
  }

  .access-field-row input::placeholder {
    color: rgba(255, 255, 255, 0.55);
  }

  .access-field-row input:focus {
    border-bottom-color: #fff;
    outline: 0;
  }

  .access-field-row button {
    min-width: 6.5rem;
    border: 0;
    background: #fff;
    color: #071f2a;
    cursor: pointer;
  }

  .access-field-row button:hover {
    background: var(--control-hover-background);
    color: var(--control-hover-text);
  }

  .field-help,
  .field-error {
    margin-top: 0.5rem;
    font-size: 0.78rem;
  }

  .field-help {
    color: rgba(255, 255, 255, 0.7);
  }

  .field-error {
    padding: 0.35rem 0.5rem;
    background: #fff;
    color: #a2191f;
  }

  .profile-signal {
    display: flex;
    height: 5rem;
    align-items: end;
    gap: 0.35rem;
  }

  .profile-signal span {
    width: 0.3rem;
    background: var(--science-teal-bright);
  }

  .profile-signal span:nth-child(1) { height: 30%; }
  .profile-signal span:nth-child(2) { height: 75%; }
  .profile-signal span:nth-child(3) { height: 48%; }
  .profile-signal span:nth-child(4) { height: 92%; }
  .profile-signal span:nth-child(5) { height: 58%; }
  .profile-signal span:nth-child(6) { height: 42%; }

  .evidence-card {
    display: flex;
    min-height: 18rem;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    border-top: 3px solid var(--science-teal);
    background: var(--cds-layer-01);
  }

  .evidence-card-index {
    color: var(--cds-text-secondary);
    font-family: var(--font-mono);
    font-size: 0.75rem;
  }

  .evidence-card h3 {
    max-width: 14ch;
    margin-bottom: 1rem;
  }

  .evidence-card p:last-child {
    max-width: 36ch;
    color: var(--cds-text-secondary);
  }

  .timeline-item {
    display: grid;
    grid-template-columns: minmax(10rem, 0.7fr) minmax(15rem, 1fr) minmax(18rem, 1.6fr);
    gap: 1.5rem;
    padding: 2rem 0;
    border-top: 1px solid var(--cds-border-subtle);
  }

  .timeline-item:last-child {
    border-bottom: 1px solid var(--cds-border-subtle);
  }

  .timeline-organization {
    font-weight: 600;
  }

  .timeline-role h3 {
    margin-bottom: 0.35rem;
  }

  .timeline-role p,
  .timeline-bullets {
    color: var(--cds-text-secondary);
  }

  .timeline-bullets {
    display: grid;
    gap: 0.55rem;
  }

  .timeline-bullets li {
    position: relative;
    padding-left: 1.25rem;
  }

  .timeline-bullets li::before {
    position: absolute;
    top: 0.6em;
    left: 0;
    width: 0.45rem;
    height: 0.45rem;
    background: var(--science-teal);
    content: '';
  }

  .skill-group {
    min-height: 14rem;
    padding: 1.25rem;
    background: var(--cds-layer-01);
  }

  .skill-group h3 {
    min-height: 4rem;
    margin-bottom: 2rem;
  }

  .skill-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
  }

  .skill-list li {
    padding: 0.25rem 0.5rem;
    background: var(--cds-background);
    font-family: var(--font-mono);
    font-size: 0.72rem;
  }

  .education-block {
    display: grid;
    grid-template-columns: 1.2fr auto 1fr;
    gap: 2rem;
    align-items: start;
    margin-top: 1rem;
    padding: 2rem;
    background: var(--science-blue-soft);
  }

  .education-block h3 {
    margin: 0.7rem 0 0.25rem;
  }

  .coursework-list {
    display: grid;
    gap: 0.35rem;
    color: var(--cds-text-secondary);
  }

  .coursework-list li::before {
    content: '— ';
  }

  .noscript-message {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 20;
    max-width: 24rem;
    padding: 1rem;
    background: #da1e28;
    color: #fff;
  }
}

@layer layout {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: grid;
    min-height: var(--header-height);
    grid-template-columns: auto 1fr auto;
    align-items: stretch;
    border-bottom: 1px solid rgba(255, 255, 255, 0.16);
    background: var(--science-deep);
    color: #fff;
  }

  .wordmark {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0 var(--page-gutter);
    font-weight: 500;
    text-decoration: none;
  }

  .wordmark-mark {
    display: grid;
    width: 2.4rem;
    height: 2rem;
    place-items: center;
    border: 1px solid var(--science-teal-bright);
    color: var(--science-teal-bright);
    font-family: var(--font-mono);
    font-size: 0.75rem;
  }

  .primary-nav {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
  }

  .primary-nav a,
  .theme-toggle {
    display: flex;
    min-width: 5.5rem;
    min-height: var(--header-height);
    align-items: center;
    justify-content: center;
    padding: 0 1rem;
    border: 0;
    border-left: 1px solid rgba(255, 255, 255, 0.13);
    background: transparent;
    color: #c6d1d3;
    font-size: 0.86rem;
    text-decoration: none;
  }

  .primary-nav a:hover,
  .theme-toggle:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }

  .theme-toggle {
    gap: 0.5rem;
    cursor: pointer;
  }

  .hero {
    display: grid;
    min-height: calc(100svh - var(--header-height));
    grid-template-columns: minmax(0, 2fr) minmax(20rem, 0.78fr);
    max-width: var(--content-max);
    margin: 0 auto;
    border-inline: 1px solid var(--cds-border-subtle);
  }

  .hero-copy {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2rem;
    padding: clamp(3rem, 8vw, 8rem) var(--page-gutter);
    background: color-mix(in srgb, var(--cds-background) 93%, transparent);
  }

  .hero-summary {
    max-width: 46rem;
    color: var(--cds-text-secondary);
    font-size: clamp(1.05rem, 1.8vw, 1.35rem);
    line-height: 1.55;
  }

  .hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .access-panel {
    display: flex;
    min-height: 34rem;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--science-deep);
    color: #fff;
  }

  .access-panel h2 {
    max-width: 10ch;
    font-size: clamp(2rem, 3vw, 3.5rem);
  }

  .access-panel > p:not(.panel-index) {
    max-width: 31rem;
    color: #adc0c3;
  }

  .section {
    display: grid;
    grid-template-columns: minmax(9rem, 0.35fr) minmax(0, 2.65fr);
    max-width: var(--content-max);
    margin: 0 auto;
    border-inline: 1px solid var(--cds-border-subtle);
    border-top: 1px solid var(--cds-border-subtle);
  }

  .section-kicker {
    display: flex;
    min-height: 12rem;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.5rem;
    border-right: 1px solid var(--cds-border-subtle);
    color: var(--cds-text-secondary);
  }

  .section-content {
    padding: clamp(3rem, 7vw, 7rem) var(--page-gutter);
  }

  .about-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: clamp(2rem, 6vw, 7rem);
  }

  .about-copy {
    display: grid;
    align-content: end;
    gap: 1.5rem;
    color: var(--cds-text-secondary);
    font-size: 1.08rem;
  }

  .section-heading-row {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(14rem, 0.6fr);
    gap: 2rem;
    align-items: end;
    margin-bottom: 3.5rem;
  }

  .section-heading-row > p {
    color: var(--cds-text-secondary);
  }

  .evidence-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.95fr 0.8fr;
    gap: 1px;
    background: var(--cds-border-subtle);
  }

  .skills-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--cds-border-subtle);
  }

  .contact-section {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(17rem, 0.7fr);
    gap: 3rem;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: clamp(4rem, 8vw, 8rem) var(--page-gutter);
    background: var(--science-teal-surface);
    color: #fff;
  }

  .contact-copy h2 {
    max-width: 17ch;
    margin-top: 1rem;
  }

  .contact-section .eyebrow {
    color: #fff;
  }

  .contact-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: end;
    gap: 1.25rem;
  }

  .site-footer {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 2rem var(--page-gutter);
    background: var(--science-deep);
    color: #adc0c3;
    font-family: var(--font-mono);
    font-size: 0.75rem;
  }
}

@layer responsive {
  @media (max-width: 72rem) {
    .hero {
      grid-template-columns: minmax(0, 1.55fr) minmax(18rem, 0.75fr);
    }

    .timeline-item {
      grid-template-columns: minmax(10rem, 0.7fr) minmax(0, 2fr);
    }

    .timeline-bullets {
      grid-column: 2;
    }

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

  @media (max-width: 52rem) {
    body::before {
      background-size: 2rem 2rem;
    }

    .site-header {
      grid-template-columns: 1fr auto;
    }

    .primary-nav {
      display: flex;
      grid-column: 1 / -1;
      grid-row: 2;
      justify-content: stretch;
      overflow-x: auto;
      border-top: 1px solid rgba(255, 255, 255, 0.13);
    }

    .primary-nav a {
      min-width: 0;
      flex: 1 0 auto;
    }

    .profile-banner {
      grid-template-columns: 1fr auto;
    }

    .profile-banner-label {
      display: none;
    }

    .hero {
      min-height: auto;
      grid-template-columns: 1fr;
    }

    .hero-copy {
      min-height: 42rem;
    }

    .access-panel {
      min-height: 31rem;
    }

    .section {
      grid-template-columns: 1fr;
    }

    .section-kicker {
      min-height: auto;
      flex-direction: row;
      padding: 0.85rem 1rem;
      border-right: 0;
      border-bottom: 1px solid var(--cds-border-subtle);
    }

    .about-grid,
    .section-heading-row,
    .education-block,
    .contact-section {
      grid-template-columns: 1fr;
    }

    .evidence-grid {
      grid-template-columns: 1fr;
    }

    .evidence-card {
      min-height: 14rem;
    }

    .timeline-item {
      grid-template-columns: 1fr;
      gap: 0.75rem;
    }

    .timeline-bullets {
      grid-column: auto;
      margin-top: 0.75rem;
    }

    .contact-actions {
      align-items: stretch;
    }

    .site-footer {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 34rem) {
    h1 {
      font-size: clamp(2.55rem, 13vw, 4rem);
    }

    .wordmark {
      padding-left: 1rem;
    }

    .wordmark > span:last-child,
    .theme-label {
      display: none;
    }

    .theme-toggle {
      min-width: 4rem;
    }

    .hero-copy,
    .section-content {
      padding-inline: 1rem;
    }

    .hero-actions {
      display: grid;
    }

    .button {
      width: 100%;
    }

    .focus-list li {
      flex: 1 1 calc(50% - 0.5rem);
      text-align: center;
    }

    .skills-grid {
      grid-template-columns: 1fr;
    }

    .profile-banner {
      align-items: start;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
      scroll-behavior: auto !important;
      transition-duration: 0.01ms !important;
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
    }
  }

  @media print {
    .site-header,
    .access-panel,
    .profile-banner,
    .contact-section,
    .site-footer {
      display: none !important;
    }

    .hero,
    .section {
      display: block;
      border: 0;
    }

    .hero-copy,
    .section-content {
      padding: 1rem 0;
    }
  }
}
