/* ============================================================
   Jake Crowe — portfolio
   Aesthetic: warm riso print-shop / children's book
   Display: Fraunces  ·  Body: DM Sans
   ============================================================ */

:root {
  --paper:      #faf4e8;
  --paper-2:    #f3e9d5;
  --paper-card: #fffdf7;
  --ink:        #2e2620;
  --ink-soft:   #6f6457;
  --ink-faint:  #9a8f7f;
  --tomato:     #df5630;
  --tomato-deep:#c4441f;
  --teal:       #3a988a;
  --mustard:    #e7ad36;
  --blush:      #f0d3c2;
  --line:       #e6dac4;
  --line-soft:  #efe6d4;

  /* top-bar stripe — overridden per-visit by the theme script */
  --bar-1: #df5630;
  --bar-2: #e7ad36;
  --bar-3: #3a988a;

  --maxw: 1180px;
  --gap: clamp(1rem, 0.6rem + 1.6vw, 1.6rem);
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(46,38,32,.06), 0 2px 6px rgba(46,38,32,.05);
  --shadow-md: 0 6px 16px rgba(46,38,32,.10), 0 2px 6px rgba(46,38,32,.06);
  --shadow-lg: 0 18px 40px rgba(46,38,32,.16), 0 6px 14px rgba(46,38,32,.08);

  --step--1: clamp(0.82rem, 0.8rem + 0.1vw, 0.88rem);
  --step-0:  clamp(1rem, 0.96rem + 0.18vw, 1.08rem);
  --step-1:  clamp(1.18rem, 1.1rem + 0.4vw, 1.4rem);
  --step-2:  clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --h1:      clamp(2.2rem, 1.55rem + 2.9vw, 3.7rem);
}

/* fix typo-safe fallback */
* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* printed top edge */
body::after {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 6px;
  background: linear-gradient(90deg, var(--bar-1) 0 33%, var(--bar-2) 33% 66%, var(--bar-3) 66% 100%);
  z-index: 200;
}

/* faint paper grain */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .04;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

a { color: var(--tomato-deep); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--tomato); }

/* ---------- layout shell ---------- */
.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: clamp(1.1rem, 0.6rem + 2.4vw, 2.4rem);
  position: relative;
  z-index: 1;
}

/* ---------- header ---------- */
.site-header {
  position: sticky;
  top: 6px;
  z-index: 100;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.1) blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(255,255,255,.5), 0 6px 18px -12px rgba(46,38,32,.5);
}
.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-block: .85rem;
}

.brand {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--ink);
  line-height: 1;
}
.brand .name {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: .2px;
}
.brand:hover .name { color: var(--tomato-deep); }

.nav {
  display: flex;
  align-items: center;
  gap: clamp(.7rem, .3rem + 1.4vw, 1.6rem);
  flex-wrap: wrap;
}
.nav a {
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  font-size: var(--step--1);
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 2px;
  position: relative;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 100%;
  bottom: -2px;
  height: 2px;
  background: var(--tomato);
  transition: right .25s ease;
}
.nav a:hover { color: var(--ink); }
.nav a:hover::after { right: 0; }
.nav a.active { color: var(--tomato-deep); }
.nav a.active::after { right: 0; }

/* ---------- page intro ---------- */
.intro { padding-block: clamp(2.4rem, 1.6rem + 3vw, 4.2rem) clamp(1.4rem, 1rem + 2vw, 2.6rem); }
.kicker {
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--tomato-deep);
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin: 0 0 1rem;
}
.kicker::before {
  content: "";
  width: 28px; height: 2px;
  background: var(--tomato);
  display: inline-block;
}
h1.title {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: var(--h1);
  line-height: 1.04;
  letter-spacing: -0.5px;
  margin: 0 0 1rem;
  max-width: 18ch;
}
.lead {
  font-size: var(--step-1);
  color: var(--ink-soft);
  max-width: 56ch;
  margin: 0;
}

/* ---------- gallery (masonry) ---------- */
.gallery {
  columns: 1;
  column-gap: var(--gap);
  padding-bottom: clamp(2.5rem, 2rem + 3vw, 4.5rem);
}
@media (min-width: 620px)  { .gallery { columns: 2; } }
@media (min-width: 1000px) { .gallery { columns: 3; } }

.piece {
  break-inside: avoid;
  margin: 0 0 var(--gap);
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s ease;
  animation: riseIn .6s cubic-bezier(.2,.7,.2,1) both;
}
.piece:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}
.piece img {
  width: 100%;
  height: auto;
  background: var(--paper-2);
}
.piece figcaption {
  padding: .8rem .95rem 1rem;
}
.piece .pc-title {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.2;
  color: var(--ink);
  margin: 0;
}
.piece .pc-meta {
  font-size: var(--step--1);
  color: var(--ink-faint);
  letter-spacing: .03em;
  margin: .3rem 0 0;
}
.piece:hover .pc-title { color: var(--tomato-deep); }

/* staggered entrance */
.piece:nth-child(1){animation-delay:.02s}
.piece:nth-child(2){animation-delay:.08s}
.piece:nth-child(3){animation-delay:.14s}
.piece:nth-child(4){animation-delay:.20s}
.piece:nth-child(5){animation-delay:.26s}
.piece:nth-child(6){animation-delay:.32s}
.piece:nth-child(7){animation-delay:.38s}
.piece:nth-child(8){animation-delay:.44s}
.piece:nth-child(9){animation-delay:.50s}
.piece:nth-child(n+10){animation-delay:.56s}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* small placeholder marker */
.is-placeholder { position: relative; }
.is-placeholder::before {
  content: "placeholder";
  position: absolute;
  top: 10px; left: 10px;
  z-index: 2;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  background: var(--tomato);
  padding: 3px 7px;
  border-radius: 100px;
}

/* ---------- projects (expand in place) ---------- */
.projects {
  display: grid;
  gap: clamp(1.4rem, 1rem + 2vw, 2.4rem);
  padding-bottom: clamp(2.5rem, 2rem + 3vw, 4.5rem);
}
.project {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s ease;
}
.project:not(.open):hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}
.project-summary {
  display: grid;
  grid-template-columns: 1fr;
  cursor: pointer;
}
@media (min-width: 760px) {
  .project-summary { grid-template-columns: 1.05fr 1fr; }
  .project:nth-child(even) .project-summary .project-media { order: 2; }
}
.project-media {
  background: var(--paper-2);
  position: relative;
  min-height: 240px;
}
.project-media img { width: 100%; height: 100%; object-fit: cover; }
.project-body {
  padding: clamp(1.4rem, 1rem + 1.6vw, 2.4rem);
  display: flex;
  flex-direction: column;
  gap: .9rem;
  align-items: flex-start;
}
.badge {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: 5px 11px;
  border-radius: 100px;
  color: #fff;
}
.badge.dev    { background: var(--teal); }
.badge.early  { background: var(--mustard); color: #4a3a12; }
.project-body h2 {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: var(--step-2);
  line-height: 1.1;
  margin: 0;
}
.project-body p { margin: 0; color: var(--ink-soft); }
.project-spec {
  font-size: var(--step--1);
  color: var(--ink-faint);
  border-top: 1px dashed var(--line);
  padding-top: .9rem;
  margin-top: .3rem;
  width: 100%;
}
.project-more {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--tomato-deep);
  margin-top: .2rem;
}
.project.open .project-more { display: none; }

/* expandable detail region */
.project-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .38s cubic-bezier(.2,.7,.2,1);
}
.project.open .project-detail { grid-template-rows: 1fr; }
.project-detail > .detail-inner {
  overflow: hidden;
  min-height: 0;
  visibility: hidden;
  transition: visibility .38s;
}
.project.open .project-detail > .detail-inner { visibility: visible; }
.detail-inner {
  padding: clamp(1.4rem, 1rem + 1.6vw, 2.4rem);
  border-top: 1px solid var(--line);
}
.detail-inner > *:first-child { margin-top: 0; }
.detail-inner p { color: var(--ink-soft); margin: 0 0 1rem; }
.detail-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: .8rem;
  margin: 1.3rem 0;
}
.ph-tile {
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background:
    radial-gradient(120% 120% at 30% 20%, var(--blush), transparent 62%),
    var(--paper);
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-size: var(--step--1);
  text-align: center;
  padding: .5rem;
}
.project-collapse {
  margin-top: .4rem;
  background: none;
  border: none;
  color: var(--tomato-deep);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  letter-spacing: .04em;
  padding: .35rem 0;
}
.project-collapse:hover { color: var(--tomato); }

/* ---------- free stuff ---------- */
.freebies {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--gap);
  padding-bottom: clamp(2.5rem, 2rem + 3vw, 4.5rem);
}
.freebie {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform .28s cubic-bezier(.2,.7,.2,1), box-shadow .28s ease;
}
.freebie:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.freebie-media {
  aspect-ratio: 3 / 4;
  background: var(--paper-2);
}
.freebie-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.freebie-body {
  padding: 1.1rem 1.1rem 1.35rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  flex: 1;
}
.freebie-body h2 {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: var(--step-1);
  line-height: 1.15;
  margin: 0;
}
.freebie-body p {
  color: var(--ink-soft);
  font-size: var(--step--1);
  margin: 0;
  flex: 1;
}
.freebie .btn { margin-top: .7rem; align-self: flex-start; }

/* ---------- about ---------- */
.about {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.6rem, 1rem + 3vw, 3.4rem);
  align-items: start;
  padding-bottom: clamp(2.5rem, 2rem + 3vw, 4.5rem);
}
@media (min-width: 820px) { .about { grid-template-columns: 0.8fr 1.2fr; } }

.portrait {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 120% at 30% 20%, var(--blush), transparent 60%),
    var(--paper-card);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.portrait span {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  color: var(--ink-faint);
  font-size: 1.1rem;
}
.portrait::after {
  content: "photo";
  position: absolute;
  bottom: 12px; left: 12px;
  font-size: .62rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint);
  border: 1px solid var(--line);
  padding: 3px 8px; border-radius: 100px;
}
.about-body h2 {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: var(--step-2);
  margin: 0 0 1rem;
  line-height: 1.1;
}
.about-body p { color: var(--ink-soft); margin: 0 0 1rem; }
.about-body .signoff {
  font-family: "Fraunces", Georgia, serif;
  font-style: italic;
  color: var(--ink);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  font-size: var(--step-0);
  text-decoration: none;
  padding: .7rem 1.3rem;
  border-radius: 100px;
  border: 1.5px solid var(--tomato);
  background: var(--tomato);
  color: #fff;
  cursor: pointer;
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--tomato-deep); border-color: var(--tomato-deep); color:#fff; transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn.ghost { background: transparent; color: var(--tomato-deep); }
.btn.ghost:hover { background: var(--tomato); color: #fff; }

/* ---------- contact ---------- */
.contact {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.6rem, 1rem + 3vw, 3.2rem);
  padding-bottom: clamp(2.5rem, 2rem + 3vw, 4.5rem);
  align-items: start;
}
@media (min-width: 820px) { .contact { grid-template-columns: 1fr 1fr; } }

.contact-aside p { color: var(--ink-soft); }
.contact-aside .direct {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px dashed var(--line);
}
.contact-aside .direct a { font-weight: 600; }

form.card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(1.3rem, 1rem + 1.4vw, 2rem);
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 1rem;
}
.field { display: grid; gap: .4rem; }
.field label {
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field input,
.field textarea {
  font-family: inherit;
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem .85rem;
  width: 100%;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field textarea { min-height: 140px; resize: vertical; }
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--tomato);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tomato) 18%, transparent);
}

/* ---------- footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--paper-2);
  margin-top: 2rem;
}
.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
  padding-block: 1.6rem 2.2rem;
}
.foot-brand {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.15rem;
}
.foot-brand small {
  display: block;
  font-family: "DM Sans", sans-serif;
  font-weight: 400;
  font-size: var(--step--1);
  color: var(--ink-faint);
  letter-spacing: .02em;
  margin-top: 2px;
}
.foot-nav { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.foot-nav a {
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  text-decoration: none;
  color: var(--ink-soft);
}
.foot-nav a:hover { color: var(--tomato-deep); }
.foot-note { font-size: var(--step--1); color: var(--ink-faint); width: 100%; }

/* ---------- paired spread (two pages as one unit) ---------- */
.piece.spread .spread-pages {
  display: flex;
  gap: 2px;
  background: var(--line);
}
.piece.spread .spread-pages img {
  width: 50%;
  height: auto;
}

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 0.5rem + 3vw, 3rem);
  background: rgba(35, 28, 22, .82);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity .25s ease;
}
.lightbox.open { display: flex; opacity: 1; }

.lightbox-stage {
  position: relative;
  max-width: min(1100px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
}
.lightbox-figure {
  background: var(--paper-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 9rem);
  display: flex;
}
.lightbox-figure img {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  width: auto;
  height: auto;
  object-fit: contain;
}
.lightbox-figure.is-spread { gap: 2px; background: var(--line); }
.lightbox-figure.is-spread img { max-width: 50%; }

.lightbox-caption {
  text-align: center;
  color: var(--paper);
  max-width: 60ch;
}
.lightbox-caption .lb-title {
  font-family: "Fraunces", Georgia, serif;
  font-optical-sizing: auto;
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0;
  color: #fff;
}
.lightbox-caption .lb-meta {
  font-size: var(--step--1);
  letter-spacing: .03em;
  margin: .25rem 0 0;
  color: color-mix(in srgb, var(--paper) 78%, transparent);
}

.lb-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: color-mix(in srgb, var(--paper-card) 92%, transparent);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  transition: transform .15s ease, background .2s ease;
  z-index: 2;
}
.lb-btn:hover { background: #fff; transform: translateY(-50%) scale(1.08); }
.lb-prev { left: -8px; }
.lb-next { right: -8px; }
@media (min-width: 760px) {
  .lb-prev { left: -64px; }
  .lb-next { right: -64px; }
}
.lb-close {
  position: absolute;
  top: -14px;
  right: -8px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--tomato);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-md);
  z-index: 3;
}
@media (min-width: 760px) { .lb-close { top: -52px; right: -52px; } }
.lb-close:hover { background: var(--tomato-deep); }

.piece > button.piece-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  text-align: left;
  font: inherit;
  color: inherit;
}

/* ---------- a11y ---------- */
:focus-visible { outline: 2px solid var(--tomato); outline-offset: 2px; border-radius: 4px; }
.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--ink); color: #fff; padding: .6rem 1rem; z-index: 300; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

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