/* sacheydaves.com. One column on phones, two on desktop. System fonts, hover-only motion. */

:root,
html[data-theme="light"] {
  color-scheme: light;
  --paper: #f8f5ef;
  --ink: #1d1b17;
  --muted: #6a655c;
  --line: #ddd7cb;
  --accent: #3551c4;
  --card: #fffdf9;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", ui-serif, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #171613;
    --ink: #ebe7df;
    --muted: #a09a8f;
    --line: #36332d;
    --accent: #9eb0ff;
    --card: #1f1d19;
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171613;
  --ink: #ebe7df;
  --muted: #a09a8f;
  --line: #36332d;
  --accent: #9eb0ff;
  --card: #1f1d19;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--paper); }

body {
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 40rem;
  padding: clamp(4rem, 11vh, 6.5rem) 1.5rem 3rem;
  color: var(--ink);
  font: 1rem/1.65 var(--sans);
}

/* One column: the identity wrapper dissolves so Links can be ordered after the content. */
main { display: flex; flex-direction: column; flex: 1; padding-bottom: 2.5rem; }
.identity { display: contents; }

::selection { background: var(--accent); color: var(--paper); }

/* Header */

header { display: flex; align-items: center; gap: 1.25rem; margin-bottom: 2.25rem; }
header img {
  flex: none; width: 4.75rem; height: 4.75rem; border-radius: 50%;
  object-fit: cover; box-shadow: 0 0 0 1px var(--line);
}

h1, h2, p, ul { margin: 0; }

h1 {
  font: 500 clamp(2rem, 7.5vw, 2.75rem)/1.1 var(--serif);
  letter-spacing: -.015em;
}
.tagline { margin-top: .4rem; color: var(--muted); }
.tagline i { font-style: normal; color: var(--accent); padding: 0 .2em; }

/* Prose */

p + p { margin-top: 1.1rem; }
.lede { font: 1.25rem/1.45 var(--serif); text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .22em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  transition: text-decoration-color .15s ease;
}
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

/* Sections */

section { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--line); }

h2 {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem;
  font: 600 .75rem/1.5 var(--sans);
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
h2::before { content: ""; width: .375rem; height: .375rem; border-radius: 50%; background: var(--accent); }

/* Lists: title left, date or note pinned right. The title wraps, the right column never does. */

ul { padding: 0; list-style: none; }
li {
  display: grid; grid-template-columns: 1fr auto; align-items: baseline; column-gap: 2rem;
  padding: .35rem 0;
}
.note {
  color: var(--muted); font-size: .9375rem; text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.edu-meta {
  display: block; margin-top: .15rem;
  color: var(--muted); font-size: .9375rem;
}
.edu-meta i { font-style: normal; padding: 0 .2em; }

li a span { display: inline-block; transition: transform .15s ease; }
li a:hover span { transform: translate(2px, -2px); }

@media (max-width: 34rem) {
  header { gap: 1rem; }
  header img { width: 4rem; height: 4rem; }
  .tagline { line-height: 1.4; }
  .tagline span { display: block; }
  .tagline i { display: none; }
  li { display: block; padding: .55rem 0; }
  .note { display: block; text-align: left; white-space: normal; }
  .experience ul { padding-left: var(--gutter, 28px); }
  .experience li {
    display: grid; grid-template-columns: 1fr;
    margin: 0; padding: 0 0 var(--gap, 20px);
  }
  .experience li:last-child { padding-bottom: 0; }
  .experience .note { display: block; text-align: left; white-space: normal; padding-top: .15rem; line-height: 1.5; }
}

/* Footer */

footer {
  margin-top: auto; padding-top: 1.5rem; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .875rem;
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  text-align: center;
  flex-shrink: 0;
}
.reach { display: flex; align-items: center; justify-content: center; gap: .35rem; }
.reach a {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem;
  color: var(--muted); text-decoration: none; border-radius: .5rem;
  transition: transform .15s ease;
}
.reach a.logo-linkedin { color: #0A66C2; }
.reach a.logo-github { color: #181717; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .reach a.logo-github { color: #fff; }
  :root:not([data-theme="light"]) .reach .logo-labs { background: #f4f4f6; }
}
html[data-theme="dark"] .reach a.logo-github { color: #fff; }
html[data-theme="dark"] .reach .logo-labs { background: #f4f4f6; }
.reach a:hover, .reach a:focus-visible { transform: translateY(-1px); }
.reach svg, .reach img { width: 1.25rem; height: 1.25rem; display: block; }
.reach img { border-radius: 0.22rem; }

.reach .tip {
  position: absolute;
  bottom: calc(100% + .7rem);
  left: 50%;
  transform: translateX(-50%) translateY(.25rem);
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  padding: .45rem .7rem .4rem;
  background: var(--card, #fffdf9);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: .5rem;
  box-shadow: 0 8px 22px color-mix(in srgb, var(--ink) 12%, transparent);
  white-space: nowrap;
  text-align: center;
  line-height: 1.25;
  transition: opacity 150ms ease, transform 150ms ease;
}
.reach .tip b { display: block; font-weight: 600; font-size: .8125rem; color: var(--ink); }
.reach .tip-url { display: block; margin-top: .12rem; color: var(--muted); font-weight: 400; font-size: .75rem; }
.reach .tip::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 8px;
  height: 8px;
  margin-top: -5px;
  background: var(--card, #fffdf9);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
@media (hover: hover) and (pointer: fine) {
  .reach a:hover .tip { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.reach a:focus-visible .tip { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Experience timeline */
.experience {
  --node: 12px;
  --gutter: 28px;
  --gap: 20px;
  --title-lh: 1.65rem;
  --node-top: calc((var(--title-lh) - var(--node)) / 2);
  --node-center: calc(var(--node-top) + var(--node) / 2);
}
.experience ul { position: relative; padding-left: var(--gutter); }
.experience li {
  position: relative;
  display: grid; grid-template-columns: 1fr auto; column-gap: 1.5rem;
  align-items: start;
  margin: 0; padding: 0 0 var(--gap);
  border-radius: .5rem;
  transition: background-color .15s ease;
}
.experience li:last-child { padding-bottom: 0; }
.experience li::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--gutter));
  top: var(--node-top);
  width: var(--node); height: var(--node);
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--accent);
  z-index: 1;
}
.experience .role { display: block; font-weight: 600; line-height: var(--title-lh); }
.experience .org { display: block; margin-top: .15rem; color: var(--muted); font-size: .9375rem; }
.experience .note {
  align-self: start;
  padding-top: 0;
  color: var(--muted);
  font-size: .9375rem;
  line-height: var(--title-lh);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 34rem) {
  .experience li { grid-template-columns: 1fr; }
  .experience .note {
    text-align: left;
    white-space: normal;
    padding-top: .15rem;
    line-height: 1.5;
  }
}

/* Tablet: the same column, slightly roomier. */

@media (min-width: 48rem) {
  body { max-width: 44rem; padding-inline: 2rem; }
}

/* Desktop: sticky identity on the left, content on the right. */

@media (min-width: 64rem) {
  html {
    background-image:
      radial-gradient(56rem 30rem at 10% -6rem, color-mix(in srgb, var(--accent) 12%, transparent), transparent 70%),
      radial-gradient(48rem 26rem at 92% -8rem, color-mix(in srgb, #e8a25c 16%, transparent), transparent 70%);
    background-repeat: no-repeat;
  }
  body { max-width: 72rem; padding: 5rem 2.5rem 3rem; }

  main {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
    column-gap: clamp(4rem, 7vw, 6rem); align-items: start;
  }
  .identity { display: block; }

  header { display: block; margin-bottom: 1.75rem; }
  header img {
    display: block; width: 7.5rem; height: 7.5rem; margin-bottom: 1.75rem;
    box-shadow: 0 0 0 1px var(--line), 0 0 0 5px var(--paper),
      0 0 0 6px color-mix(in srgb, var(--accent) 45%, transparent);
  }
  h1 { font-size: clamp(3rem, 4.6vw, 3.5rem); letter-spacing: -.02em; }
  h1::after { content: ""; display: block; width: 2.75rem; height: 2px; margin-top: 1.1rem; background: var(--accent); }
  .tagline { margin-top: 1rem; font-size: 1.0625rem; }
  .lede { font-size: 1.375rem; }

  .content > section { margin-top: 2.75rem; }
  .content > section:first-child { margin-top: 0; }

  /* Rows bleed slightly into the gutter so the hover highlight has room. */
  li { margin-inline: -.75rem; padding: .6rem .75rem; border-radius: .5rem; transition: background-color .15s ease; }
  .experience li { margin-inline: 0; padding: 0 0 var(--gap); }
  .experience li:last-child { padding-bottom: 0; }

  .now {
    padding: 1.5rem 1.75rem 1.4rem; border: 1px solid var(--line); border-radius: .875rem;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 7%, var(--card)), var(--card) 60%);
  }
  .now h2::before { box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
  .now li { display: block; position: relative; margin: 0; padding: .3rem 0 .3rem 1.25rem; }
  .now li::before {
    content: ""; position: absolute; left: 0; top: 1.1rem;
    width: .625rem; height: 1.5px; background: var(--accent);
  }
}

@media (min-width: 64rem) and (hover: hover) {
  li:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
  .now li:hover { background: none; }
  .experience li:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
}

/* Only pin the identity column when the viewport is tall enough to show all of it. */
@media (min-width: 64rem) and (min-height: 56rem) {
  .identity { position: sticky; top: 5rem; }
}

@media (prefers-reduced-motion: reduce) {
  a, li, li a span, .reach a, .reach .tip, .project-card, .theme-toggle, .site-tools, .site-tools .nav-link, .bar-name { transition: none; }
  li a:hover span { transform: none; }
  .reach a:hover, .reach a:focus-visible { transform: none; }
  .reach a:hover .tip, .reach a:focus-visible .tip { transform: translateX(-50%) translateY(0); }
  .project-card:hover { transform: none; }
}


/* Full-width top bar: name on the left after the hero, tools on the right */

.site-tools {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: flex-end;
  gap: .5rem;
  min-height: 3.25rem;
  padding: .4rem 1.15rem;
  padding-top: max(.4rem, env(safe-area-inset-top));
  padding-left: max(1.15rem, env(safe-area-inset-left));
  padding-right: max(1.15rem, env(safe-area-inset-right));
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  box-shadow: none;
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.site-tools.is-scrolled {
  background: var(--paper);
  border-bottom-color: var(--line);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--ink) 8%, transparent);
}
.bar-name {
  margin-right: auto;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
  font: 500 1.05rem/1.2 var(--serif);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-.3rem);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease, visibility .2s ease;
}
.site-tools.show-name .bar-name,
.site-tools[data-always-name] .bar-name {
  opacity: 1;
  visibility: visible;
  transform: none;
  pointer-events: auto;
}
.bar-name:hover, .bar-name:focus-visible {
  color: var(--accent);
  text-decoration: none;
}
.site-tools-end {
  display: flex; align-items: center; gap: .15rem; flex: none;
}
.site-tools .nav-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2.1rem; padding: .2rem .7rem;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--ink);
  text-decoration: none; font: 500 .875rem/1 var(--sans);
  transition: color .15s ease, background-color .15s ease;
}
.site-tools a.nav-link:hover, .site-tools a.nav-link:focus-visible {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  text-decoration: none;
}
.site-tools a.nav-link[aria-current="page"] {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.15rem; height: 2.15rem; margin-left: .1rem;
  padding: 0; border: 1px solid var(--line); border-radius: 50%;
  background: var(--card); color: var(--ink); cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.theme-toggle:hover, .theme-toggle:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--accent);
}
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; display: block; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }
@media (max-width: 34rem) {
  .site-tools { padding-inline: max(.85rem, env(safe-area-inset-left)) max(.85rem, env(safe-area-inset-right)); gap: .35rem; }
  .bar-name { font-size: .95rem; }
  .site-tools .nav-link { padding: .2rem .5rem; font-size: .8125rem; }
}

/* Portfolio page */

body.page-portfolio { max-width: 56rem; }
body.page-portfolio main { display: block; }
body.page-portfolio header {
  display: flex; flex-direction: column; align-items: flex-start;
  gap: .4rem; margin-bottom: 2rem;
}
body.page-portfolio .site-name {
  color: var(--muted); text-decoration: none;
  font-size: .9375rem; font-weight: 500;
}
body.page-portfolio .site-name:hover,
body.page-portfolio .site-name:focus-visible { color: var(--accent); text-decoration: none; }
body.page-portfolio h1 { font-size: clamp(2rem, 5vw, 2.5rem); }

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: 1.25rem;
}
.project-card {
  display: flex; gap: 1.1rem; align-items: flex-start;
  padding: 1.15rem 1.2rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: .875rem;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
@media (hover: hover) and (pointer: fine) {
  .project-card:hover {
    border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
    box-shadow: 0 8px 24px color-mix(in srgb, var(--ink) 8%, transparent);
    transform: translateY(-1px);
  }
}
.project-thumb {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 3rem; height: 3rem; border-radius: .65rem;
  background: color-mix(in srgb, var(--paper) 65%, var(--card));
  border: 1px solid var(--line);
}
.project-thumb img { width: 1.75rem; height: 1.75rem; object-fit: contain; display: block; }
.project-thumb img[src$=".png"],
.project-thumb img[src$=".jpg"],
.project-thumb img[src$=".webp"] {
  width: 100%; height: 100%; object-fit: cover; border-radius: inherit;
}
.project-body { min-width: 0; }
.project-name { font: 500 1.25rem/1.25 var(--serif); letter-spacing: -.01em; }
.project-desc { margin-top: .35rem; text-wrap: pretty; }
.project-meta {
  margin-top: .35rem; color: var(--muted); font-size: .9375rem;
  font-variant-numeric: tabular-nums;
}
.project-tags {
  display: flex; flex-wrap: wrap; gap: .35rem;
  list-style: none; padding: 0; margin: .65rem 0 0;
}
.project-tags li {
  display: inline-flex; align-items: center;
  margin: 0; padding: .15rem .55rem;
  border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font-size: .75rem; line-height: 1.4;
  background: transparent;
}
.project-links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .85rem; }
.project-links a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 2rem; padding: .15rem .7rem;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  border-radius: .4rem;
  color: var(--accent); text-decoration: none;
  font-size: .8125rem; font-weight: 500;
  transition: background-color .15s ease, border-color .15s ease;
}
.project-links a:hover, .project-links a:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, var(--card));
  text-decoration: none;
}
.portfolio-empty { margin-top: 1.5rem; color: var(--muted); }

@media (min-width: 64rem) {
  body.page-portfolio { max-width: 60rem; padding: 5rem 2.5rem 3rem; }
  body.page-portfolio header { display: flex; margin-bottom: 2.25rem; }
}
@media (min-width: 64rem) and (hover: hover) {
  .project-tags li:hover { background: transparent; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .project-thumb { background: #f4f4f6; }
}
html[data-theme="dark"] .project-thumb { background: #f4f4f6; }
