/* ==========================================================================
   dadigitaldiamond
   A white wall, black and blue ink, one old gilded frame.
   Shared by both versions: the desktop (index.html, the homepage) and the gallery (gallery.html).
   ========================================================================== */

@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond-Light.ttf") format("truetype"); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond-LightItalic.ttf") format("truetype"); font-weight: 300; font-style: italic; font-display: swap; }
@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond-Italic.ttf") format("truetype"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Apple Garamond"; src: url("../fonts/AppleGaramond-BoldItalic.ttf") format("truetype"); font-weight: 700; font-style: italic; font-display: swap; }

:root {
  color-scheme: light;

  /* Three colours. */
  --wall: #fbfaf8;                    /* white: a plastered wall rather than a screen */
  --ink: #0d0d0e;                     /* black: whatever is read */
  --blue: #1807da;                    /* blue: names, labels, links, the clock */

  --wall-lit: #ffffff;                /* where the light falls on the wall */
  --wall-far: #f1f0ec;                /* and where it falls away */
  --paper: #ffffff;
  --rule: rgba(24, 7, 218, 0.17);     /* hairlines: the blue, thinned */
  --shade: 10, 8, 70;                 /* shadows carry a little of the blue */

  --font: "Apple Garamond", "ITC Garamond Std", "Garamond Premier Pro", "Adobe Garamond Pro", Garamond, "Times New Roman", serif;

  /* Three sizes, none of them large. */
  --small: 0.9375rem;
  --text: 1.0625rem;
  --lead: 1.3125rem;

  --pad: clamp(1rem, 2.6vw, 2rem);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* The opening of the frame, as a hole: the outer edge, then the opening wound
     the other way. frame-*.jpg is 1988 x 1254 with a 164 px moulding. */
  --frame-hole: polygon(evenodd,
    0 0, 100% 0, 100% 100%, 0 100%, 0 0,
    8.2495% 13.0781%, 8.2495% 86.9219%, 91.7505% 86.9219%, 91.7505% 13.0781%, 8.2495% 13.0781%);

  --z-bar: 10;
  --z-tag: 20;
}

/* the "Powered by Netlify" badge the host adds on its free plan */
#nl-badge-frame { display: none !important; }

@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.28s; }

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

html {
  background: var(--wall);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text);
  font-weight: 300;
  line-height: 1.45;
  font-kerning: normal;
  font-variant-ligatures: common-ligatures;
  text-rendering: optimizeLegibility;
  text-transform: lowercase;          /* everything, everywhere */
}

/* The wall: lit from the upper left like the frame, with the faintest grain. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  .04 0 0 0 0'/%3E%3C/filter%3E%3Crect width='220' height='220' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 220px 220px,
    radial-gradient(ellipse 85% 78% at 40% 34%, var(--wall-lit) 0%, var(--wall) 44%, var(--wall-far) 100%);
}

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
h1, h2, h3 { font: inherit; }
ul, ol { padding: 0; list-style: none; }
img, video { max-width: 100%; }
button { text-transform: inherit; }

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--blue);
  transition: color 0.2s;
}
a:hover { color: var(--blue); }

em { font-style: italic; }

::selection { background: var(--blue); color: #fff; }

:focus-visible { outline: 1px solid var(--blue); outline-offset: 3px; border-radius: 1px; }

.text-button {
  appearance: none;
  border: 0;
  margin: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: color 0.2s;
}
.text-button:hover { color: var(--blue); }

/* small text, generous targets */
.text-button, .bar a, .foot a { padding: 0.55em 0.3em; margin: -0.55em -0.3em; }

.blue { color: var(--blue); }

/* --------------------------------------------------------------------------
   The bar: name, three doors, the time. Borrowed from a desktop menu bar.
   -------------------------------------------------------------------------- */

.bar {
  position: sticky;
  top: 0;
  z-index: var(--z-bar);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.9rem var(--pad) 0.8rem;
  border-bottom: 1px solid transparent;
  font-size: var(--small);
  line-height: 1.2;
  transition: border-color 0.3s, background-color 0.3s;
  view-transition-name: bar;
}
/* at rest the bar is just words on the wall; it only becomes a bar once the page moves under it */
.bar.is-scrolled {
  background: rgba(251, 250, 248, 0.86);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-bottom-color: var(--rule);
}

.bar a { text-decoration: none; }

.bar__brand {
  justify-self: start;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5em;
  color: var(--blue);
  font-weight: 400;
}
.gem {
  display: inline-block;
  width: 0.46em;
  height: 0.46em;
  background: var(--blue);
  transform: translateY(-0.1em) rotate(45deg);
}

.bar__nav { display: flex; gap: clamp(1rem, 2.4vw, 2rem); }
.bar__nav a[aria-current="page"] { color: var(--blue); font-style: italic; }

.bar__clock {
  justify-self: end;
  color: var(--blue);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   The wall: the frame, as large as the window allows, and the reel inside it.
   -------------------------------------------------------------------------- */

.wall {
  flex: 1;
  display: grid;
  place-items: center;
  padding: clamp(0.5rem, 1.6svh, 1.25rem) clamp(0.5rem, 2.6vw, 2rem);
}

.piece {
  width: min(100%, 105rem, max(18rem, (100svh - 13.6rem) * 1.5853));
}

/* The picture is 1680 x 945 (16:9) and sits about 10 px under the frame's inner
   lip on every side, so the gold really overlaps the film. frame-shadow.png is
   the shadow the frame throws on the picture. If the frame is re-rendered, these
   percentages and --frame-hole are the only things to keep in step. */
.frame {
  position: relative;
  aspect-ratio: 1988 / 1254;
  container-type: inline-size;
  isolation: isolate;
}
.frame__shadow {
  position: absolute;
  inset: 0;
  box-shadow: 2px 4px 6px rgba(var(--shade), 0.26), 9px 18px 30px rgba(var(--shade), 0.18), 16px 36px 64px rgba(var(--shade), 0.09);
  box-shadow: 0.25cqw 0.45cqw 0.7cqw rgba(var(--shade), 0.26), 1.1cqw 2.2cqw 3.6cqw rgba(var(--shade), 0.18), 2cqw 4.5cqw 8cqw rgba(var(--shade), 0.09);
}
.frame__picture {
  position: absolute;
  left: 7.7465%;
  top: 12.3206%;
  width: 84.507%;
  height: 75.3589%;
  overflow: hidden;
  background: var(--blue);
  cursor: pointer;
}
.frame__picture video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.frame__cast,
.frame__moulding,
.frame__sheen {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  user-select: none;
}
.frame__moulding {
  background: linear-gradient(135deg, #c9a551, #8f6c25);   /* old gold at once, the carving as it loads */
  clip-path: var(--frame-hole);
}
/* A soft light that drifts over the gilding as the pointer moves, the way real
   leaf answers when you walk past it. */
.frame__sheen {
  overflow: hidden;
  clip-path: var(--frame-hole);
  mix-blend-mode: soft-light;
}
.frame__sheen::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 85%;
  aspect-ratio: 1;
  margin: -42.5% 0 0 -42.5%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 244, 214, 0.8), rgba(255, 244, 214, 0));
  transform: translate3d(var(--sx, -24cqw), var(--sy, -14cqw), 0);
  will-change: transform;
}

.caption {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  margin-top: clamp(0.9rem, 2.2svh, 1.5rem);
  font-size: var(--small);
  line-height: 1.3;
  text-align: center;
}
.caption__soon { color: var(--blue); }
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2rem 1.9rem;
}
/* until the script takes over, or if the film cannot load, there is nothing to operate */
.piece:not(.has-controls) .controls,
.piece.is-empty .controls { visibility: hidden; }

/* --------------------------------------------------------------------------
   Inner pages: a blue label on the left, the matter in black on the right.
   -------------------------------------------------------------------------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 78rem;
  margin-inline: auto;
  padding: clamp(2.5rem, 9svh, 6.5rem) var(--pad) clamp(4rem, 10svh, 7rem);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 9fr);
  gap: 0.75rem 2rem;
  padding-block: clamp(1.5rem, 3.5svh, 2.25rem);
}
.row + .row { border-top: 1px solid var(--rule); }
.row:first-child { padding-top: 0; }

.row__label { color: var(--blue); font-size: var(--small); line-height: 1.5; }
.row__body { max-width: 62ch; }
.row__body > * + * { margin-top: 0.9em; }

.lead { font-size: var(--lead); line-height: 1.32; text-wrap: balance; }
p { text-wrap: pretty; }

.plain li + li { margin-top: 0.15em; }

.steps { counter-reset: step; }
.steps li { counter-increment: step; display: grid; grid-template-columns: 1.6em 1fr; }
.steps li + li { margin-top: 0.15em; }
.steps li::before { content: counter(step); color: var(--blue); font-variant-numeric: tabular-nums; }

.quote p { font-style: italic; color: var(--blue); }
.quote footer { margin-top: 0.7em; font-size: var(--small); }

/* Case studies */

.case__meta { position: sticky; top: 4.25rem; align-self: start; }
.case__meta h2 { color: var(--ink); font-size: var(--text); font-weight: 400; line-height: 1.35; }
.case__meta ul { margin-top: 0.9em; }
.case__body { max-width: 44rem; }
.case__still { aspect-ratio: 16 / 9; background: rgba(24, 7, 218, 0.08); overflow: hidden; }
.case__still img { display: block; width: 100%; height: 100%; object-fit: cover; }
.case__text { display: grid; gap: 0.9em; margin-top: 1.4rem; }
.case__text div { display: grid; grid-template-columns: 6.5em minmax(0, 1fr); gap: 0 1rem; }
.case__text dt { font-style: italic; color: var(--blue); }
.case__text dd { max-width: 62ch; }

/* Work */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: clamp(1.75rem, 4svh, 2.75rem) clamp(0.9rem, 1.6vw, 1.4rem);
  padding-top: clamp(1.5rem, 3.5svh, 2.25rem);
  border-top: 1px solid var(--rule);
}
.tile { display: block; text-decoration: none; }
.tile:hover { color: inherit; }
.tile__img { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: rgba(24, 7, 218, 0.08); }
.tile__img img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.1s var(--ease);
}
.tile:hover .tile__img img, .tile:focus-visible .tile__img img { transform: scale(1.03); }
.tile__cap {
  display: flex;
  align-items: baseline;
  gap: 0.8rem;
  margin-top: 0.65rem;
  font-size: var(--small);
  line-height: 1.3;
}
.tile__no, .tile__kind { color: var(--blue); font-variant-numeric: tabular-nums; }
.tile__kind { margin-left: auto; text-align: right; }

/* The small tag that follows the pointer over the work */
.tag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-tag);
  padding: 0.12em 0.75em 0.2em;
  border: 1px solid var(--blue);
  border-radius: 999px;
  background: var(--paper);
  color: var(--blue);
  font-size: var(--small);
  line-height: 1.3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s;
  will-change: transform;
}
.tag.is-on { opacity: 1; }

/* The viewer: one piece at a time, on the same wall */
.viewer {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--wall);
  color: var(--ink);
}
.viewer::backdrop { background: var(--wall); }
.viewer[open] { display: grid; grid-template-rows: auto 1fr; }
.viewer__bar { display: flex; justify-content: flex-end; padding: 0.9rem var(--pad) 0.8rem; font-size: var(--small); line-height: 1.2; }
.viewer__stage { display: grid; align-content: center; justify-items: center; gap: 0.9rem; padding: 0 var(--pad) clamp(2rem, 7svh, 4rem); }
.viewer__media { width: min(100%, 64rem, (100dvh - 13rem) * 1.7778); aspect-ratio: 16 / 9; background: rgba(24, 7, 218, 0.08); }
.viewer__media > * { display: block; width: 100%; height: 100%; object-fit: contain; }
.viewer__cap { display: flex; gap: 0.8rem; width: min(100%, 64rem, (100dvh - 13rem) * 1.7778); font-size: var(--small); }
.viewer__cap span:last-child { margin-left: auto; color: var(--blue); }

/* --------------------------------------------------------------------------
   Foot
   -------------------------------------------------------------------------- */

.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.25rem 2rem;
  padding: 1rem var(--pad) 1.1rem;
  font-size: var(--small);
  line-height: 1.2;
}
.foot ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.4rem; }

/* --------------------------------------------------------------------------
   Motion: the frame is hung once, quietly. It settles on the wall and its
   shadow lands. Nothing is ever hidden waiting for an animation, so the page is
   complete even where animations do not run. Moving between pages is the
   browser's own cross-fade (see @view-transition at the top).
   -------------------------------------------------------------------------- */

@keyframes settle { from { transform: translateY(-0.6rem); } }
@keyframes land { from { opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: no-preference) {
  .frame { animation: settle 1.4s var(--ease) both; }
  .frame__shadow { animation: land 1.8s ease-out both; }
  .viewer[open] { animation: fade 0.3s ease-out; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}

/* --------------------------------------------------------------------------
   Small screens
   -------------------------------------------------------------------------- */

@media (max-width: 46rem) {
  .bar { grid-template-columns: 1fr auto; }
  .bar__clock { display: none; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .case__text div { grid-template-columns: minmax(0, 1fr); }
  .case__meta { position: static; }
  .piece { width: 100%; }
}
@media (max-width: 24rem) {
  .bar__nav { gap: 0.8rem; }
}
