/* ---------- Palettes ----------
   Switch by changing data-palette */

:root,
[data-palette="amber"] {
  --bg: #0e0f11;       /* graphite */
  --text: #a8a29e;     /* warm grey body text, 7.6:1 */
  --head: #ece7df;     /* headings, 15.6:1 */
  --accent: #f2b54a;   /* instrument amber, 10.5:1 */
  --line: #3a3733;
  --card: rgba(255, 255, 255, 0.035);
  --spot: rgba(242, 181, 74, 0.06);
  color-scheme: dark;
}

[data-palette="copper"] {
  --bg: #0b1712;       /* solder-mask green */
  --text: #94a89c;
  --head: #e2ebe5;
  --accent: #e8a06a;   /* copper trace */
  --line: #2f4038;
  --card: rgba(255, 255, 255, 0.035);
  --spot: rgba(232, 160, 106, 0.06);
  color-scheme: dark;
}

[data-palette="datasheet"] {
  --bg: #f6f4ef;       /* paper */
  --text: #57534e;
  --head: #1c1917;
  --accent: #1d4ed8;   /* ink blue */
  --line: #d6d3cc;
  --card: rgba(0, 0, 0, 0.03);
  --spot: rgba(29, 78, 216, 0.05);
  color-scheme: light;
}

:root {
  --accent-chip: color-mix(in srgb, var(--accent) 12%, transparent);
  --stroke: color-mix(in srgb, var(--text) 55%, var(--bg));
  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Base ---------- */

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

html {
  background: var(--bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

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

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

.spotlight {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(600px circle at var(--spot-x, -1000px) var(--spot-y, -1000px), var(--spot), transparent 80%);
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 1rem;
  z-index: 50;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.print-only { display: none; }

/* ---------- Layout ---------- */

.layout {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 3rem 1.5rem;
}

.content { margin-top: 2.5rem; }

@media (min-width: 768px) {
  .layout { padding: 5rem 3rem; }
}

@media (min-width: 1024px) {
  .layout {
    display: flex;
    justify-content: space-between;
    padding: 0 6rem;
  }
  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 48%;
    max-height: 100vh;
    padding: 6rem 0;
  }
  .content {
    width: 52%;
    margin-top: 0;
    padding: 6rem 0;
  }
}

/* ---------- Sidebar ---------- */

.name {
  margin: 0;
  color: var(--head);
  font-size: clamp(2.25rem, 5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.role {
  margin: 0.75rem 0 0;
  color: var(--head);
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}
@media (min-width: 640px) {
  .role { font-size: 1.25rem; }
}

.tagline {
  max-width: 21rem;
  margin: 1rem 0 0;
}

.status {
  display: inline-flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 1.5rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.status-dot {
  flex: none;
  margin-top: 0.5em;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-chip);
}

@media (prefers-reduced-motion: no-preference) {
  .status-dot { animation: pulse 2.4s ease-in-out infinite; }
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 6px transparent; }
}

.nav { display: none; }

@media (min-width: 1024px) {
  .nav { display: block; margin-top: 4rem; }
}

.nav ul {
  width: max-content;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav a {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nav-line {
  width: 2rem;
  height: 1px;
  margin-right: 1rem;
  background: var(--line);
  transition: width 0.15s ease, background-color 0.15s ease;
}

.nav-text { transition: color 0.15s ease; }

.nav a:hover .nav-line,
.nav a:focus-visible .nav-line {
  width: 4rem;
  background: var(--head);
}

.nav a.active .nav-line {
  width: 4rem;
  background: var(--accent);
}

.nav a:hover .nav-text,
.nav a:focus-visible .nav-text,
.nav a.active .nav-text {
  color: var(--head);
}

.socials {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
}

@media (min-width: 1024px) {
  .socials { margin-top: 0; }
}

.socials a {
  display: block;
  margin: -0.25rem;
  padding: 0.25rem;
  transition: color 0.15s ease;
}
.socials a:hover { color: var(--head); }
.socials svg { display: block; width: 1.5rem; height: 1.5rem; }

/* ---------- Sections ---------- */

.section {
  margin-bottom: 4rem;
  scroll-margin-top: 4rem;
}
.section > p { margin: 0 0 1rem; }
.section:last-child { margin-bottom: 0; }

@media (min-width: 768px) {
  .section { margin-bottom: 6rem; }
}
@media (min-width: 1024px) {
  .section { margin-bottom: 9rem; scroll-margin-top: 6rem; }
}

.section-heading {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 -1.5rem 0.75rem;
  padding: 1rem 1.5rem;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

@media (min-width: 768px) {
  .section-heading { margin-inline: -3rem; padding-inline: 3rem; }
}

.section-heading h2 {
  margin: 0;
  color: var(--head);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* headings for screen readers only */
@media (min-width: 1024px) {
  .section-heading {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

.inline-link {
  color: var(--head);
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
.inline-link:hover,
.inline-link:focus-visible {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.em { color: var(--head); font-weight: 500; }

/* ---------- Cards ---------- */

.card-list {
  display: grid;
  gap: 3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: grid;
  gap: 0.5rem;
  border-radius: 0.5rem;
  transition: opacity 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

@media (min-width: 640px) {
  .card { grid-template-columns: 2fr 6fr; gap: 2rem; }
  .card--project { grid-template-columns: 3fr 5fr; }
  .card--project .card-thumb { order: -1; margin-top: 0.3rem; }
}

@media (min-width: 1024px) {
  .card-list { gap: 1.5rem; margin: -1rem; }
  .card { padding: 1rem; }
}

@media (min-width: 1024px) and (hover: hover) {
  .card-list:hover .card { opacity: 0.5; }
  .card-list .card:hover {
    opacity: 1;
    background: var(--card);
    box-shadow: inset 0 1px 0 0 color-mix(in srgb, var(--head) 8%, transparent);
  }
  .card:hover .card-title { color: var(--accent); }
  .card:hover .card-thumb svg { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
}

.card-meta {
  margin: 0.2rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-title {
  margin: 0;
  color: var(--head);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
  transition: color 0.15s ease;
}

.card-at { font-weight: 500; }

.card-sub {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
}

.card-body > p:not(.card-sub) {
  margin: 0.6rem 0 0;
  font-size: 0.9375rem;
}

.badge {
  display: inline-block;
  padding: 0 0.5rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.6875rem;
  line-height: 1.5;
  vertical-align: 1px;
}

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

.tags li {
  padding: 0.2rem 0.7rem;
  border-radius: 999px;
  background: var(--accent-chip);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
}

.card-thumb { margin: 0; }

.card-thumb svg {
  display: block;
  width: 100%;
  max-width: 12.5rem;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 0.375rem;
  background: color-mix(in srgb, var(--head) 2%, transparent);
  transition: border-color 0.2s ease;
}

/* Diagram parts inside the project thumbnails */
.t-line { fill: none; stroke: var(--stroke); stroke-width: 1.5; }
.t-accent { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.t-dot { fill: var(--accent); }
.t-fill { fill: color-mix(in srgb, var(--accent) 30%, transparent); }
/* Opaque fill so the shield hides the database lines behind it */
.t-shield { fill: color-mix(in srgb, var(--accent) 14%, var(--bg)); stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; }
.t-label { fill: var(--text); font-family: var(--mono); font-size: 11px; }
.t-label--accent { fill: var(--accent); }

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 3rem;
  color: var(--head);
  font-weight: 600;
  text-underline-offset: 4px;
}
.arrow-link svg { width: 1rem; height: 1rem; transition: transform 0.15s ease; }
/* the one solid-accent element on the page: the live drive data */
.arrow-link--card {
  margin-top: 1rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-size: 0.875rem;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}
.arrow-link.arrow-link--card:hover,           /* beats the generic .arrow-link:hover below */
.arrow-link.arrow-link--card:focus-visible {
  color: var(--bg);
  background: color-mix(in srgb, var(--accent) 88%, white);
  box-shadow: 0 0 0 4px var(--accent-chip);
  text-decoration: none;
}
.arrow-link:hover,
.arrow-link:focus-visible { color: var(--accent); text-decoration: underline; }
.arrow-link:hover svg,
.arrow-link:focus-visible svg { transform: translateX(4px); }

/* CarPi card: primary data link + secondary link out to the hosted analyzer */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}
.card-actions .arrow-link { margin-top: 0; }
.arrow-link--ghost {
  padding: calc(0.45rem - 1px) calc(1rem - 1px);   /* same outer size as the solid pill */
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--head);
  font-size: 0.875rem;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.arrow-link.arrow-link--ghost:hover,
.arrow-link.arrow-link--ghost:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-chip);
  text-decoration: none;
}
.arrow-link--ghost:hover svg,
.arrow-link--ghost:focus-visible svg { transform: translate(2px, -2px); }   /* diagonal: leaves the site */
.card-note {
  margin: 0.55rem 0 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.75rem;
  opacity: 0.8;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ---------- Print: the page doubles as a one-page résumé ---------- */

@media print {
  @page { margin: 0.6in; }

  :root,
  [data-palette] {
    --bg: #fff;
    --text: #333;
    --head: #000;
    --accent: #000;
    --line: #bbb;
    --accent-chip: transparent;
  }

  body { font-size: 10pt; line-height: 1.45; }

  .spotlight, .skip-link, .nav, .socials, .card-thumb, .arrow-link, .card-actions, .card-note, .status-dot { display: none !important; }
  .print-only { display: block; margin: 0.4rem 0 0; font-size: 9pt; }

  .layout, .sidebar, .content { display: block; width: auto; max-height: none; padding: 0; }
  .sidebar { margin-bottom: 1rem; }
  .content { margin-top: 0; }
  .name { font-size: 20pt; }
  .role { font-size: 12pt; margin-top: 0.2rem; }
  .tagline { max-width: none; margin-top: 0.3rem; }
  .status { margin-top: 0.3rem; }

  .section { margin-bottom: 1rem; }
  .section-heading {
    position: static;
    width: auto;
    height: auto;
    margin: 0 0 0.5rem;
    padding: 0 0 0.2rem;
    overflow: visible;
    clip: auto;
    white-space: normal;
    border-bottom: 1px solid var(--line);
    background: none;
    backdrop-filter: none;
  }

  .card-list { gap: 0.7rem; margin: 0; }
  .card, .card--project { grid-template-columns: 1fr 5fr; gap: 1rem; padding: 0; break-inside: avoid; }
  .card--project { grid-template-columns: 1fr; }
  .card-body > p:not(.card-sub) { font-size: 9.5pt; margin-top: 0.25rem; }
  .tags { margin-top: 0.3rem; gap: 0.3rem; }
  .tags li { padding: 0 0.4rem; border: 1px solid var(--line); font-size: 8pt; }
  .badge { border-color: var(--line); }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
