/* Light "mist" theme: cool grey-blue page, slate outlines, sans-serif type */

:root {
  --bg: #e7eef8;
  --fg: #1f2937;
  --mut: #5b6472;
  --acc: #1f2937;
  --tint: #d9e5f4;
  --font: ui-sans-serif, system-ui, "Segoe UI", Helvetica, Arial, sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

/* Text and links can be selected, copied and dragged; only pictures can't be dragged out */
img, svg {
  -webkit-user-drag: none;
}

/* Site version, quiet, top right on every screen (bump it with every release) */
.site-version {
  position: fixed;
  top: 0.6rem;
  right: 0.9rem;
  margin: 0;
  z-index: 1;
  font-size: 0.75rem;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

/* Soft light orb that slowly drifts around, gently lightening the background */
.orb {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 75vmax;
  height: 75vmax;
  margin: -37.5vmax 0 0 -37.5vmax;
  border-radius: 50%;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.6) 0%, rgba(255, 255, 255, 0.32) 35%, rgba(255, 255, 255, 0) 68%);
  pointer-events: none;
  z-index: 0;
  will-change: transform;
  animation: orb-drift 42s ease-in-out infinite alternate;
}
@keyframes orb-drift {
  0%   { transform: translate(-18vw, -12vh) scale(1); }
  33%  { transform: translate(14vw, -6vh) scale(1.08); }
  66%  { transform: translate(8vw, 16vh) scale(0.96); }
  100% { transform: translate(-14vw, 10vh) scale(1.04); }
}

h1, h2, p {
  margin: 0;
}

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

a:focus-visible,
.print-card:focus-visible {
  outline: 2px solid var(--acc);
  outline-offset: 3px;
  border-radius: 8px;
}

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

/* One screen visible at a time */
.view-section {
  display: none;
  position: relative;
  z-index: 1;
}
.view-section.active {
  display: block;
  animation: view-in 0.35s ease both;
}
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Home screen: exactly one viewport tall, page itself never scrolls */
body.home-active {
  overflow: hidden;
}
.home-screen {
  height: 100vh;
  height: 100dvh;
  max-width: 30rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  /* Only scrolls internally on very short windows (or zoomed in), instead of clipping */
  overflow-y: auto;
}
/* Centred with auto margins rather than justify-content: center, which pushed the top
   of the content above the scrollable area when it didn't fit (name cut off) */
.home-screen > :first-child {
  margin-top: auto;
}
.home-screen > :last-child {
  margin-bottom: auto;
}

/* Focus is moved to the screen's heading on navigation; no ring needed there */
h1[tabindex="-1"]:focus {
  outline: none;
}

/* Read by screen readers only */
.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;
}

/* Empty text slots stay out of the way (still editable in edit mode) */
body:not(.edit-mode) .tagline:empty,
body:not(.edit-mode) .bio:empty {
  display: none;
}

/* Page behind the open lightbox doesn't scroll */
body.lightbox-open {
  overflow: hidden;
}

.name {
  font: 600 clamp(2.2rem, 5.5vw, 3rem) / 1.1 var(--font);
  letter-spacing: -0.03em;
}
.tagline {
  margin-top: 0.55rem;
  color: var(--mut);
}

/* Outlined buttons (home menu and project list) */
.menu {
  margin-top: 2.25rem;
}
.menu-item {
  display: grid;
  grid-template-columns: 2.4rem 1fr auto;
  column-gap: 0.25rem;
  align-items: baseline;
  padding: 0.9rem 1.25rem;
  margin-bottom: 0.75rem;
  border: 1.5px solid var(--acc);
  border-radius: 12px;
}
.menu-item:focus-visible {
  background: var(--acc);
  color: #fff;
}
/* Hover-only visual states are gated to devices that can actually hover.
   Touch browsers simulate :hover on tap with no real "pointer leaves the
   element" event, so without this gate the dark state gets stuck after a
   tap, a return-to-page, or a finger dragged off the button. */
@media (hover: hover) and (pointer: fine) {
  .menu-item:hover {
    background: var(--acc);
    color: #fff;
  }
}
.menu-item .ico {
  grid-row: 1 / span 2;
  align-self: center;
  display: flex;
  align-items: center;
}
.menu-item .n {
  font-size: 0.8rem;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
}
.menu-item .t {
  font-size: 1.15rem;
}
.menu-item .d {
  grid-column: 2;
  color: var(--mut);
  font-size: 0.85rem;
}
.menu-item .arr {
  grid-column: 3;
  grid-row: 1;
}
.menu-item:focus-visible .n,
.menu-item:focus-visible .d {
  color: #cbd5e1;
}
@media (hover: hover) and (pointer: fine) {
  .menu-item:hover .n,
  .menu-item:hover .d {
    color: #cbd5e1;
  }
}

.home-footer {
  margin-top: 2.25rem;
  color: var(--mut);
  font-size: 0.9rem;
}
/* Bigger tap target than the text, without moving anything (the extra area is invisible) */
.home-footer a {
  position: relative;
}
.home-footer a::after {
  content: "";
  position: absolute;
  inset: -12px -6px;
}
@media (hover: hover) and (pointer: fine) {
  .home-footer a:hover,
  .mail:hover {
    color: var(--acc);
  }
}

/* Inner screens */
.page {
  max-width: 36rem;
  margin: 0 auto;
  min-height: 100vh;
  padding: 3rem 1.5rem;
}
.back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 2.25rem;
  padding: 0.55rem 1.1rem;
  border: 1.5px solid var(--mut);
  border-radius: 10px;
  color: var(--mut);
  font-size: 0.95rem;
  font-weight: 500;
}
.back:focus-visible {
  border-color: var(--acc);
  color: var(--acc);
  background: var(--tint);
}
@media (hover: hover) and (pointer: fine) {
  .back:hover {
    border-color: var(--acc);
    color: var(--acc);
    background: var(--tint);
  }
}
.page-title {
  font: 600 2rem / 1.15 var(--font);
  letter-spacing: -0.03em;
}
.project-list {
  margin-top: 2rem;
}

/* 3D print gallery */
.print-grid {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 1.25rem;
}
.print-card {
  display: block;
  width: 100%;
  text-align: left;
  cursor: default;
  border: 1.5px solid var(--acc);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}
/* No lift or shadow on hover/focus: any change under the pointer made the spin look jumpy.
   Keyboard focus still gets the site's outline (.print-card:focus-visible above). */
.print-media {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--tint);
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
  /* A sideways swipe turns the model; only up/down scrolls the page */
  touch-action: pan-y;
}
.print-body {
  display: block;
  padding: 0.9rem 1rem;
}
.print-title {
  display: block;
  font-weight: 600;
}
.print-caption {
  display: block;
  color: var(--mut);
  font-size: 0.85rem;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(31, 41, 55, 0.85);
  backdrop-filter: blur(6px);
}
.lightbox.open {
  display: flex;
}
/* The dialog takes focus after a mouse/touch open: no ring for that (Close keeps its own) */
.lightbox:focus {
  outline: none;
}
.lightbox-caption {
  position: absolute;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  margin: 0;
  max-width: calc(100% - 2rem);
  padding: 0.35rem 0.9rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lightbox-media {
  max-width: 100%;
  max-height: 85vh;
  border-radius: 12px;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  border: 0;
  background: #fff;
  color: var(--fg);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

/* Privacy page */
.privacy {
  margin-top: 2rem;
  max-width: 38rem;
  color: var(--mut);
  line-height: 1.6;
}
.privacy p {
  margin: 0 0 0.8rem;
}
.privacy h2 {
  margin: 1.5rem 0 0.5rem;
  color: var(--fg);
  font-size: 1.1rem;
  font-weight: 600;
}
.privacy h2:first-child {
  margin-top: 0;
}
.privacy a,
.page-note a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Small link under a page's content */
.page-note {
  margin-top: 2rem;
  color: var(--mut);
  font-size: 0.85rem;
}

/* About page */
.about {
  margin-top: 2rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.headshot {
  position: relative;
  width: 5.5rem;
  height: 5.5rem;
  flex-shrink: 0;
  border-radius: 9999px;
  overflow: hidden;
  border: 1.5px solid var(--acc);
  background: var(--tint);
  color: var(--acc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 600;
}
.headshot img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bio {
  font-size: 1.35rem;
  line-height: 1.35;
}
.mail {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--mut);
  font-size: 0.95rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .view-section.active { animation: none; }
  .orb { animation: none; }
  .menu-item,
  .print-card { transition: none; }
}
