@layer tokens, base, layout, narrow, print;

@layer tokens {
  :root {
    color-scheme: light;
    --ink: #3a4a58;
    --ink-strong: #2f3e4c;
    --muted: #62707c;
    --fg: #5c6b78;
    --line: #cfd8df;
    --page: #ffffff;
    --desk: #e6e9ed;
    --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --weight-heading: 800;
    --weight-role: 600;
    --weight-date: 700;
    --leading: 1.45;
    --leading-tight: 1;
    --size-name: 26pt;
    --size-name-narrow: 22pt;
    --size-role: 11pt;
    --size-label: 12pt;
    --size-job: 11pt;
    --size-copy: 9.5pt;
    --track-name: 0.04em;
    --track-role: 0.22em;
    --track-label: 0.14em;
    --space: 0.24in;
    --space-sm: 0.12in;
    --list-gap: 0.4em;
    --rule-gap: 0.18in;
    --gutter: 0.42in;
    --rail: 2.2in;
    --page-width: 8.5in;
    --page-height: 11in;
    --page-pad: 0.5in;
    --rule: 1px solid var(--line);
    --shadow: 0 12px 40px rgb(40 50 60 / 12%);
    --icon-slot: 1.15em;
    --icon-size: 0.9em;
    --badge-size: 1.2em;
    --sprite: 64px;
  }
}

@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    font-family: var(--font);
    line-height: var(--leading);
    background: var(--desk);
    color: var(--fg);
  }

  body {
    margin: 0;
    padding: 2rem 1rem;
  }

  h1,
  h2,
  h3 {
    margin: 0;
    color: var(--ink-strong);
    font-weight: var(--weight-heading);
  }

  h1,
  h2,
  .role {
    text-transform: uppercase;
  }

  h1,
  h2 {
    line-height: var(--leading-tight);
  }

  h1 {
    font-size: var(--size-name);
    letter-spacing: var(--track-name);
  }

  .role {
    margin: var(--list-gap) 0 0;
    color: var(--muted);
    font-size: var(--size-role);
    font-weight: var(--weight-role);
    letter-spacing: var(--track-role);
  }

  h2 {
    display: flex;
    align-items: center;
    gap: 0.4em;
    margin-bottom: var(--space-sm);
    font-size: var(--size-label);
    letter-spacing: var(--track-label);
  }

  h3 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1em;
    font-size: var(--size-job);
  }

  h3 time {
    color: var(--muted);
    font-weight: var(--weight-date);
    white-space: nowrap;
  }

  h3 + p {
    margin: var(--list-gap) 0 var(--space-sm);
    color: var(--muted);
  }

  .badge {
    display: inline-block;
    flex: none;
    width: var(--badge-size);
    height: 1em;
    color: var(--ink);
    line-height: 0;
  }

  /* Keep the sprite at a real size; 0×0 sheets get rasterized and look crunchy. */
  .sprites {
    position: absolute;
    left: -100vw;
    width: var(--sprite);
    height: var(--sprite);
    overflow: hidden;
    pointer-events: none;
  }

  .badge svg,
  .contact .glyph svg {
    display: block;
    overflow: visible;
    shape-rendering: geometricPrecision;
    text-rendering: geometricPrecision;
  }

  .badge svg {
    width: 100%;
    height: 100%;
  }

  ul,
  ol,
  p {
    margin: 0;
  }

  .contact,
  ol {
    padding: 0;
    list-style: none;
  }

  .contact li {
    display: grid;
    grid-template-columns: var(--icon-slot) 1fr;
    column-gap: 0.45em;
    align-items: center;
  }

  .contact .glyph {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--icon-slot);
    height: 1.25em;
    color: var(--ink);
    line-height: 0;
  }

  .contact .glyph svg {
    width: var(--icon-size);
    height: var(--icon-size);
  }

  section ul li,
  .contact li,
  section p,
  h3 time {
    font-size: var(--size-copy);
  }

  section ul li,
  .contact li {
    margin: 0 0 var(--list-gap);
  }

  section ul li:last-child,
  .contact li:last-child {
    margin-bottom: 0;
  }

  .contact a {
    display: flex;
    align-items: center;
    min-height: 24px;
    overflow-wrap: anywhere;
  }

  section ul {
    padding-left: 1.05em;
  }

  section ul li::marker {
    color: var(--ink);
  }

  section ul em {
    font-style: normal;
    font-weight: var(--weight-date);
    color: var(--ink-strong);
  }

  h3 + p {
    font-style: italic;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  ol > li + li {
    margin-top: var(--space);
  }
}

@layer layout {
  .page {
    width: var(--page-width);
    min-height: var(--page-height);
    margin: 0 auto;
    padding: var(--page-pad);
    background: var(--page);
    color: var(--fg);
    box-shadow: var(--shadow);
  }

  header {
    padding-bottom: var(--rule-gap);
    margin-bottom: var(--rule-gap);
    border-bottom: var(--rule);
  }

  main {
    display: grid;
    grid-template-columns: var(--rail) 1fr;
    grid-template-rows: auto auto 1fr;
    column-gap: var(--gutter);
    row-gap: 0;
    align-items: start;
  }

  main > section:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  main > section:nth-child(2) {
    grid-column: 1;
    grid-row: 2;
    margin-top: var(--rule-gap);
    padding-top: var(--rule-gap);
    border-top: var(--rule);
  }

  main > section:nth-child(n + 3) {
    grid-column: 2;
  }

  main > section:nth-child(n + 4) {
    margin-top: var(--rule-gap);
    padding-top: var(--rule-gap);
    border-top: var(--rule);
  }
}

@layer narrow {
  @media (max-width: 9in) {
    body {
      padding: 0;
      background: var(--page);
    }

    .page {
      width: auto;
      min-height: 0;
      padding: 1.4rem 1.1rem;
      box-shadow: none;
    }

    main {
      grid-template-columns: 1fr;
      grid-template-rows: none;
    }

    main > section:nth-child(n) {
      grid-column: 1;
      grid-row: auto;
    }

    main > section + section {
      margin-top: var(--rule-gap);
      padding-top: var(--rule-gap);
      border-top: var(--rule);
    }

    h1 {
      font-size: var(--size-name-narrow);
    }
  }
}

@layer print {
  @media print {
    @page {
      size: letter;
      margin: 0.4in;
    }

    html {
      --space: 0.2in;
      --space-sm: 0.1in;
      --list-gap: 0.32em;
      --rule-gap: 0.14in;
      background: var(--page);
      print-color-adjust: exact;
      -webkit-print-color-adjust: exact;
    }

    body {
      padding: 0;
      background: var(--page);
    }

    .page {
      width: auto;
      min-height: 0;
      padding: 0;
      box-shadow: none;
    }

    /* Block flow paginates; grid/flex lines often become extra pages in Chrome. */
    main {
      display: block;
    }

    main > section:nth-child(1) {
      float: left;
      width: calc(50% - var(--gutter) / 2);
      grid-column: auto;
      grid-row: auto;
      margin-top: 0;
      padding-top: 0;
      border-top: 0;
    }

    main > section:nth-child(2) {
      float: right;
      width: calc(50% - var(--gutter) / 2);
      grid-column: auto;
      grid-row: auto;
      margin-top: 0;
      padding-top: 0;
      border-top: 0;
    }

    main > section:nth-child(n + 3) {
      clear: both;
      float: none;
      width: auto;
      grid-column: auto;
      grid-row: auto;
      margin-top: var(--rule-gap);
      padding-top: var(--rule-gap);
      border-top: var(--rule);
    }

    /* Sit the first full-width rule closer to Contact/Skills than to Profile. */
    main > section:nth-child(3) {
      margin-top: 0.1in;
    }

    .contact a {
      min-height: 0;
    }
  }
}
