@font-face {
  font-family: "Host Grotesk";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("fonts/host-grotesk-normal-300-600.woff2") format("woff2");
}

@font-face {
  font-family: "Roboto Slab";
  font-style: normal;
  font-weight: 300 600;
  font-display: swap;
  src: url("fonts/roboto-slab-normal-300-600.woff2") format("woff2");
}

:root {
  --ink: #1d1d1b;
  --ink-soft: #4a4a46;
  --gold: #d4af37;
  --paper: #fff;
  --cream: #e7e6e4; /* the background of « Le nostre lavorazioni » on his current site */
  --cream-dark: #d4d3d1; /* the background of « Heritage and Vision » on his current site */
  --frame: 0.75rem; /* the white border around the photos of the hero's tiles */
  --heading: "Host Grotesk", "Helvetica Neue", Arial, sans-serif;
  --text: "Roboto Slab", Georgia, serif;
  --gutter: clamp(20px, 4vw, 56px);
  --header-height: 72px;
  --lang-width: 92px; /* the language switch's slab, for which the header keeps room on its right */
}

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

html {
  scroll-padding-top: var(--header-height);
  @media (prefers-reduced-motion: no-preference) {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

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

.visually-hidden:where(:not(:focus-within, :active)) {
  position: absolute !important;
  clip-path: inset(50%) !important;
  overflow: hidden !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  background: var(--ink);
  color: var(--paper);
  font: 500 15px/1 var(--heading);
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;

  &:hover {
    background: var(--gold);
    color: var(--ink);
  }
}

.button--outline {
  min-height: 44px;
  padding: 0 18px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--ink);

  &:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

.text-link {
  font: 500 15px/1.2 var(--heading);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;

  &:hover {
    text-decoration-color: var(--gold);
    text-decoration-thickness: 2px;
  }
}

/* Header: absent on the first screen, it comes in as the page scrolls */

.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid rgb(29 29 27 / 0.12);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 16px 32px;
  min-height: var(--header-height);
  padding: 12px calc(var(--gutter) + var(--lang-width) + 16px) 12px var(--gutter);
}

.site-header__logo {
  margin-right: auto;

  & img {
    width: auto;
    height: 44px;
  }
}

.site-nav ul,
.lang ul {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav ul {
  gap: 28px;
}

.site-nav a,
.lang a {
  display: inline-block;
  padding-block: 12px;
  font: 400 15px/1 var(--heading);
  text-decoration: none;

  &:hover {
    text-decoration: underline;
    text-decoration-color: var(--gold);
    text-decoration-thickness: 2px;
    text-underline-offset: 0.45em;
  }
}

/* The language switch: outside the header, so that it shows on the first screen too, on a small white slab
   cut like the hero's tiles that reads on any floor. Where the header comes in, the slab stays put and melts
   into it: its stone and shadow fade out and the two letters are left on the header's white. */
.lang {
  position: fixed;
  top: 0;
  right: var(--gutter);
  z-index: 11;
  display: flex;
  align-items: center;
  height: var(--header-height);

  & ul {
    position: relative;
    isolation: isolate;
    justify-content: center;
    gap: 4px;
    width: var(--lang-width);
    font: 400 13px/1 var(--heading);
    letter-spacing: 0.08em;

    &::before {
      content: "";
      position: absolute;
      inset: -2px 0;
      z-index: -1;
      background: url("tiles/stone-1-wide.svg") center / 100% 100% no-repeat;
      filter: drop-shadow(0 1px 0.5px rgb(0 0 0 / 0.25)) drop-shadow(0 8px 10px rgb(0 0 0 / 0.4));
    }
  }

  & li + li::before {
    content: "/";
    margin-right: 4px;
    color: var(--ink-soft);
  }

  & a {
    font-size: 13px;
    color: var(--ink-soft);
  }

  & a[aria-current] {
    color: var(--ink);
    font-weight: 600;
  }
}

/* Below 1100 px the hero starts with the white panel: the slab would be white on white, so only its letters stay */
@media (width < 1100px) {
  .lang ul::before {
    display: none;
  }
}

@media (width < 1080px) {
  .site-nav {
    display: none;
  }
}

/* Scroll-driven where supported; main.js adds .is-scrolled elsewhere */
@supports (animation-timeline: scroll()) and (animation-range: 0% 100%) {
  .site-header {
    animation: header-in linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 120px;
  }

  .lang ul::before {
    animation: slab-out linear both;
    animation-timeline: scroll(block root);
    animation-range: 60px 120px;
  }
}

@keyframes slab-out {
  to {
    opacity: 0;
  }
}

html.no-scroll-timeline .lang ul::before {
  transition: opacity 0.3s;
}

html.no-scroll-timeline .site-header.is-scrolled + .lang ul::before {
  opacity: 0;
}

html.no-scroll-timeline .site-header {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;

  @media (prefers-reduced-motion: no-preference) {
    translate: 0 -100%;
    transition: opacity 0.3s, translate 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
  }

  &.is-scrolled {
    opacity: 1;
    translate: none;
    pointer-events: auto;
  }
}

@keyframes header-in {
  from {
    opacity: 0;
    pointer-events: none;
  }
  to {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes header-in {
    from {
      opacity: 0;
      translate: 0 -100%;
      pointer-events: none;
    }
    to {
      opacity: 1;
      translate: none;
      pointer-events: auto;
    }
  }
}

/* A keyboard user reaching the menu sees it, scrolled or not */
.site-header:focus-within,
html.no-scroll-timeline .site-header:focus-within {
  animation: none;
  opacity: 1;
  translate: none;
  pointer-events: auto;
}

/* Hero */

.hero {
  position: relative;
  isolation: isolate;
  min-height: 100svh;
  display: flex;
}

.hero__background {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* Two columns: the plaque as a white panel down the whole height on the left,
   the floor and the tiles laid on it on the right */
.hero__inner {
  flex: 1;
  display: grid;
  grid-template-columns: clamp(320px, 25vw, 380px) minmax(0, 1fr);
}

/* The plaque: where the floor starts, its edge is cut like a tile's, without the scratches */

.plaque {
  position: relative;
  isolation: isolate;
  display: flex;
}

/* The edge, a strip whose white ends on the cut line 16 px from its left (assets/stone/make_stones.py),
   laid so that the cut runs along the panel's edge; under the panel's white, which stops short of it.
   A shadow on the right alone, for the passage to the floor: clipped above and below the panel. */
.plaque::after {
  content: "";
  position: absolute;
  inset: 0 -12px 0 auto;
  z-index: -1;
  width: 28px;
  background: url("tiles/panel-edge.svg") center / 100% 100% no-repeat;
  filter: drop-shadow(1px 0 0.5px rgb(0 0 0 / 0.2)) drop-shadow(6px 0 9px rgb(0 0 0 / 0.22));
  clip-path: inset(0 -40px 0 0);
  pointer-events: none;
}

.plaque__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: clamp(40px, 5vw, 72px) clamp(28px, 3vw, 48px) clamp(40px, 5vw, 72px) var(--gutter);
  position: relative;
  isolation: isolate;
  background: linear-gradient(var(--paper)) 0 0 / calc(100% - 8px) 100% no-repeat;

  /* Scratches and cracks on the white, under the text and never where the logo stands, the cracks leaving
     the cut edge from its chips (assets/stone/make_stones.py) */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("tiles/panel-marks.svg") center / 100% 100% no-repeat;
    pointer-events: none;
  }
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font: 500 12px/1.4 var(--heading);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-wrap: balance;

  &::before {
    content: "";
    flex: none;
    width: 9px;
    height: 9px;
    background: var(--gold);
    rotate: 6deg;
  }
}

.plaque__logo {
  margin: 0;

  & img {
    width: clamp(175px, 15vw, 220px);
  }
}

.lede {
  max-width: 32rem;
  margin: 0;
  font: 300 16px/1.6 var(--text);
  color: var(--ink-soft);
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 24px;
  margin-top: 4px;
}

/* Tiles: the four crafts and the workmanship, laid like samples, each photo in a white border.
   The small ones are about square, as on the Netsol hero; the large one spans two of them each way. */

.tiles {
  --tile-columns: 4;
  --tile-gap: 16px;
  container-type: inline-size;
  align-self: center;
  display: grid;
  grid-template-columns: repeat(var(--tile-columns), minmax(0, 1fr));
  gap: var(--tile-gap);
  margin: 0;
  padding: clamp(28px, 4vw, 56px) var(--gutter) clamp(28px, 4vw, 56px) clamp(32px, 4vw, 64px);
  list-style: none;
}

/* One column: the panel on top, the tiles on the floor below it */
@media (width < 1100px) {
  .hero__inner {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The cut edge goes below the panel, without a shadow */
  .plaque::after {
    inset: auto 0 -12px;
    width: auto;
    height: 28px;
    background-image: url("tiles/panel-edge-bottom.svg");
    filter: none;
    clip-path: none;
  }

  .plaque__body {
    padding: clamp(32px, 6vw, 56px) var(--gutter) clamp(36px, 7vw, 64px);
    background-size: 100% calc(100% - 8px);

    &::before {
      background-image: url("tiles/panel-marks-bottom.svg");
    }
  }

  .tiles {
    padding-inline: var(--gutter);
  }
}

/* The li stays in place and takes the hover; its figure is the slab that lifts. Were the li to lift, a pointer
   near its bottom edge would fall off it, drop it back under the pointer and lift it again, over and over. */
.tile {
  display: flex;
  cursor: pointer;

  & figure {
    --shadow: drop-shadow(0 1px 0.5px rgb(0 0 0 / 0.25)) drop-shadow(0 14px 16px rgb(0 0 0 / 0.5));
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: var(--frame) var(--frame) 0;
    /* Identity values, so that hovering does not create a stacking context; the tilted tiles set their own rotate */
    translate: 0 0;
    rotate: 0deg;

    /* The white marble slab the photo is set in, cut like the tesserae of the floor: its own edges, chips,
       veins and cracks for each tile (assets/stone/make_stones.py), its shadow following them */
    &::before {
      content: "";
      position: absolute;
      inset: -4px;
      z-index: -1;
      background: var(--stone) center / 100% 100% no-repeat;
      filter: var(--shadow);
    }

    /* What is on its surface, scratches and cracks, over the photo too, in line with those on the frame */
    &::after {
      content: "";
      position: absolute;
      inset: -4px;
      background: var(--marks) center / 100% 100% no-repeat;
      pointer-events: none;
    }
  }

  /* The slab lifts and the tilted ones straighten, slowly enough to feel picked up rather than jumped */
  @media (prefers-reduced-motion: no-preference) {
    & figure {
      transition-property: translate, rotate;
      transition-duration: 0.5s;
      transition-timing-function: cubic-bezier(0.25, 0.5, 0.25, 1);

      &::before {
        transition: filter 0.5s cubic-bezier(0.25, 0.5, 0.25, 1);
      }
    }

    &:hover figure {
      --shadow: drop-shadow(0 1px 0.5px rgb(0 0 0 / 0.2)) drop-shadow(0 22px 20px rgb(0 0 0 / 0.5));
      translate: 0 -6px;
      rotate: 0deg;
    }
  }

  /* The tile's photos, one shown at a time (assets/main.js), laid over each other in a square */
  & .tile__photos {
    position: relative;
    aspect-ratio: 1;
  }

  & img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;

    &[hidden] {
      display: none;
    }
  }

  /* Where the photo stands in the tile's series, and « Before » or « After » for a restoration's pair:
     small labels on the photo, as on a sample */
  & .tile__count,
  & .tile__state {
    position: absolute;
    padding: 0.2em 0.5em;
    background: rgb(255 255 255 / 0.88);
    color: var(--ink);
    font: 500 0.75rem/1.2 var(--heading);
  }

  & .tile__count {
    right: 6px;
    bottom: 6px;
    font-variant-numeric: tabular-nums;
  }

  & .tile__state {
    top: 6px;
    left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;

    &[hidden] {
      display: none;
    }
  }

  /* The button that shows the next photo covers the whole slab, so that a click anywhere on it does */
  & .tile__next {
    position: absolute;
    inset: 0;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;

    &:focus-visible {
      outline: 3px solid var(--ink);
      outline-offset: -5px; /* inside the white slab, where the ink stands out, rather than on the floor */
    }
  }

  /* One size for the five, set by the width of a small tile so that the longest name fits on one line:
     « Venetian Terrazzo » is about 9.6 em wide with its tessera, « Seminato veneziano » 10.4 em */
  & figcaption {
    --caption-ems: 9.6;
    display: flex;
    align-items: center;
    gap: 0.45em;
    padding: 0.5em 0.15em 0.6em;
    font: 500 clamp(0.8125rem, ((100cqi - (var(--tile-columns) - 1) * var(--tile-gap)) / var(--tile-columns) - 2 * var(--frame)) / var(--caption-ems), 1.1875rem)/1.2 var(--heading);

    &:lang(it) {
      --caption-ems: 10.4;
    }

    /* A tessera before the name, as before the eyebrow: black, gold for the workmanship */
    &::before {
      content: "";
      flex: none;
      width: 0.5em;
      height: 0.5em;
      background: var(--ink);
      rotate: 6deg;
    }
  }
}

.tile--large {
  grid-column: span 2;
  grid-row: span 2;

  & .tile__photos {
    flex: 1;
    min-height: 0;
    aspect-ratio: auto;
  }

  & figcaption::before {
    background: var(--gold);
  }
}

/* Each place on the floor has its own slab, whatever photo it shows */
.tile:nth-child(1) { --stone: url("tiles/stone-1.svg"); --marks: url("tiles/stone-1-marks.svg"); }
.tile:nth-child(2) { --stone: url("tiles/stone-2.svg"); --marks: url("tiles/stone-2-marks.svg"); }
.tile:nth-child(3) { --stone: url("tiles/stone-3.svg"); --marks: url("tiles/stone-3-marks.svg"); }
.tile:nth-child(4) { --stone: url("tiles/stone-4.svg"); --marks: url("tiles/stone-4-marks.svg"); }
.tile:nth-child(5) { --stone: url("tiles/stone-5.svg"); --marks: url("tiles/stone-5-marks.svg"); }

.tile--tilt-right figure {
  rotate: 1.4deg;
}

.tile--tilt-left figure {
  rotate: -1.1deg;
}

/* Two columns of tiles once four would make the captions too small */
@media (width < 760px) {
  :root {
    --frame: 0.5rem;
  }

  .tiles {
    --tile-columns: 2;
    --tile-gap: 12px;
  }

  /* The large tile's slab, wider than tall here */
  .tile:nth-child(1) {
    --stone: url("tiles/stone-1-wide.svg");
    --marks: url("tiles/stone-1-wide-marks.svg");
  }

  .tile--large {
    grid-row: auto;

    & .tile__photos {
      flex: none;
      aspect-ratio: 4 / 3;
    }
  }
}

/* Heritage and Vision */

.heritage {
  display: grid;
  grid-template-columns: minmax(0, 34rem) minmax(0, 26rem);
  justify-content: center;
  align-items: center;
  gap: clamp(40px, 8vw, 128px);
  padding: clamp(80px, 11vw, 168px) var(--gutter);
  background: var(--cream);

  & h2 {
    margin: 20px 0 28px;
    font: 500 clamp(36px, 4.4vw, 60px)/1.05 var(--heading);
    letter-spacing: -0.01em;
    text-wrap: balance;
  }

  & p:not(.eyebrow) {
    margin: 0 0 18px;
    font: 300 18px/1.7 var(--text);
    color: var(--ink-soft);
    text-wrap: pretty;
  }

  & .text-link {
    display: inline-block;
    margin-top: 14px;
  }
}

.heritage__photo {
  width: 100%;
  aspect-ratio: 5 / 4;
  object-fit: cover;
}

@media (width < 760px) {
  .heritage {
    grid-template-columns: minmax(0, 1fr);
  }

  .heritage__photo {
    max-width: 420px;
  }
}

/* The photo rises gently into place as it scrolls in: decorative, so no fallback */
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: view()) and (animation-range: entry) {
    @keyframes rise-in {
      from {
        opacity: 0.2;
        translate: 0 80px;
      }
    }

    .heritage__photo,
    .heritage__text {
      animation: rise-in auto cubic-bezier(0.2, 0.7, 0.2, 1) backwards;
      animation-timeline: view();
      animation-range: entry 0% entry 90%;
    }

    .heritage__text {
      animation-range: entry 10% entry 100%;
    }
  }
}

/* Footer: the darker cream of « Heritage and Vision » on his current site, the logo in one colour as it shows it there */

.site-footer {
  background: var(--cream-dark);
  color: var(--ink);
}

.site-footer__inner {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.6fr);
  grid-template-areas: "brand work workshop map";
  align-items: start;
  gap: 48px clamp(28px, 4vw, 56px);
  max-width: 1280px;
  margin-inline: auto;
  padding: clamp(64px, 8vw, 112px) var(--gutter) clamp(48px, 6vw, 80px);
}

.site-footer__brand {
  grid-area: brand;

  & .eyebrow {
    margin-bottom: 24px;
  }

  & img {
    width: clamp(120px, 11vw, 150px);
  }

  & p {
    max-width: 22rem;
    margin: 24px 0 0;
    font: 300 15px/1.6 var(--text);
    color: var(--ink-soft);
    text-wrap: pretty;
  }
}

.site-footer__workshop {
  grid-area: workshop;
}

.site-footer__work {
  grid-area: work;
}

.site-footer__heading {
  margin: 0 0 16px;
  font: 500 12px/1.4 var(--heading);
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.site-footer address {
  font: 300 15px/1.6 var(--text);
  font-style: normal;
  color: var(--ink-soft);

  & p {
    margin: 0 0 12px;
  }
}

.site-footer__links {
  margin: 0;
  padding: 0;
  list-style: none;

  & a {
    display: inline-block;
    padding-block: 5px;
    font: 400 15px/1.3 var(--heading);
    text-decoration: none;

    &:hover {
      text-decoration: underline;
      text-decoration-thickness: 1px;
      text-underline-offset: 0.3em;
    }
  }
}

.site-footer address a {
  color: var(--ink);
  text-underline-offset: 0.25em;
}

/* The map of the workshop (assets/map-image.css): its height from the aspect ratio, not the pattern's default */
.site-footer__map {
  grid-area: map;
  aspect-ratio: 4 / 3;
  block-size: auto;
}

.site-footer__bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  width: min(100% - 2 * var(--gutter), 1280px - 2 * var(--gutter));
  margin-inline: auto;
  padding: 20px 0 28px;
  border-top: 1px solid rgb(29 29 27 / 0.15);
  font: 400 13px/1.4 var(--heading);
  color: var(--ink-soft);

  & p {
    margin: 0;
  }

  & a {
    color: inherit;
    text-underline-offset: 0.25em;
  }
}

@media (width < 1080px) {
  .site-footer__inner {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "brand work workshop"
      "map   map  map";
  }

  .site-footer__map {
    aspect-ratio: 21 / 9;
  }
}

@media (width < 640px) {
  .site-footer__inner {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "work"
      "workshop"
      "map";
    gap: 40px;
  }

  .site-footer__map {
    aspect-ratio: 4 / 3;
  }
}

/* The cross-fade between two photos of a tile (assets/main.js): only the photo changes, not the page */
:root {
  view-transition-name: none;
}

::view-transition-group(tile-photo) {
  animation-duration: 0.35s;
}
