/* ==========================================================================
   Site styles: mobile-first.
   Base rules target phones; min-width media queries add tablet/desktop layout.
   ========================================================================== */

/* ---------- Design tokens ---------- */
/* One warm dark theme for every visitor: dark brown, warm off-white text, yellow highlights. */
:root {
  --bg: #17120d;
  --surface: #211a14;
  --surface-2: #2c241c;
  --text: #f2e9d8;
  --muted: #b5a891;
  --border: #3b3128;
  --accent: #f2c14e;
  --accent-hover: #ffd36e;
  --accent-soft: #3a2e13;
  --on-accent: #1c1508;
  --shadow: none;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 8px;
  --gutter: 1.25rem;
  --maxw: 66rem;

  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Keeps hidden elements hidden even when a class (like .button) sets display. */
[hidden] {
  display: none !important;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1;
}

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

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

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

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

h1,
h2,
h3 {
  margin: 0 0 0.5em;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

p {
  margin: 0 0 1em;
}

/* Chemical formulas (Li₄ZrF₈, CO₂) without uneven line spacing. */
sub,
sup {
  line-height: 0;
}

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-left: max(var(--gutter), env(safe-area-inset-left));
  padding-right: max(var(--gutter), env(safe-area-inset-right));
}

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: -9999px;
  z-index: 10;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

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

.eyebrow {
  margin-bottom: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.lede {
  max-width: 36rem;
  font-size: 1.125rem;
  color: var(--muted);
}

/* ---------- Page transitions ----------
   Browsers that support cross-page view transitions (Safari 18.2+, Chrome 126+)
   animate between pages; others simply change page. Elements with the same
   view-transition-name on both pages glide from their old spot to their new one:
   the name moves from the home page's center to the header, and the Apps and Info
   buttons move into the menu. Everything else fades and rises slightly. */
@view-transition {
  navigation: auto;
}

.site-name,
.brand {
  view-transition-name: site-name;
}

.site-header {
  view-transition-name: site-header;
}

[data-nav="apps"] {
  view-transition-name: nav-apps;
}

[data-nav="info"] {
  view-transition-name: nav-info;
}

::view-transition-group(*) {
  animation-duration: 380ms;
  animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1);
}

::view-transition-old(root) {
  animation: 180ms ease-out both page-out;
}

::view-transition-new(root) {
  animation: 380ms cubic-bezier(0.2, 0.8, 0.2, 1) 60ms both page-in;
}

/* Text keeps its proportions while it grows or shrinks between pages. */
::view-transition-old(site-name),
::view-transition-new(site-name),
::view-transition-old(nav-apps),
::view-transition-new(nav-apps),
::view-transition-old(nav-info),
::view-transition-new(nav-info) {
  height: 100%;
  width: auto;
  object-fit: contain;
}

@keyframes page-out {
  to {
    opacity: 0;
  }
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition {
    navigation: none;
  }
}

/* ---------- Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.5rem;
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

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

.site-nav ul {
  display: flex;
  gap: 0.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
}

.site-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--surface-2);
}

@media (min-width: 30rem) {
  .site-header .container {
    column-gap: 1rem;
  }

  .site-nav ul {
    gap: 0.25rem;
  }

  .site-nav a {
    padding: 0 0.8rem;
  }
}

/* ---------- Buttons ---------- */
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.75rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.875rem;
  padding: 0.7rem 1.3rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.button-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.button-primary:hover {
  background: var(--accent-hover);
  color: var(--on-accent);
}

.button-secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.button-secondary:hover,
.button-secondary[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Page sections ---------- */
.hero {
  padding-block: 3rem 2.75rem;
}

.hero h1 {
  max-width: 15ch;
  font-size: clamp(2.25rem, 6vw + 0.75rem, 4rem);
}

.page-header {
  padding-block: 2.5rem 1.5rem;
}

.page-header h1 {
  font-size: clamp(2rem, 4vw + 1rem, 3rem);
}

.section {
  padding-block: 2.5rem;
}

.section + .section {
  border-top: 1px solid var(--border);
}

.page-header + .section {
  padding-top: 0;
}

@media (min-width: 48rem) {
  .hero {
    padding-block: 5.5rem 4.5rem;
  }

  .page-header {
    padding-block: 4rem 2rem;
  }

  .section {
    padding-block: 3.5rem;
  }
}

/* ---------- Cards ---------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 40rem) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 60rem) {
  .card-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
  }
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.card:has(.card-link):hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.card-placeholder {
  background: transparent;
  border-style: dashed;
  box-shadow: none;
}

.card-icon {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.card h3 {
  margin: 0;
  font-size: 1.125rem;
}

.card p {
  margin: 0;
  font-size: 0.975rem;
  color: var(--muted);
}

/* Stretches the title link over the whole card so the full card is tappable. */
.card-link {
  color: inherit;
  text-decoration: none;
}

.card-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.25rem;
}

.button-small {
  min-height: 44px;
  padding: 0.5rem 1.05rem;
  font-size: 0.9375rem;
}

/* Install panel: the one-line command, wrapped so it never scrolls sideways on a phone. */
.install-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.card .install-note {
  font-size: 0.875rem;
}

.install-panel code {
  display: block;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Home: name and two buttons, centered on screen ---------- */
.home-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  padding: max(2rem, env(safe-area-inset-top)) var(--gutter) max(2rem, env(safe-area-inset-bottom));
  text-align: center;
}

.home-name {
  margin: 0;
  font-size: clamp(1.5rem, 3vw + 0.75rem, 2.25rem);
  font-weight: 600;
}

.home-buttons {
  display: flex;
  gap: 0.75rem;
}

.home-buttons .button {
  min-width: 8.5rem;
  min-height: 3.25rem;
  font-size: 1.0625rem;
}

/* ---------- Code browser ---------- */
.code-page {
  padding-block: 2rem 3rem;
}

.code-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.code-top h1 {
  margin: 0;
  font-size: clamp(1.75rem, 3vw + 1rem, 2.5rem);
}

.code-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 0.4rem;
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.code-crumbs a {
  padding-block: 0.4rem;
  text-decoration: none;
}

.code-crumbs [aria-current] {
  color: var(--text);
}

.code-message {
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
}

.code-list {
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-list li + li {
  border-top: 1px solid var(--border);
}

.code-list a {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 44px;
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
}

.code-list a:hover {
  background: var(--surface-2);
}

.code-list a.is-dir {
  color: var(--accent);
}

.code-name {
  min-width: 0;
  overflow-wrap: anywhere;
}

.code-size {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
}

.code-file-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
}

.code-file-links {
  display: flex;
  gap: 1rem;
}

/* Long code lines scroll inside the box, never the whole page. */
.code-file {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.6;
  tab-size: 4;
}

.code-image {
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* README and other Markdown, rendered. */
.markdown {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}

.markdown-file {
  margin-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  margin: 1.6em 0 0.5em;
}

.markdown h1 {
  font-size: 1.6rem;
}

.markdown h2 {
  font-size: 1.3rem;
}

.markdown h3,
.markdown h4 {
  font-size: 1.075rem;
}

.markdown ul,
.markdown ol {
  padding-left: 1.4rem;
}

.markdown code {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

.markdown :not(pre) > code {
  padding: 0.1em 0.35em;
  background: var(--surface-2);
  border-radius: 4px;
}

.markdown pre {
  padding: 0.9rem;
  overflow-x: auto;
  background: var(--bg);
  border-radius: var(--radius-sm);
  overflow-wrap: normal;
}

.markdown img {
  max-width: 100%;
  height: auto;
}

.markdown table {
  display: block;
  overflow-x: auto;
  border-collapse: collapse;
}

.markdown th,
.markdown td {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
}

.markdown blockquote {
  margin: 0 0 1em;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
}

/* ---------- Resume ---------- */
.resume {
  padding-block: 2rem 3rem;
}

.resume-header {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.resume-header h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw + 1rem, 2.75rem);
}

.resume-title {
  margin: 0.35rem 0 0.9rem;
  font-size: 1.125rem;
  color: var(--muted);
}

.resume-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.95rem;
}

.resume-contact li {
  color: var(--muted);
}

.resume-section {
  padding-block: 1.75rem;
  border-bottom: 1px solid var(--border);
}

.resume-section:last-child {
  border-bottom: 0;
}

.resume-section > h2 {
  margin-bottom: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.resume-section > div > p:last-child {
  margin-bottom: 0;
}

.entry + .entry {
  margin-top: 1.75rem;
}

.entry-head {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.5rem;
}

.entry-head h3 {
  margin: 0;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
}

.entry-org {
  font-weight: 400;
  color: var(--muted);
}

.entry-dates {
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}

.entry ul {
  margin: 0;
  padding-left: 1.1rem;
}

.entry li + li {
  margin-top: 0.35rem;
}

.skill-group + .skill-group {
  margin-top: 1.25rem;
}

.skill-group h3 {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.chips li {
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 0.9rem;
}

@media (min-width: 40rem) {
  .resume-header {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }

  .entry-head {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
  }
}

@media (min-width: 48rem) {
  .resume {
    padding-block: 3.5rem 4rem;
  }

  .resume-section {
    display: grid;
    grid-template-columns: 10rem 1fr;
    gap: 2rem;
    padding-block: 2.25rem;
  }

  .resume-section > h2 {
    margin: 0.3rem 0 0;
  }
}

/* ---------- Print (resume "Save as PDF") ---------- */
@media print {
  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-2: #fff;
    --text: #000;
    --muted: #333;
    --border: #bbb;
    --accent: #000;
    color-scheme: light;
  }

  @page {
    margin: 0.55in 0.6in;
  }

  body {
    display: block;
    font-size: 10pt;
    line-height: 1.4;
  }

  .site-header,
  .skip-link,
  .no-print {
    display: none !important;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .resume {
    padding: 0;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  .resume-header {
    padding-bottom: 0.12in;
  }

  .resume-header h1 {
    font-size: 20pt;
  }

  .resume-title {
    margin: 0.04in 0 0.08in;
    font-size: 11pt;
  }

  .resume-contact {
    font-size: 9pt;
  }

  .resume-section {
    display: grid;
    grid-template-columns: 1.2in 1fr;
    gap: 0.2in;
    padding-block: 0.12in;
  }

  .resume-section > h2 {
    margin: 0.02in 0 0;
    font-size: 8.5pt;
  }

  .entry,
  .skill-group {
    break-inside: avoid;
  }

  .entry + .entry {
    margin-top: 0.12in;
  }

  .entry-head {
    flex-direction: row;
    justify-content: space-between;
    margin-bottom: 0.03in;
  }

  .entry-head h3 {
    font-size: 10.5pt;
  }

  .entry-dates {
    font-size: 9pt;
  }

  .entry li + li {
    margin-top: 0.02in;
  }

  .skill-group + .skill-group {
    margin-top: 0.08in;
  }

  .skill-group h3 {
    margin-bottom: 0.03in;
    font-size: 9.5pt;
  }

  /* Chips print as a plain comma-separated line. */
  .chips {
    display: block;
  }

  .chips li {
    display: inline;
    padding: 0;
    background: none;
    font-size: 9.5pt;
  }

  .chips li:not(:last-child)::after {
    content: ", ";
  }
}
