/* ==========================================================================
   Geoff Sondergard — portfolio
   Plain modern CSS (nesting, :has, @starting-style, scroll-driven animation).
   ========================================================================== */

@font-face {
  font-family: "Questrial";
  src: url("../fonts/Questrial-Regular.woff") format("woff"),
       url("../fonts/Questrial-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --yellow: #f1d675;
  --orange: #d38324;
  --red: #d54e27;
  --maroon: #731813;
  --hot: #dc372e;
  --sand: #ddd092;
  --sand-ink: #4a3b0e;
  --olive: #999966;

  --font: "Questrial", ui-sans-serif, system-ui, sans-serif;
  --header-h: 60px;
  --header-top: 5vh;
  --tilt: -1.5deg;
  --pop: 7px;
  --ease-out: cubic-bezier(.2, .8, .2, 1);

  color-scheme: dark;
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  background: #000;

  &:has(.lightbox[open]) { overflow: hidden; }
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: clamp(1.0625rem, .95rem + .45vw, 1.4rem);
  line-height: 1.5;
  color: #fff;
  background: #000;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { display: block; max-width: 100%; height: auto; }

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

h1, h2, h3 { font-weight: 400; line-height: 1.15; margin: 0 0 .6em; text-wrap: balance; }
p { margin: 0 0 1em; text-wrap: pretty; }

.yellow { color: var(--yellow); }
.orange { color: var(--orange); }
.red    { color: var(--red); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: fixed; top: .5rem; left: .5rem; z-index: 200;
  padding: .5rem 1rem; background: var(--yellow); color: #000;
  translate: 0 -200%;
  &:focus-visible { translate: 0; }
}

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

.container {
  width: min(90%, 1366px);
  margin-inline: auto;
}

/* --------------------------------------------------------------------------
   Header — the signature tilted band
   -------------------------------------------------------------------------- */

.site-header {
  position: fixed;
  z-index: 100;
  top: var(--header-top);
  left: -2%;
  width: 104%;
  height: var(--header-h);
  display: flex;
  rotate: var(--tilt);   /* also makes the header the containing block for the mobile dropdown */
  box-shadow: 0 6px 18px rgb(0 0 0 / .35);
}

.brand {
  flex: 0 0 calc(25% + 2%);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  padding-inline: 18px;
  background: var(--maroon);
  color: #fff;
  text-align: right;
  line-height: 1.05;
  transition: color .4s ease;

  .brand-name { font-size: clamp(1.05rem, .7rem + 1vw, 1.5rem); text-transform: uppercase; }
  .brand-tag  { font-size: clamp(.8rem, .55rem + .7vw, 1.1rem); color: #000; transition: color .4s ease; }

  &:hover { color: var(--hot); }
}

.site-nav {
  flex: 1;
  display: flex;
  align-items: center;
  background: rgb(115 24 19 / .5);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
}

.nav-links {
  display: flex;
  gap: clamp(.75rem, 2vw, 2rem);
  margin: 0;
  padding: 0 0 0 18px;
  list-style: none;

  a {
    display: block;
    font-size: clamp(1.4rem, .9rem + 1.4vw, 2.1rem);
    line-height: var(--header-h);
    text-transform: uppercase;
    color: #fff;
    -webkit-text-stroke: 1px #000;
    paint-order: stroke fill;
    text-shadow:
       3px  3px 0 #000,
      -1px -1px 0 #000,
       1px -1px 0 #000,
      -1px  1px 0 #000,
       1px  1px 0 #000;
    transition: color .4s ease, translate .25s var(--ease-out);

    &:hover, &[aria-current="true"] { color: var(--hot); }
    &:hover { translate: 0 -2px; }
  }
}

.nav-toggle { display: none; }

/* ---- Mobile: hamburger + dropdown ---- */
@media (max-width: 760px) {
  :root { --header-h: 56px; --header-top: max(12px, env(safe-area-inset-top)); --tilt: -1deg; }

  .brand {
    flex: 1 1 auto;
    align-items: flex-start;
    text-align: left;
    padding-inline: calc(2vw + 16px) 12px;
  }

  .site-nav {
    flex: 0 0 calc(var(--header-h) + 8vw);
    justify-content: flex-start;
    padding-left: 4px;
    /* a backdrop-filter here would trap the absolutely-positioned dropdown */
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .nav-toggle {
    display: grid;
    place-items: center;
    width: var(--header-h);
    height: var(--header-h);
    padding: 0;
    border: 0;
    background: none;
    color: #fff;
    cursor: pointer;
  }

  .nav-toggle-icon,
  .nav-toggle-icon::before,
  .nav-toggle-icon::after {
    display: block;
    width: 26px;
    height: 3px;
    border-radius: 2px;
    background: currentColor;
    box-shadow: 2px 2px 0 #000;
    transition: rotate .3s var(--ease-out), translate .3s var(--ease-out), opacity .2s;
  }
  .nav-toggle-icon { position: relative; }
  .nav-toggle-icon::before,
  .nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
  .nav-toggle-icon::before { translate: 0 -8px; }
  .nav-toggle-icon::after  { translate: 0  8px; }

  [data-open="true"] {
    .nav-toggle-icon { background: transparent; box-shadow: none; }
    .nav-toggle-icon::before { translate: 0; rotate: 45deg; }
    .nav-toggle-icon::after  { translate: 0; rotate: -45deg; }
  }

  .nav-links {
    position: absolute;
    top: 100%;
    right: 2%;
    left: 2%;
    flex-direction: column;
    gap: 0;
    padding: .5rem 0 1rem;
    background: rgb(40 8 6 / .88);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border-top: 3px solid var(--maroon);
    box-shadow: 0 18px 40px rgb(0 0 0 / .5);

    clip-path: inset(0 0 100% 0);
    opacity: 0;
    visibility: hidden;
    transition: clip-path .35s var(--ease-out), opacity .25s ease, visibility 0s .35s;

    li { border-bottom: 1px solid rgb(255 255 255 / .06); }
    li:last-child { border-bottom: 0; }

    a {
      padding-inline: calc(2vw + 18px);
      font-size: 2rem;
      line-height: 3.6rem;
      color: #fff;
      &[aria-current="true"] { color: var(--hot); }
    }
  }

  [data-open="true"] .nav-links {
    clip-path: inset(0 0 0 0);
    opacity: 1;
    visibility: visible;
    transition: clip-path .4s var(--ease-out), opacity .25s ease, visibility 0s;
  }
}

/* --------------------------------------------------------------------------
   Panels
   -------------------------------------------------------------------------- */

.panel {
  min-height: 100svh;
  padding-block: calc(var(--header-top) + var(--header-h) + clamp(2.5rem, 7vw, 6rem)) clamp(3rem, 6vw, 5rem);
  background: #000 center / cover no-repeat;
  text-shadow: 1px 1px 1px #000;
  scroll-margin-top: 0;
  overflow-x: clip;
}

.panel--intro     { background-image: url("../images/starfield.jpg"); }
.panel--portfolio { background-image: url("../images/earth.jpg"); }
.panel--about     { background-image: url("../images/clouds.jpg"); }
.panel--contact   { background-image: url("../images/desert.jpg"); }

/* tablets & up get fixed backgrounds where it's cheap; iOS ignores it anyway */
@media (min-width: 1024px) and (hover: hover) {
  .panel { background-attachment: fixed; }
}

/* soft entrance as each section scrolls in */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .reveal {
      animation: reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 60%;
    }
  }
}
@keyframes reveal {
  from { opacity: 0; translate: 0 40px; }
  to   { opacity: 1; translate: 0 0; }
}

/* ---- Intro ---- */
.intro {
  display: grid;
  grid-template-columns: minmax(0, 32rem) minmax(0, 600px);
  justify-content: center;
  align-items: start;
  column-gap: clamp(1.5rem, 4vw, 4rem);
}

.intro-copy {
  position: relative;
  z-index: 2;
  color: var(--yellow);

  h1 { font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.4rem); }
}
.intro-kicker { font-size: 1.1em; }

.moon {
  width: 100%;
  max-width: 600px;
  justify-self: center;
  margin-top: -14%;
  pointer-events: none;
  animation: drift 24s ease-in-out infinite alternate;
}
@keyframes drift {
  from { translate: 0 0; rotate: 0deg; }
  to   { translate: -12px 10px; rotate: 6deg; }
}

@media (max-width: 760px) {
  .intro { grid-template-columns: 1fr; }
  .moon {
    position: absolute;
    z-index: 0;
    width: 115vw;
    max-width: none;
    right: -45vw;
    top: 18svh;
    margin: 0;
    opacity: .5;
  }
  .panel--intro { position: relative; display: grid; align-items: center; }
}

/* ---- Portfolio ----
   Each group is a grid of 100px columns centred in the page; the thumbnail list
   joins that grid via subgrid, so the title lines up with the first thumbnail. */
.gallery-group {
  --thumb-w: 100px;
  --gap: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, var(--thumb-w));
  justify-content: center;
  column-gap: var(--gap);
  max-width: calc(9 * var(--thumb-w) + 8 * var(--gap)); /* 9 per row at most */
  margin-inline: auto;
}
.gallery-group + .gallery-group { margin-top: clamp(2rem, 4vw, 3rem); }

.gallery-title {
  grid-column: 1 / -1;
  margin: 0 0 .35em;
  color: var(--accent);
  font-size: clamp(1.15rem, 1rem + .6vw, 1.5rem);
  font-weight: 700;
  letter-spacing: .01em;
}

.gallery {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: subgrid;
  row-gap: var(--gap);
  margin: 0;
  padding: var(--pop) 0 0;
  list-style: none;

  a {
    display: block;
    position: relative;
    border: 1px solid transparent;
    outline-offset: 4px;
    transition:
      translate .35s var(--ease-out),
      box-shadow .35s var(--ease-out),
      border-color .35s ease;
    cursor: zoom-in;

    &:hover, &:focus-visible {
      translate: calc(var(--pop) * -1) calc(var(--pop) * -1);
      border-color: var(--accent);
      box-shadow: var(--pop) var(--pop) 0 0 var(--accent);
    }
    &:focus-visible { outline-color: var(--accent); }
    &:active { translate: 0 0; box-shadow: 0 0 0 0 var(--accent); transition-duration: .1s; }
  }

  img {
    width: var(--thumb-w);
    aspect-ratio: 1 / 2;
    object-fit: cover;
    background: rgb(255 255 255 / .06);
  }
}

@media (max-width: 760px) {
  .gallery-group {
    --gap: 10px;
    /* source thumbs are 100×200, so keep cells near native size (4-up on phones) */
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    padding-inline: var(--pop);
  }
  .gallery img { width: 100%; }
}

/* ---- About ---- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 42rem) minmax(0, 372px);
  justify-content: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  color: var(--orange);

  h2 { font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.4rem); }
}

.resume {
  margin-top: 1.5em;
  font-size: 1.2em;
  a {
    color: var(--yellow);
    border-bottom: 1px dashed currentColor;
    transition: color .3s;
    &:hover { color: #fff; }
  }
}

.about-photo {
  width: 100%;
  max-width: 372px;
  margin-top: clamp(0rem, 6vw, 5rem);
  box-shadow: var(--pop) var(--pop) 0 0 var(--orange);
}

@media (max-width: 760px) {
  .about { grid-template-columns: 1fr; }
  .about-photo { order: -1; width: 55%; margin: 0; }
}

/* ---- Contact ---- */
.contact {
  display: grid;
  grid-template-columns: minmax(0, 26rem) minmax(0, 460px);
  justify-content: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
  color: var(--red);

  h2 { font-size: clamp(2.2rem, 1.4rem + 2.6vw, 3.4rem); }
}
.contact-lede { font-size: 1.2em; }

.contact-form {
  display: grid;
  gap: 1rem;
  max-width: 460px;
  text-shadow: none;

  label {
    display: grid;
    gap: .3rem;
    color: #251e06;
    font-size: .95em;
    text-transform: uppercase;
    letter-spacing: .02em;
    text-shadow: 0 0 6px rgb(221 208 146 / .6);
  }

  input, textarea {
    width: 100%;
    padding: .55em .7em;
    border: 2px solid var(--sand);
    border-radius: 0;
    background: var(--sand);
    color: var(--sand-ink);
    font: inherit;
    font-size: max(16px, .9em); /* prevents iOS zoom-on-focus */
    text-transform: none;
    box-shadow: 0 0 8px rgb(0 0 0 / .3);
    transition: border-color .2s, box-shadow .2s;

    &:focus { outline: none; border-color: var(--olive); box-shadow: 0 0 0 3px rgb(153 153 102 / .45); }
    &:user-invalid { border-color: #900; }
  }
  textarea { resize: vertical; min-height: 9rem; }

  .hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.submit {
  min-width: 6.5rem;
  padding: .55em 1.2em;
  border: 2px solid var(--sand);
  background: var(--olive);
  color: #251e06;
  font: inherit;
  text-transform: uppercase;
  letter-spacing: .05em;
  cursor: pointer;
  transition: background .3s, color .3s, translate .2s var(--ease-out), box-shadow .2s var(--ease-out);

  &:hover, &:focus-visible {
    background: var(--red);
    color: var(--sand);
    translate: -4px -4px;
    box-shadow: 4px 4px 0 var(--sand);
  }
  &:disabled { opacity: .6; cursor: progress; }
}

.form-status {
  margin: 0;
  font-size: 1.05em;
  -webkit-text-stroke: 1px var(--sand);
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 var(--sand);

  &[data-state="error"]   { color: #900; }
  &[data-state="success"] { color: #3a6b84; }
}

.contact-form[data-sent] :is(label, .submit) { display: none; }

@media (max-width: 760px) {
  .contact { grid-template-columns: 1fr; }
  .contact-hint { display: none; }
  .contact-form { max-width: none; }
}

/* ---- Footer ---- */
.site-footer {
  padding: 1.25rem 5%;
  background: #000;
  color: rgb(255 255 255 / .45);
  font-size: .8rem;
  text-align: center;
  p { margin: 0; }
}

/* --------------------------------------------------------------------------
   Lightbox (native <dialog>)
   -------------------------------------------------------------------------- */

.lightbox {
  --accent: var(--orange);
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #fff;
  overflow: hidden;

  opacity: 0;
  transition: opacity .3s ease, overlay .3s allow-discrete, display .3s allow-discrete;

  &[open] {
    display: grid;
    place-items: center;
    opacity: 1;
    @starting-style { opacity: 0; }
  }

  &::backdrop {
    background: rgb(0 0 0 / 0);
    backdrop-filter: blur(0);
    transition: background .3s, backdrop-filter .3s, overlay .3s allow-discrete, display .3s allow-discrete;
  }
  &[open]::backdrop {
    background: rgb(0 0 0 / .82);
    backdrop-filter: blur(6px);
    @starting-style { background: rgb(0 0 0 / 0); backdrop-filter: blur(0); }
  }
}

.lightbox-figure {
  margin: 0;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: clamp(3.5rem, 6vw, 4.5rem) clamp(.75rem, 6vw, 5.5rem) calc(4rem + env(safe-area-inset-bottom));
  touch-action: pan-y pinch-zoom;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid #ccc;
  box-shadow: 0 30px 80px rgb(0 0 0 / .6);
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity .25s ease, scale .35s var(--ease-out), translate .35s var(--ease-out);

  .lightbox[open] & { @starting-style { scale: .92; opacity: 0; } }
  &.is-loading { opacity: 0; scale: .97; }
}

.lightbox-caption {
  position: fixed;
  inset: auto 0 0 0;
  padding: .7em 1em calc(.7em + env(safe-area-inset-bottom));
  background: var(--accent);
  color: var(--on-accent, #fff);
  text-align: center;
  text-shadow: none;
  font-size: clamp(.9rem, .8rem + .4vw, 1.15rem);
  transition: background-color .35s ease;
  &:empty { display: none; }
}

.lb-btn {
  position: fixed;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / .25);
  border-radius: 50%;
  background: rgb(0 0 0 / .45);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .2s, border-color .2s, scale .2s var(--ease-out);

  svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

  &:hover, &:focus-visible { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); scale: 1.08; }
}
.lb-close { top: max(12px, env(safe-area-inset-top)); right: 12px; }
.lb-prev  { left: 12px;  top: 50%; translate: 0 -50%; }
.lb-next  { right: 12px; top: 50%; translate: 0 -50%; }

.lb-counter {
  position: fixed;
  top: max(22px, calc(env(safe-area-inset-top) + 10px));
  left: 18px;
  margin: 0;
  font-size: .9rem;
  letter-spacing: .1em;
  color: rgb(255 255 255 / .7);
}

@media (max-width: 760px), (pointer: coarse) {
  /* on phones, swipe & tap the image instead; keep the arrows small & low */
  .lb-prev, .lb-next { top: auto; bottom: calc(3.6rem + env(safe-area-inset-bottom)); translate: none; width: 42px; height: 42px; }
}
