/*
  Canonical resume stylesheet for index.html.
  Screen: minimalist elevated sheet with native light/dark adaptation.
  Print: A4 & US Letter, 2 pages or fewer, pure light ink.
  index.html holds no presentation. Keep every visual rule in this file.
*/

:root {
  color-scheme: light dark;
  --text: #1d1d1f;
  --secondary: #58585d;       /* 7.11:1 on #ffffff (WCAG AAA) */
  --muted: #76767b;           /* subtle markers */
  --hairline: #e5e5ea;
  --sheet-border: rgba(0, 0, 0, 0.08);
  --sheet-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 12px 32px -8px rgba(0, 0, 0, 0.06);
  --link: #0066cc;            /* 5.57:1 on #ffffff (WCAG AA) */
  --link-underline: rgba(0, 102, 204, 0.32);
  --selection: #cce0f5;
  --page: #f5f5f7;
  --sheet: #ffffff;
  --font-text: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "SF Pro Display", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --row: 1.5rem;
  --gutter: clamp(1rem, 2.5vw, 1.5rem);
  --measure: 68ch;
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    --text: #f5f5f7;          /* 16.1:1 on #1c1c1e (WCAG AAA) */
    --secondary: #a1a1a6;     /* 6.85:1 on #1c1c1e (WCAG AA+) */
    --muted: #6e6e73;
    --hairline: rgba(255, 255, 255, 0.11);
    --sheet-border: rgba(255, 255, 255, 0.09);
    --sheet-shadow:
      0 1px 2px rgba(0, 0, 0, 0.45),
      0 16px 40px -8px rgba(0, 0, 0, 0.55);
    --link: #4da3ff;          /* 6.79:1 on #1c1c1e (WCAG AA+) */
    --link-underline: rgba(77, 163, 255, 0.38);
    --selection: rgba(77, 163, 255, 0.28);
    --page: #0a0a0c;
    --sheet: #1c1c1e;
  }
}

@media screen and (prefers-contrast: more) {
  :root {
    --secondary: #1d1d1f;
    --muted: #424245;
    --hairline: #767676;
    --link-underline: currentColor;
  }
}

@media screen and (prefers-color-scheme: dark) and (prefers-contrast: more) {
  :root {
    --secondary: #f5f5f7;
    --muted: #c7c7cc;
    --hairline: rgba(255, 255, 255, 0.35);
    --link-underline: currentColor;
  }
}

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

@media screen and (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

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

html {
  background: var(--page);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 100%;
  line-height: 1.5;
  font-kerning: normal;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The body is the sheet. Fluid width and padding prevent awkward breakpoint jumps. */
body {
  width: min(49.5rem, 100% - clamp(1.5rem, 4vw, 3rem));
  margin-block: clamp(1.25rem, 4.5vw, 3.5rem);
  margin-inline: auto;
  padding: clamp(2rem, 5.5vw, 3.5rem) clamp(1.5rem, 6vw, 3.75rem) clamp(1.75rem, 4.5vw, 2.75rem);
  background: var(--sheet);
  border: 1px solid var(--sheet-border);
  border-radius: clamp(0.75rem, 2vw, 1.125rem);
  box-shadow: var(--sheet-shadow);
  overflow-wrap: break-word;
}

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

ul,
ol {
  padding: 0;
}

address,
cite {
  font-style: normal;
}

strong {
  font-weight: 600;
}

p,
li,
dd {
  text-wrap: pretty;
}

::selection {
  background: var(--selection);
}

/* Keyboard skip link */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.75rem;
  z-index: 10;
  padding: 0.5rem 0.875rem;
  background: var(--sheet);
  color: var(--link);
  border: 1px solid var(--link);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}

.skip-link:focus-visible {
  left: 0.75rem;
}

/* Links: whisper-subtle underline satisfies WCAG 1.4.1 without adding clutter */

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  border-radius: 4px;
  touch-action: manipulation;
  transition: text-decoration-color 150ms ease;
}

a:hover,
a:focus {
  text-decoration-color: currentColor;
}

a:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

/* Masthead */

.masthead {
  margin-bottom: clamp(2rem, 4vw, 2.75rem);
}

.masthead h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.35rem + 1.8vw, 2.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.headline {
  margin-top: 0.375rem;
  font-size: clamp(1.0625rem, 0.95rem + 0.55vw, 1.25rem);
  line-height: 1.35;
  color: var(--secondary);
}

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.35rem;
  margin-top: 1.125rem;
  list-style: none;
  font-size: 0.875rem;
  color: var(--secondary);
}

/* Sections */

main > section {
  scroll-margin-top: 1.5rem;
}

main > section + section {
  margin-top: 2.25rem;
}

h2 {
  margin-bottom: 1.125rem;
  font-family: var(--font-display);
  font-size: clamp(1.1875rem, 1.1rem + 0.4vw, 1.375rem);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

/* The hairline sits on the heading, not the section, so a page break cannot separate them. */
main > section + section > h2 {
  padding-top: 1.75rem;
  border-top: 1px solid var(--hairline);
}

#summary > p {
  max-width: var(--measure);
  font-size: clamp(1rem, 0.975rem + 0.15vw, 1.0625rem);
  line-height: 1.58;
}

/* Entry header: title + org on left; dates + location on right via display: contents */

.role + .role,
.degree + .degree {
  margin-top: 1.875rem;
}

.role > header,
.degree > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--gutter);
  align-items: baseline;
}

.role > header > h3,
.degree > header > h3 {
  grid-column: 1;
  grid-row: 1;
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.4;
  text-wrap: balance;
}

.org {
  grid-column: 1;
  grid-row: 2;
  line-height: var(--row);
}

.role > header > .meta,
.degree > header > .meta {
  display: contents;
  font-size: 0.875rem;
  line-height: var(--row);
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.role > header > .meta > .dates,
.degree > header > .meta > .dates {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: baseline;
}

.role > header > .meta > .location,
.degree > header > .meta > .location {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  align-self: baseline;
}

.progression {
  grid-column: 1 / -1;
  grid-row: 3;
  margin-top: 0.125rem;
  font-size: 0.875rem;
  line-height: 1.45;
  color: var(--secondary);
}

/* Group eyebrow labels and bullets */

.role h4 {
  margin-top: 1.125rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary);
}

.role ul + h4 {
  margin-top: 1.25rem;
}

.role ul,
.degree ul {
  margin-top: 0.625rem;
  padding-left: 1.25em;
}

.role h4 + ul {
  margin-top: 0.45rem;
}

.role li,
.degree li {
  max-width: var(--measure);
}

.role li + li,
.degree li + li {
  margin-top: 0.425rem;
}

ul > li::marker {
  color: var(--muted);
  font-size: 0.85em;
}

.degree > p {
  margin-top: 0.375rem;
  max-width: var(--measure);
  font-size: 0.9375rem;
  color: var(--secondary);
}

.degree cite {
  font-style: italic;
  color: var(--text);
}

/* Skills: fluid label column + value column, with hairline between groups */

.skills > div {
  display: grid;
  grid-template-columns: clamp(9.5rem, 29%, 12.5rem) minmax(0, 1fr);
  column-gap: var(--gutter);
  align-items: baseline;
  padding-block: 0.6875rem;
}

.skills > div:first-child {
  padding-top: 0;
}

.skills > div:last-child {
  padding-bottom: 0;
}

.skills > div + div {
  border-top: 1px solid var(--hairline);
}

.skills dt {
  grid-column: 1;
  font-weight: 600;
}

.skills dd {
  grid-column: 2;
}

/* Publications: two-column layout with grouped date/location metadata */

.publications {
  list-style: none;
}

.publications > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--gutter);
  row-gap: 0.125rem;
}

.publications > li + li {
  margin-top: 1rem;
}

.publications cite,
.publications .authors,
.publications .venue {
  grid-column: 1;
}

.publications cite {
  font-weight: 500;
  line-height: 1.4;
}

.publications .authors,
.publications .venue {
  font-size: 0.9375rem;
  color: var(--secondary);
}

.publications .authors strong {
  color: var(--text);
  font-weight: 600;
}

.publications .meta {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  align-self: start;
  gap: 0.125rem;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Footer */

body > footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hairline);
  font-size: 0.8125rem;
  color: var(--secondary);
}

/* Touch ergonomics (coarse pointers only — never affects print) */

@media screen and (pointer: coarse) {
  .contact a {
    display: inline-flex;
    align-items: center;
    padding-block: 0.375rem;
    margin-block: -0.25rem;
  }
}

/* Narrow screens: stack to 1 column cleanly at 640px (39.99rem) */

@media screen and (max-width: 39.99rem) {
  .contact {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.375rem;
  }

  .contact a {
    display: inline-block;
    padding-block: 0.25rem;
  }

  .role > header,
  .degree > header,
  .publications > li,
  .skills > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .role > header > h3,
  .degree > header > h3,
  .org,
  .progression,
  .skills dd {
    grid-column: 1;
    grid-row: auto;
  }

  .role > header > .meta,
  .degree > header > .meta,
  .publications .meta {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.125rem 0.875rem;
    grid-column: 1;
    grid-row: auto;
    margin-top: 0.125rem;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--secondary);
    font-variant-numeric: tabular-nums;
    text-align: left;
    white-space: normal;
  }

  .role > header > .meta > .dates,
  .degree > header > .meta > .dates,
  .role > header > .meta > .location,
  .degree > header > .meta > .location {
    grid-column: auto;
    grid-row: auto;
    justify-self: start;
  }

  .progression {
    margin-top: 0.25rem;
  }

  .skills dt {
    margin-bottom: 0.25rem;
  }
}

/* Phone viewports: remove outer frame for full-bleed readability down to 320px */

@media screen and (max-width: 37.49rem) {
  html {
    background: var(--sheet);
  }

  body {
    width: auto;
    margin: 0;
    padding: clamp(1.5rem, 6vw, 2.25rem) clamp(1rem, 5vw, 1.5rem) 2rem;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

/* Print: A4 & US Letter (<= 2 pages), always pure light ink */

@page {
  size: auto;
  margin: 11.5mm 14mm;

  @bottom-left {
    content: "Hadrian Paulo Manuel Lim, M.S.";
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 7.5pt;
    color: #424245;
  }

  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 7.5pt;
    color: #424245;
    font-variant-numeric: tabular-nums;
  }
}

@media print {
  :root {
    color-scheme: light;
    --text: #1d1d1f;
    --secondary: #424245;
    --muted: #58585d;
    --hairline: #d2d2d7;
    --link: #1d1d1f;
    --page: #ffffff;
    --sheet: #ffffff;
    --row: 1.2rem;
    --gutter: 12pt;
  }

  html {
    background: #ffffff;
    font-size: 9.25pt;
    line-height: 1.22;
  }

  body {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #ffffff;
    color: var(--text);
  }

  .skip-link {
    display: none;
  }

  a,
  a:hover,
  a:focus {
    color: var(--text);
    text-decoration: none;
  }

  .masthead {
    margin-bottom: 8pt;
  }

  .masthead h1 {
    font-size: 18.5pt;
  }

  .headline {
    margin-top: 2pt;
    font-size: 10.25pt;
  }

  .contact {
    gap: 0 6pt;
    margin-top: 4.5pt;
    font-size: 8pt;
    color: var(--text);
  }

  .contact li + li::before {
    content: "·";
    margin-right: 6pt;
    color: var(--secondary);
  }

  main > section + section {
    margin-top: 6.5pt;
  }

  main > section + section > h2 {
    padding-top: 4.5pt;
  }

  h2 {
    margin-bottom: 3.5pt;
    font-size: 10.75pt;
  }

  #summary > p {
    max-width: none;
    font-size: 1rem;
    line-height: 1.24;
  }

  .role + .role,
  .degree + .degree {
    margin-top: 5pt;
  }

  .role > header,
  .degree > header,
  .publications > li {
    row-gap: 0;
  }

  .role > header > h3,
  .degree > header > h3 {
    font-size: 9.75pt;
    line-height: 1.22;
  }

  .org,
  .role > header > .meta,
  .degree > header > .meta {
    line-height: 1.22;
  }

  .role > header > .meta,
  .degree > header > .meta,
  .publications .meta {
    font-size: 8.25pt;
  }

  .progression {
    margin-top: 0.5pt;
    font-size: 8.25pt;
    line-height: 1.22;
  }

  .role h4 {
    margin-top: 4pt;
    font-size: 7.5pt;
    letter-spacing: 0.05em;
    line-height: 1.22;
  }

  .role ul + h4 {
    margin-top: 4.5pt;
  }

  .role ul,
  .degree ul {
    margin-top: 1.5pt;
  }

  .role h4 + ul {
    margin-top: 1pt;
  }

  .role li,
  .degree li,
  .degree > p {
    max-width: none;
  }

  .role li + li,
  .degree li + li {
    margin-top: 1.25pt;
  }

  ul > li::marker {
    font-size: 0.9em;
  }

  .degree > p {
    margin-top: 1pt;
    font-size: 8.75pt;
  }

  .skills > div {
    grid-template-columns: 12.5rem minmax(0, 1fr);
    padding-block: 2pt;
  }

  .publications > li + li {
    margin-top: 3pt;
  }

  .publications .authors,
  .publications .venue {
    font-size: 8.25pt;
    line-height: 1.2;
  }

  body > footer {
    margin-top: 6.5pt;
    padding-top: 3pt;
    font-size: 7.75pt;
  }

  .role > header,
  .degree > header,
  li,
  .skills > div {
    break-inside: avoid;
  }

  h2,
  h3,
  h4,
  .role > header,
  .degree > header {
    break-after: avoid;
  }

  p,
  li {
    orphans: 2;
    widows: 2;
  }
}
