:root {
  --bg: #ffffff;
  --panel: #e6e2db;
  --ink: #1c1c1a;
  --muted: #6b6860;
  --accent: #a39a6a;          /* olive underline */
  --gutter: 28px;
  --mono: "IBM Plex Mono", "Courier New", monospace;
  --sans: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

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

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--gutter) var(--gutter) 0;
}

/* ---------- Panel ---------- */
.panel {
  flex: 1;
  position: relative;
  background: var(--bg);        /* white around uncropped images */
  min-height: 320px;
  overflow: hidden;
}

.view { position: absolute; inset: 0; }
.view[hidden] { display: none; }

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 6px 18px;
}
.brand { margin-right: auto; }

/* ENG | ESP switch, right side of the title line */
.lang-toggle {
  flex: none;
  display: flex;
  align-items: baseline;
  gap: .5em;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .2em;
  color: var(--muted);
}
.lang-toggle button {
  background: none;
  border: 0;
  border-bottom: 1.5px solid transparent;
  padding: 2px 0 1px;
  margin-right: -.2em;          /* letter-spacing would leave a gap after the word */
  font: inherit;
  letter-spacing: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease;
}
.lang-toggle button:hover { color: var(--ink); }
.lang-toggle button.is-active { color: var(--ink); border-bottom-color: var(--accent); }

.brand {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-family: var(--mono);
  text-transform: uppercase;
}

.brand__part {
  font-weight: 300;
  font-size: clamp(15px, 1.5vw, 20px);
  letter-spacing: .34em;
}

.brand__dash {
  width: 28px;
  height: 1px;
  background: var(--accent);
  align-self: center;
}

/* ---------- Home: video ---------- */
.view--home { animation: fade 1.2s ease both; }
/* fills the panel from side to side; the clip is cropped to fit */
.landing-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: var(--panel);     /* beige while it loads */
  /* calmer look: softer colors and contrast, slightly warm */
  filter: saturate(.72) contrast(.9) brightness(1.04) sepia(.12);
  opacity: 0;
  transition: opacity 2s ease;
}
.landing-video.is-shown { opacity: 1; }
/* the two copies of the clip the canvas draws from */
.landing-source {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Carousel (project galleries): center image, neighbours partly visible */
.carousel { --slide: 72%; --gap: 14px; }
.gallery.carousel img {
  inset: 0 auto;
  left: 50%;
  width: var(--slide);
  transform: translateX(calc(-50% + var(--off, 0) * (100% + var(--gap))));
  transition: transform .9s cubic-bezier(.45, 0, .2, 1), opacity .9s ease;
}
.gallery.carousel img.is-side { opacity: .55; cursor: pointer; }
.gallery.carousel img.is-side:hover { opacity: .8; }

/* ---------- Project view ---------- */
.view--project { display: flex; flex-direction: column; }

.gallery {
  flex: 1;
  position: relative;
  cursor: e-resize;
}

.gallery img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s ease;
}
.gallery img.is-active { opacity: 1; }

.gallery__empty {
  position: absolute;
  inset: 0;
  background: var(--panel);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .3em;
  font-size: 12px;
  color: var(--muted);
}

.project-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 6px 0;          /* white, text lined up with the abstract */
}
/* dog centered on the project name line */
.project-bar .dog { align-self: flex-start; margin-top: -15px; }

/* Arrows only: no image numbers */
#counter { display: none; }

.project-title {
  margin: 0;
  font-family: var(--mono);
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: .3em;
  font-size: 13px;
}

/* Small bare arrows over the images; they invert against what's behind
   them (dark on white margins, light on dark renders) */
.gallery-wrap { flex: 1; position: relative; overflow: hidden; }
#gallery { position: absolute; inset: 0; }

.gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  padding: 10px 6px;            /* bigger hit area than the arrow itself */
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1;
  color: #fff;
  mix-blend-mode: difference;
  cursor: pointer;
  transition: opacity .2s ease;
}
.gallery-arrow[hidden] { display: none; }
.gallery-arrow:hover { opacity: .6; }
.gallery-arrow--prev { left: 14px; }
.gallery-arrow--next { right: 14px; }

/* Project images: one at a time, whole image on white (never cropped);
   click opens full size */
#gallery { cursor: zoom-in; }
#gallery img { object-fit: contain; }

/* ---------- Full-size image viewer ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 72px;
  background: rgba(255, 255, 255, .97);
  animation: fade .3s ease both;
}
.lightbox[hidden] { display: none; }

.lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-out;
}

.lightbox button {
  position: absolute;
  background: none;
  border: 0;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
}
.lightbox button:hover { color: var(--accent); }
.lightbox__close { top: 10px; right: 14px; font-size: 30px; }
.lightbox__arrow { top: 50%; transform: translateY(-50%); }
.lightbox__arrow--prev { left: 14px; }
.lightbox__arrow--next { right: 14px; }

body.no-scroll { overflow: hidden; }

/* ---------- Project details band ---------- */
.project-info {
  display: flex;                /* text from side to side */
  padding: 26px 6px 28px;
  animation: fade .6s ease both;
}
.project-info[hidden] { display: none; }

/* Name + specs side by side in the beige bar */
.project-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 36px;
}

.project-specs {
  display: grid;                /* building names in one column, numbers aligned */
  grid-template-columns: max-content 1fr;
  gap: 4px 0;
  margin: 0;
  font-family: var(--mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: .22em;
  font-size: 11px;
  color: var(--muted);
}
.project-specs:empty { display: none; }
.project-specs__row { display: flex; flex-wrap: wrap; grid-column: 2; }
.project-specs__row:first-child { grid-column: 1 / -1; }   /* no building name */
.project-specs b {
  font-weight: 400;
  color: var(--ink);
  margin-right: 1.4em;
  white-space: nowrap;
}
.project-specs span { white-space: nowrap; }
.project-specs span + span::before {
  content: "·";
  margin: 0 .9em;
  color: var(--accent);
}

.project-about {
  display: grid;
  gap: 26px;
  font-size: 15px;
  line-height: 1.65;
  color: #3a3833;
}
.project-about p + p { margin-top: .8em; }
.project-about p {
  margin: 0;
  text-align: justify;
  hyphens: manual;             /* never split words with a hyphen at line ends */
}
.project-about [hidden] { display: none; }

.project-about { flex: 1; min-width: 0; }

/* description in two justified columns (one column on phones and for short texts) */
@media (min-width: 761px) {
  .project-about > div:not(.is-short) {
    column-count: 2;
    column-gap: 56px;
  }
  .project-about p { orphans: 3; widows: 3; }   /* no lone lines at a column break */
}

/* Inside a project: images fill the screen, text is below the fold,
   and the menu is hidden; only the dog remains to go back home */
.is-project .panel { flex: none; height: calc(100vh - 90px); height: calc(100dvh - 90px); min-height: 420px; }
.is-project .footer { display: none; }

/* ---------- Contact view ---------- */
.view--contact {
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade .6s ease both;
}
.contact { text-align: center; font-size: 15px; }
/* two buttons under the contact details */
.contact .contact__more {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
}
.contact a.contact__button {
  border: 1px solid var(--ink);
  padding: 9px 14px 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  transition: background .2s ease, color .2s ease;
}
.contact a.contact__button:hover { background: var(--ink); color: var(--panel); }
.view--contact.has-photo .contact__more { justify-content: flex-start; }
.cv__page[hidden] { display: none; }

/* ---------- Education and completed projects ---------- */
.view--cv {
  background: var(--panel);
  overflow-y: auto;
  animation: fade .6s ease both;
}
.cv {
  max-width: 640px;
  margin: 0 auto;
  padding: clamp(28px, 6vh, 64px) 24px 40px;
  font-size: 15px;
  line-height: 1.6;
}
.cv__back {
  display: inline-block;
  margin-bottom: 28px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}
.cv__back:hover { color: var(--ink); }
.cv .project-title { margin: 0 0 14px; }
.cv__list { list-style: none; margin: 0 0 36px; padding: 0; }
.cv__list li { padding: 8px 0; border-top: 1px solid rgba(28, 28, 26, .12); }
.cv__list li:last-child { border-bottom: 1px solid rgba(28, 28, 26, .12); }
.cv__soon { color: var(--muted); }

/* completed projects: name · place · year in columns */
.cv:has(.cv__list--projects:not(:empty)) { max-width: 820px; }
.cv__list--projects li {
  display: grid;
  grid-template-columns: 1fr auto 3.2em;
  gap: 4px 24px;
  align-items: baseline;
}
.work__place { color: var(--muted); font-size: 14px; text-align: right; }
.work__year { font-family: var(--mono); font-size: 12px; letter-spacing: .1em; color: var(--muted); text-align: right; }
a.work__name { border-bottom: 1px solid var(--accent); justify-self: start; }
a.work__name:hover { color: var(--accent); }
.cv h2.project-title { margin-top: 8px; }

/* Contact with a photo: photo on the left, details on the right */
.view--contact.has-photo { gap: clamp(32px, 6vw, 96px); padding: 32px; }
.view--contact.has-photo .contact { text-align: left; }
.contact__photo {
  height: 82%;
  width: auto;
  max-width: 45%;
  object-fit: contain;
  mix-blend-mode: multiply;     /* the collage's white paper disappears into the beige */
}
.contact .project-title { margin-bottom: 28px; }
.contact p { margin: 8px 0; }
.contact a { border-bottom: 1px solid var(--accent); }

/* ---------- Footer / menu ---------- */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(32px, 5vw, 80px);
  padding: 14px 6px 18px;
}

.menu {
  display: grid;
  grid-template-columns: repeat(7, auto);
  grid-template-rows: repeat(2, auto);
  justify-content: space-between;   /* spread columns evenly across the width */
  column-gap: 20px;
  row-gap: 4px;
  font-size: 15px;
  flex: 1;
}

.menu a {
  grid-column: var(--d-col);
  grid-row: var(--d-row);
  justify-self: start;
  line-height: 1.35;
  padding-bottom: 1px;
  border-bottom: 1.5px solid transparent;
  transition: border-color .2s ease;
}
.menu a:hover,
.menu a.is-active { border-bottom-color: var(--accent); }

.dog {
  flex: none;
  width: 56px;
  color: var(--ink);
  margin-right: 8px;
}
.dog img {
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;   /* drop the white background */
  transform-origin: 50% 90%;
}
.dog:hover img { animation: wag .5s ease; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  :root { --gutter: 16px; }

  .panel {
    flex: none;
    aspect-ratio: 4 / 4.6;
    min-height: 0;
    max-height: 72vh;
  }

  .header { padding: 0 0 14px; }
  .brand { flex-direction: column; gap: 6px; }
  .brand__part { font-size: clamp(12px, 3.6vw, 17px); letter-spacing: .16em; white-space: nowrap; }
  .brand__dash { display: none; }
  .header { gap: 12px; flex-wrap: wrap; }   /* very narrow phones: switch drops below the title */
  .lang-toggle { margin-left: auto; }
  .lang-toggle { font-size: 10px; letter-spacing: .12em; gap: .35em; }
  .lang-toggle button { margin-right: -.12em; }

  .carousel { --slide: 80%; --gap: 8px; }
  /* shorter, landscape home panel for the desert */
  .is-home .panel { aspect-ratio: 5 / 3.4; }

  .lightbox { padding: 56px 0; }
  .lightbox__arrow { top: auto; bottom: 8px; transform: none; }

  /* gallery same shape as the home carousel; name and specs flow below it */
  .is-project .panel { height: auto; min-height: 0; aspect-ratio: auto; max-height: none; overflow: visible; }
  .view--project { position: static; }
  .gallery-wrap { flex: none; aspect-ratio: 5 / 3.4; overflow: hidden; }
  .project-info { padding: 20px 0 28px; }

  /* contact with a photo: photo on top, details below, panel grows to fit */
  .is-contact .panel:has(.has-photo:not([hidden])),
  .is-contact .panel:has(.view--cv:not([hidden])) { aspect-ratio: auto; height: auto; max-height: none; }
  .view--cv { position: static; overflow: visible; }
  /* phones: name on its own line, place and year below it */
  .cv__list--projects li { grid-template-columns: 1fr auto; gap: 2px 12px; }
  .work__name { grid-column: 1 / -1; }
  .work__place { text-align: left; font-size: 13px; }
  .view--contact.has-photo { position: static; flex-direction: column; padding: 28px 16px 32px; gap: 24px; }
  .view--contact.has-photo .contact { text-align: center; }
  .view--contact.has-photo .contact__more { justify-content: center; }
  .contact__photo { height: auto; width: 70%; max-width: 280px; }
  .project-specs { font-size: 9px; letter-spacing: .12em; line-height: 1.5; }
  .project-head { gap: 2px 20px; }
  .project-specs span + span::before { margin: 0 .6em; }
  .project-about { font-size: 14px; }

  .footer {
    flex-direction: column;
    align-items: stretch;
    gap: 18px;
    padding: 12px 0 28px;
  }

  .menu {
    grid-template-columns: repeat(3, auto);   /* desktop order, read down each column */
    grid-template-rows: repeat(5, auto);
    justify-content: space-between;
    column-gap: 10px;
    row-gap: 4px;
    font-size: clamp(13px, 4vw, 15px);
    max-width: none;
  }
  .menu a { grid-column: var(--m-col); grid-row: var(--m-row); }
  /* Contact alone on the last row, lined up with the second column */
  .menu a[href="#contact"] { margin-top: 8px; }

  .dog { align-self: center; width: 48px; margin: 0; }

  .project-bar { gap: 10px; padding: 12px 0 0; }
  .project-bar .dog { align-self: flex-start; width: 42px; margin: -9px 0 0; }
  .gallery-arrow { font-size: 15px; }
  .gallery-arrow--prev { left: 4px; }
  .gallery-arrow--next { right: 4px; }
  .project-title { font-size: 11px; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes wag {
  0%, 100% { transform: rotate(0); }
  30% { transform: rotate(-6deg); }
  70% { transform: rotate(4deg); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
