:root {
  --sidebar-width: 220px;
  --gutter: 32px;
  --text: #111;
  --muted: #777;
  --rule: #d7d7d7;
  --max-content: 1180px;
  --gallery-gap: 20px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: #fff;
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-transform: lowercase;
}

button,
input,
textarea,
select {
  font: inherit;
  text-transform: lowercase;
}

img { border: 0; }

/* all site links: grey regular; active/hover/focus: black bold */
a {
  color: var(--muted);
  font-weight: 400;
  text-decoration: none;
}

a:hover,
a:focus-visible,
a:active,
a.active,
a[aria-current="page"] {
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  outline: none;
}

button:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 3px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  padding: calc(25px + env(safe-area-inset-top, 0px)) 24px calc(20px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  background: #fff;
  border-right: 1px solid var(--rule);
  z-index: 10;
}

.site-name {
  position: relative;
  display: block;
  width: fit-content;
  letter-spacing: .03em;
}

.site-name::before,
.primary-nav > a::before {
  content: "";
  position: absolute;
  inset: -7px -10px;
}

.site-subtitle {
  min-height: 1.4em;
  margin-top: 2px;
  margin-bottom: 32px;
  color: var(--muted);
}

.primary-nav > a {
  position: relative;
  display: block;
  width: fit-content;
  margin: 0 0 7px;
  letter-spacing: .02em;
}

.sidebar-footer {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 11px;
}

.content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(25px + env(safe-area-inset-top, 0px)) var(--gutter) calc(55px + env(safe-area-inset-bottom, 0px));
}

.page { width: min(100%, var(--max-content)); }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr);
  gap: clamp(28px, 6vw, 90px);
  align-items: start;
}

.home-image-wrap,
.slide-figure,
.film-figure { margin: 0; }

.home-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100vh - 50px);
  max-height: calc(100dvh - 50px - env(safe-area-inset-top, 0px));
  object-fit: contain;
  object-position: top left;
}

.about-copy {
  max-width: 380px;
  padding-top: 1px;
}

.about-copy p { margin: 0 0 1.35em; }
.about-copy p:last-child { margin-bottom: 0; }

/* work gallery */
.work-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gallery-gap);
  align-items: start;
}

.gallery-card {
  position: relative;
  display: block;
  min-width: 0;
  color: var(--text);
  font-weight: 400;
  overflow: hidden;
}

.gallery-thumb {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #fff;
}

/*
  Never crop gallery artwork.
  The thumbnail keeps its fixed 4:3 box, while the image keeps its own
  aspect ratio and is scaled down only as much as needed to fit inside it.
  Wide images leave white space below; tall images leave white space at the sides.
*/
.gallery-thumb img {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: contain !important;
  object-position: top center !important;
  flex: 0 0 auto;
}

.gallery-info {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  background: rgba(255, 255, 255, .88);
  color: var(--text);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}

.gallery-title { font-weight: 700; }
.gallery-meta,
.gallery-description { color: #555; }
.gallery-description { margin-top: 6px; }

.gallery-card:hover .gallery-info,
.gallery-card:focus-visible .gallery-info {
  opacity: 1;
}


.gallery-empty {
  margin: 0;
  color: var(--muted);
}

/* single-artwork detail view */
.work-detail[hidden],
.work-gallery[hidden] { display: none !important; }

.work-media {
  position: relative;
  width: max-content;
  max-width: 100%;
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.work-media.is-normalized { max-width: none; }

.work-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 105px);
  max-height: calc(100dvh - 105px - env(safe-area-inset-top, 0px));
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: top left;
}

.work-media.is-normalized .work-image {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}

.hover-arrow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  border: 0;
  padding: 0 18px;
  background: transparent;
  color: #111;
  opacity: 0;
  cursor: pointer;
  transition: opacity .12s ease;
}

.hover-arrow span {
  display: inline-block;
  padding: 2px 5px 3px;
  background: rgba(255,255,255,.86);
}

.hover-arrow-prev {
  left: 0;
  text-align: left;
  cursor: w-resize;
}

.hover-arrow-next {
  right: 0;
  text-align: right;
  cursor: e-resize;
}

.work-media:hover .hover-arrow,
.hover-arrow:focus-visible { opacity: 1; }

.work-caption {
  max-width: 980px;
  margin-top: 9px;
}

.work-caption-text { min-width: 0; }
.muted { color: var(--muted); }
#work-details:not(:empty)::before { content: " — "; }

.work-description {
  max-width: 650px;
  margin-top: 17px;
  color: var(--muted);
}

.work-description:empty { display: none; }

.film-projects {
  display: grid;
  gap: 42px;
}

.film-project {
  display: grid;
  grid-template-columns: 120px minmax(220px, 1fr);
  gap: 24px;
  align-items: start;
  scroll-margin-top: 25px;
}

/* keep the slpwkr mark intentionally small */
.film-figure {
  width: 120px;
}

.film-still {
  display: block;
  width: auto;
  height: auto;
  max-width: 110px;
  max-height: 110px;
  object-fit: contain;
  object-position: top left;
}

/* automatic film-poster thumbnails: exact 27:40 poster proportion */
.film-posters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 150px));
  gap: 22px 18px;
  align-items: start;
  justify-content: start;
  margin-top: 42px;
}

.film-poster {
  margin: 0;
  width: 100%;
}

.film-poster-frame {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  aspect-ratio: 27 / 40;
  overflow: hidden;
  background: #fff;
}

.film-poster-frame img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: top center;
}

.film-info h2 {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 400;
}

.film-title-link { display: inline-block; }

.film-meta {
  margin-bottom: 15px;
  color: var(--muted);
}

.film-info p {
  max-width: 390px;
  margin: 0 0 12px;
}

.film-video {
  width: min(100%, 760px);
  margin-top: 18px;
}

.film-video-embed {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  border: 0;
  background: #000;
}

video.film-video-embed {
  object-fit: contain;
}

.contact-page { max-width: 620px; }

.contact-page h1 {
  margin: 0 0 24px;
  font-size: 13px;
  font-weight: 700;
}

.contact-copy p { margin: 0 0 12px; }

.load-error,
.noscript-message {
  position: fixed;
  left: calc(var(--sidebar-width) + var(--gutter));
  right: var(--gutter);
  bottom: 24px;
  max-width: 720px;
  padding: 10px 12px;
  border: 1px solid #bbb;
  background: #fff;
  color: #444;
  font-size: 12px;
  z-index: 100;
}

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

@media (hover: none), (pointer: coarse) {
  .gallery-info {
    position: static;
    padding: 8px 0 0;
    background: transparent;
    opacity: 1;
  }

  .gallery-description { display: none; }

  .hover-arrow {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 900px) {
  .work-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root {
    --gutter: 18px;
    --gallery-gap: 16px;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: calc(18px + env(safe-area-inset-top, 0px)) max(var(--gutter), env(safe-area-inset-right, 0px)) 10px max(var(--gutter), env(safe-area-inset-left, 0px));
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }

  .site-subtitle { margin-bottom: 17px; }

  .primary-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
  }

  .primary-nav > a { margin: 0; }
  .sidebar-footer { display: none; }

  .content {
    margin-left: 0;
    padding: 20px max(var(--gutter), env(safe-area-inset-right, 0px)) calc(45px + env(safe-area-inset-bottom, 0px)) max(var(--gutter), env(safe-area-inset-left, 0px));
  }

  .home-grid {
    grid-template-columns: 1fr;
    gap: 22px;
  }

  .film-project {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 18px;
  }

  .film-figure { width: 88px; }
  .film-still { max-width: 82px; max-height: 82px; }

  .film-posters {
    grid-template-columns: repeat(auto-fill, minmax(96px, 126px));
    gap: 18px 14px;
    margin-top: 32px;
  }

  .home-image { max-height: none; }
  .about-copy { max-width: 620px; }

  .work-image {
    max-width: 100%;
    max-height: calc(100dvh - 165px);
  }

  .load-error,
  .noscript-message {
    left: var(--gutter);
    right: var(--gutter);
    bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 520px) {
  .work-gallery { grid-template-columns: 1fr; }
}

@media (max-height: 520px) and (orientation: landscape) and (max-width: 900px) {
  .sidebar { padding-top: max(10px, env(safe-area-inset-top, 0px)); }
  .site-subtitle { margin-bottom: 8px; }
  .content { padding-top: 12px; }
  .work-image { max-height: calc(100dvh - 105px); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .gallery-info,
  .hover-arrow { transition: none; }
}

/* technical finishing pass: crawlable/no-js baseline and shareable detail views */
.skip-link {
  position: fixed;
  left: 10px;
  top: 10px;
  z-index: 1000;
  padding: 7px 9px;
  background: #fff;
  color: #111;
  font-weight: 700;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); }

.film-poster {
  display: block;
  color: inherit;
}

.film-poster-detail[hidden],
.film-posters[hidden],
.film-projects[hidden] { display: none !important; }

.film-poster-detail-figure { margin: 0; }
.film-poster-detail-figure img {
  display: block;
  width: auto;
  height: auto;
  max-width: min(420px, 100%);
  max-height: calc(100dvh - 105px);
  object-fit: contain;
  object-position: top left;
}
.film-poster-detail-figure figcaption {
  margin-top: 9px;
  color: var(--muted);
}

/* No-JS visitors still get a complete, navigable portfolio because index.php
   renders the content before scripts run. */

/* private DESIGN page: server-rendered and usable without JavaScript */
.design-detail-nav {
  display: none;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: center;
  width: min(100%, 420px);
  margin-top: 18px;
}
.design-detail-nav > :first-child { justify-self: start; }
.design-detail-nav > :nth-child(2) { justify-self: center; }
.design-detail-nav > :last-child { justify-self: end; }

@media (hover: none), (pointer: coarse) {
  .design-detail-nav { display: grid; }
}
