:root {
  --ink: #000;
  --bg: #fff;
}

@font-face {
  font-family: "Kern";
  src: url("fonts/kern.otf") format("opentype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Kern";
  overflow: hidden;
}

a {
  color: #000;
  text-decoration: none;
}

a:hover,
.selected {
  color: #00ff00;
  text-decoration: none;
}

.page {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background: #fff;
}

.page-flipper {
  position: absolute;
  inset: 0;
}

.screen,
.page-flipper .face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100svh;
  overflow: hidden;
  background: #fff;
}

.page-flipper .face.back {
  display: none;
}

.page-flipper .face.back.is-active {
  display: block;
}

.page-flipper.is-flipped .face.front {
  display: none;
}

html.subpage-mode,
body.subpage-mode {
  overflow-y: auto;
}

body.subpage-mode .page {
  overflow: visible;
  min-height: auto;
}

body.subpage-mode .page-flipper {
  position: relative;
  inset: auto;
}

body.subpage-mode .page-flipper .face.back.is-active {
  position: relative;
  inset: auto;
  height: auto;
  overflow: visible;
  padding-bottom: 8vw;
}

h1 {
  position: absolute;
  top: 0;
  left: 3.125%;
  z-index: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 6.5vw;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: bold;
  line-height: 0.85;
  letter-spacing: -0.01em;
  white-space: nowrap;
  color: var(--ink);
  transition: color 0.15s linear;
}

h1.title-on-image {
  color: #fff;
}

.title-line2 {
  display: inline-block;
  margin-left: 0.06em;
}

.home-intro {
  position: absolute;
  top: 16vw;
  left: 3.125%;
  z-index: 2;
  width: 46%;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1.05vw;
  line-height: 1.5;
  color: var(--ink);
  pointer-events: none;
  transition: opacity 0.2s linear;
}

.home-intro h2 {
  font-size: 1.05vw;
  font-weight: normal;
  margin: 1.4em 0 0;
}

.home-intro h2:first-child {
  margin-top: 0;
}

.home-intro p {
  margin: 0.4em 0 0;
  text-indent: 2em;
}

.page-single-project-container {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  perspective: 2000px;
}

.page-single-project {
  position: absolute;
  top: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(0deg);
  transform-style: preserve-3d;
}

.page-single-project .face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
}

.page-single-project .project-front {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow-x: scroll;
  overflow-y: hidden;
  outline: 0;
  user-select: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: url("img/arrownextkern.svg") 22 22, e-resize;
}

.page-single-project .project-front::-webkit-scrollbar {
  display: none;
}

.page-single-project .project-front.clickable-left {
  cursor: url("img/arrowprevkern.svg") 22 22, w-resize;
}

.page-single-project .project-front.clickable-right {
  cursor: url("img/arrownextkern.svg") 22 22, e-resize;
}

.page-single-project .project-front.is-dragging {
  cursor: grabbing;
}

#container-photos {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  gap: 0;
  width: max-content;
  height: 100%;
  box-sizing: border-box;
  padding-left: 50%;
  padding-right: 50vw;
}

.diy-screen {
  overflow-y: auto;
  display: block;
}

.model-viewer-page {
  position: relative;
  width: 100%;
  height: 95vh;
  height: 95svh;
  background: #fff;
}

.model-viewer-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.diy-instructions {
  box-sizing: border-box;
  width: 100%;
  padding: 4vw 3.125% 8vw;
  font-size: 1.1vw;
  line-height: 1.5;
}

.howto-title {
  text-align: center;
  font-family: "Kern", serif;
  font-weight: normal;
  font-size: 2.8vw;
  margin: 0 0 4vw;
  padding-top: 2vw;
}

.diy-screen > .howto-title {
  padding-top: 1vw;
  margin-bottom: 0;
}

.howto-content {
  box-sizing: border-box;
  width: 100%;
  padding: 4vw 3.125% 8vw;
}

.howto-text {
  width: 93.75%;
  margin: 0 auto 5vw;
  font-size: 1.1vw;
  line-height: 1.6;
}

.howto-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4vw;
}

.howto-col-intro {
  margin: 0 0 1em;
  color: #444;
}

.howto-section-title {
  font-size: 1.15vw;
  font-weight: bold;
  margin: 0 0 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.howto-steps {
  padding-left: 1.4em;
  margin: 0;
}

.howto-steps li {
  margin-bottom: 0.6em;
}

code {
  font-family: monospace;
  background: #f0f0f0;
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.howto-note {
  margin-top: 2em;
  font-size: 1vw;
  color: #666;
  border-top: 1px solid #e0e0e0;
  padding-top: 1em;
}

.howto-video-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 auto 5vw;
}

.howto-video-block:last-child {
  margin-bottom: 0;
}

.howto-video {
  display: block;
  width: 100%;
  max-width: 56vw;
  background: #000;
}

.howto-caption {
  margin: 1.2vw 0 0;
  font-size: 1.4vw;
  text-align: center;
}

.diy-legend {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin-bottom: 1.5vw;
  font-weight: bold;
}

.diy-legend .diy-badge {
  margin-left: 0.6em;
}

.diy-legend .diy-badge:first-child {
  margin-left: 0;
}

.diy-intro {
  margin-bottom: 2vw;
  font-weight: bold;
}

.diy-download-link {
  color: inherit;
  text-decoration: underline;
}

.diy-section-title {
  font-size: 1.4vw;
  font-weight: bold;
  margin: 3vw 0 0.5vw;
}

.diy-section-intro {
  margin-bottom: 1.5vw;
}

.diy-steps {
  list-style: none;
  padding-left: 0;
  counter-reset: diy-step;
}

.diy-steps--roof {
  counter-reset: diy-step;
}

.diy-steps > li {
  counter-increment: diy-step;
  display: flex;
  align-items: center;
  gap: 2vw;
  margin-bottom: 1.5vw;
  padding-bottom: 1.5vw;
  border-bottom: 1px solid #e5e5e5;
}

.diy-step-text {
  flex: 0 0 38%;
  min-width: 0;
}

.diy-step-text--full {
  flex: 1 1 100%;
}

.diy-step-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 0.3em;
}

.diy-badge-group {
  flex: 0 0 auto;
  display: flex;
  gap: 0.2em;
  width: 4.6em;
}

.diy-step-row p {
  margin: 0;
}

.diy-step-row p::before {
  content: counter(diy-step) ". ";
  font-weight: bold;
}

.diy-badge {
  display: inline-block;
  flex: 0 0 auto;
  width: 1.4em;
  height: 1.4em;
  object-fit: contain;
}

.diy-substeps {
  margin: 0.3em 0 0 2.6em;
  padding: 0;
}

.diy-step-image-frame {
  flex: 1 1 auto;
  width: auto;
  height: 32vw;
  display: flex;
  align-items: center;
  justify-content: center;
}

.diy-step-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: url(#diy-thicken-lines);
}

.contact-content {
  box-sizing: border-box;
  width: 100%;
  padding: 4vw 3.125% 8vw;
}

.contact-title {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 300;
  font-size: 6.5vw;
  line-height: 0.9;
  margin: 0 0 3vw;
}

.contact-body {
  max-width: 46%;
  font-size: 1.1vw;
  line-height: 1.6;
}

.contact-intro {
  margin: 0 0 1.5em;
}

.contact-email {
  display: block;
  font-size: 1.4vw;
  font-weight: bold;
  color: #000;
  text-decoration: none;
  margin-bottom: 1.5em;
}

.contact-email:hover {
  color: #00ff00;
}

.contact-happy {
  margin: 0 0 0.6em;
}

.contact-list {
  padding-left: 1.2em;
  margin: 0 0 2em;
}

.contact-list li {
  margin-bottom: 0.6em;
}

.contact-footer {
  margin: 0;
  color: #666;
  font-size: 1vw;
}

@media (max-width: 760px) {
  .diy-instructions {
    font-size: 3.5vw;
  }

  .diy-legend {
    flex-wrap: wrap;
  }
}

#container-photos img {
  flex: 0 0 auto;
  display: block;
  width: auto;
  height: 100%;
  margin-right: -1px;
  user-drag: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 3;
  display: flex;
  box-sizing: border-box;
  padding-left: 3.125%;
  padding-right: 3.125%;
  padding-bottom: 3.125%;
  font-size: 3vw;
}

.nav a {
  flex: 1;
  color: #000;
  font-size: inherit;
  font-weight: normal;
  line-height: 1;
  letter-spacing: 0;
  text-decoration: none;
  white-space: nowrap;
  text-align: center;
  align-self: flex-end;
  transition: color 0.12s linear;
}

.nav a:first-child {
  text-align: center;
}

.nav a:last-child {
  text-align: center;
}

.nav a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 8px;
}

.nav a.nav-on-image {
  color: #fff;
}

.nav a:hover,
.nav a:focus-visible,
.nav a.selected {
  color: #00ff00;
}

@media (max-width: 1180px) {
  #container-photos {
    padding-left: 45%;
  }
}

@media (max-width: 760px) {
  .page {
    min-height: 100svh;
  }

  h1 {
    left: 3.125%;
    width: 93.75%;
    font-size: 12vw;
    line-height: 16vw;
    white-space: normal;
  }

  .home-intro {
    position: relative;
    top: auto;
    left: auto;
    width: 93.75%;
    margin: 36vw auto 0;
    font-size: 3.5vw;
  }

  .home-intro h2 {
    font-size: 3.5vw;
  }

  #container-photos {
    padding-left: 24%;
  }

  .nav {
    padding-left: 3.125%;
    padding-right: 3.125%;
    padding-bottom: 5vw;
    font-size: 8vw;
  }

  .nav a {
    font-size: inherit;
  }
}

@media (max-width: 430px) {
  h1 {
    font-size: 12vw;
  }

  #container-photos {
    padding-left: 18%;
  }
}

/* Carousel dots are only shown on phones */
.carousel-dots {
  display: none;
}

/* =========================================================
   Phone & tablet layout
   (everything below only applies on smaller screens;
   the desktop design above is unchanged)
   ========================================================= */

/* Tablets / small laptops: keep text from getting too small */
@media (min-width: 761px) and (max-width: 1180px) {
  .home-intro,
  .home-intro h2,
  .diy-instructions,
  .howto-text,
  .contact-body {
    font-size: max(1.1vw, 14px);
  }

  .howto-section-title {
    font-size: max(1.15vw, 14px);
  }

  .howto-note,
  .contact-footer {
    font-size: max(1vw, 13px);
  }

  .howto-caption,
  .contact-email,
  .diy-section-title {
    font-size: max(1.4vw, 16px);
  }
}

/* Phones */
@media (max-width: 760px) {
  /* Let the whole page scroll vertically */
  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .page {
    overflow: visible;
    min-height: auto;
  }

  .page-flipper {
    position: relative;
    inset: auto;
  }

  .page-flipper .face.front {
    position: relative;
    inset: auto;
    height: auto;
    overflow: visible;
    padding-bottom: 90px; /* room for the menu bar */
    /* order on phones: title, then images, then text */
    display: flex;
    flex-direction: column;
  }

  .page-flipper .face.front h1 {
    order: 1;
  }

  .page-flipper .face.front .page-single-project-container {
    order: 2;
  }

  .page-flipper .face.front .home-intro {
    order: 3;
  }

  body.subpage-mode .page-flipper .face.back.is-active {
    padding-bottom: 90px;
  }

  /* ---------- Home ---------- */
  h1 {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    padding: 4vw 5% 0;
    font-size: 15vw;
    line-height: 0.9;
  }

  h1.title-on-image {
    color: var(--ink);
  }

  .home-intro {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    margin: 0;
    padding: 8vw 5% 0;
    font-size: 16px;
    opacity: 1 !important; /* no fade-out on phones */
  }

  .home-intro h2 {
    font-size: 16px;
    font-weight: bold;
  }

  /* Photo carousel becomes a swipeable strip under the text */
  /* Sized so the next image peeks in at the right edge */
  .page-single-project-container {
    position: relative;
    flex: none;
    height: min(105vw, 62svh);
    margin-top: 6vw;
  }

  .page-single-project .project-front {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 5vw;
  }

  #container-photos {
    padding-left: 5vw;
    padding-right: 5vw;
  }

  #container-photos img {
    margin-right: 8px;
    scroll-snap-align: start;
  }

  /* Dots under the images */
  .carousel-dots {
    order: 2;
    display: flex;
    justify-content: center;
    gap: 2px;
    margin-top: 10px;
  }

  .carousel-dots button {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .carousel-dots button::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid #000;
    background: transparent;
    transition: background 0.15s linear;
  }

  .carousel-dots button.is-active::before {
    background: #000;
  }

  /* ---------- Menu bar ---------- */
  .nav {
    gap: 4px;
    padding: 14px 3% calc(14px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #e5e5e5;
    font-size: clamp(14px, 4.2vw, 18px);
  }

  .nav a {
    white-space: normal;
    line-height: 1.15;
    align-self: center;
  }

  .nav a.nav-on-image {
    color: #000;
  }

  .nav a.selected,
  .nav a:focus-visible {
    color: #00ff00;
  }

  /* ---------- Building guide ---------- */
  .howto-title {
    font-size: 26px;
    margin-bottom: 6vw;
    padding: 6vw 5% 0;
  }

  .model-viewer-page {
    height: 65svh;
  }

  /* Swipe sideways to turn the 3D model, swipe up/down to scroll the page */
  .model-viewer-page canvas {
    touch-action: pan-y !important;
  }

  .diy-instructions {
    padding: 6vw 5% 10vw;
    font-size: 16px;
  }

  .diy-legend {
    gap: 6px;
    margin-bottom: 20px;
  }

  .diy-intro {
    margin-bottom: 24px;
  }

  .diy-section-title {
    font-size: 21px;
    margin: 36px 0 8px;
  }

  .diy-section-intro {
    margin-bottom: 20px;
  }

  .diy-steps > li {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 24px;
  }

  .diy-step-text {
    flex: none;
    width: 100%;
  }

  .diy-step-row {
    align-items: flex-start;
    margin-bottom: 0.7em;
  }

  .diy-badge-group {
    width: auto;
    margin-right: 12px;
    padding-top: 0.05em;
  }

  .diy-step-image-frame {
    flex: none;
    width: 100%;
    height: 75vw;
  }

  .diy-step-image-frame:empty {
    display: none;
  }

  /* ---------- Using files ---------- */
  .howto-content {
    padding: 6vw 5% 10vw;
  }

  .howto-content .howto-title {
    padding: 0;
  }

  .howto-text {
    width: 100%;
    margin-bottom: 40px;
    font-size: 16px;
  }

  .howto-columns {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .howto-section-title {
    font-size: 15px;
  }

  .howto-note {
    font-size: 14px;
  }

  .howto-video-block {
    margin-bottom: 36px;
  }

  .howto-video {
    max-width: 100%;
  }

  .howto-caption {
    margin-top: 10px;
    font-size: 15px;
  }

  code {
    overflow-wrap: anywhere;
  }

  /* ---------- Contact ---------- */
  .contact-content {
    padding: 6vw 5% 10vw;
  }

  .contact-title {
    font-size: 15vw;
    margin-bottom: 8vw;
  }

  .contact-body {
    max-width: 100%;
    font-size: 16px;
  }

  .contact-email {
    font-size: 19px;
    overflow-wrap: anywhere;
  }

  .contact-footer {
    font-size: 14px;
  }
}
