/* The Max Lab — one stylesheet, no inline styles anywhere (the CSP drops them).
   Design language shared with mkasphoto.com: near-black, off-white type, tiny tracked labels,
   hairline dividers, image-led tiles. */

:root {
  color-scheme: dark;

  --bg: #0a0a0b;
  --surface: #141416;
  --text: #f2f2f0;
  --muted: #9a9a9e;
  --line: rgba(242, 242, 240, .1);
  --accent: #5b7bff;

  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: clamp(20px, 4.5vw, 64px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* ---------- Base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

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

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

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}

.wrap {
  width: 100%;
  max-width: calc(1312px + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 10px 16px;
  background: var(--text);
  color: var(--bg);
}
.skip:focus { top: 12px; }

/* The tiny tracked uppercase label, used for section titles, names and links. */
.label {
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
}

.wordmark {
  font-size: .95rem;
  font-weight: 600;
  letter-spacing: .02em;
}

/* ---------- Header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: clamp(64px, 10vw, 88px);
}

.top__nav { display: flex; gap: clamp(14px, 3vw, 32px); }
.top__nav a {
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 0;
  transition: color .2s;
}
.top__nav a:hover { color: var(--text); }

@media (max-width: 520px) {
  .top__nav a:last-child { display: none; }
}

/* ---------- Hero ---------- */

.hero { padding-top: clamp(28px, 12vw, 160px); }

.hero h1 {
  font-size: clamp(2.6rem, 7.4vw, 4.5rem);
  font-weight: 600;
  line-height: 1.04;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.hero .label { margin-top: 1.4rem; }

.hero__intro {
  margin-top: clamp(28px, 7vw, 88px);
  max-width: 46ch;
  font-size: clamp(1.1rem, 2.2vw, 1.25rem);
  line-height: 1.55;
  color: #b9b9bd;
}

/* ---------- Sections ---------- */

.section { padding-top: clamp(80px, 12vw, 152px); }
#why { padding-top: clamp(48px, 10vw, 128px); }

.section__title {
  padding-bottom: 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

/* ---------- Tiles (apps and photo galleries share one grid) ---------- */

.tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 48px 24px;
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .tiles--apps { grid-template-columns: repeat(2, 1fr); }
  /* An odd last app sits centered at the width of its siblings; a single app is centered too. */
  .tiles--apps > .tile:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    justify-self: center;
    width: calc(50% - 12px);
  }
  .tiles--photos { grid-template-columns: repeat(3, 1fr); gap: 24px; }
}

@media (min-width: 1080px) {
  .tiles--apps:has(> .tile:nth-child(3):last-child) { grid-template-columns: repeat(3, 1fr); }
  .tiles--apps:has(> .tile:nth-child(3):last-child) > .tile:last-child { grid-column: auto; width: auto; }
}

.tile { position: relative; }

.tile__caption {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
}

.tile h3 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.tile__link {
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
  padding: 12px 0;
  margin: -12px 0;
}
.tile__link span { display: inline-block; transition: transform .25s var(--ease); }

/* The whole tile is the link's hit area; the link text stays the one real link. */
.tile__link::after { content: ""; position: absolute; inset: 0; }
.tile__link:focus-visible { outline: none; }
.tile:has(.tile__link:focus-visible) { outline: 2px solid var(--accent); outline-offset: 8px; }

.tile:hover .tile__link span,
.tile:has(.tile__link:focus-visible) .tile__link span { transform: translateX(4px); }

/* ---------- App tiles: the real app screen, rising from a dark stage ---------- */

.app__media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
}

.app__media img {
  position: absolute;
  left: 50%;
  top: 11%;
  width: 52%;
  transform: translateX(-50%);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .06);
  transition: transform .5s var(--ease);
}

.app:hover .app__media img,
.app:has(.tile__link:focus-visible) .app__media img { transform: translate(-50%, -10px); }

.app:active .app__media img { transform: translate(-50%, -4px) scale(.99); }

/* Each app's stage takes a faint glow of its own colours. */
.app--chess .app__media { background: radial-gradient(90% 70% at 50% 100%, rgba(253, 213, 95, .16), transparent 70%), var(--surface); }
.app--raildash .app__media { background: radial-gradient(90% 70% at 50% 100%, rgba(56, 189, 248, .16), transparent 70%), var(--surface); }

.app__desc {
  margin-top: 10px;
  color: #b9b9bd;
  max-width: 52ch;
}

.app__story {
  margin-top: 10px;
  color: var(--muted);
  font-size: .95rem;
  max-width: 52ch;
}

.app__domain {
  margin-top: 14px;
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: #6c6c70;
}

/* ---------- Photography ---------- */

.feature {
  position: relative;
  display: block;
  overflow: hidden;
}

.feature img {
  width: 100%;
  aspect-ratio: 16 / 8;
  object-fit: cover;
  object-position: 70% 60%;
  transition: transform 1.2s var(--ease);
}
.feature:hover img { transform: scale(1.02); }

.feature__text {
  position: absolute;
  inset: auto 0 0 0;
  display: grid;
  gap: 10px;
  padding: clamp(20px, 4vw, 40px);
  background: linear-gradient(to top, rgba(10, 10, 11, .92), rgba(10, 10, 11, .25) 70%, transparent);
}

.feature__title {
  font-size: clamp(1.5rem, 4.4vw, 3rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  max-width: 14ch;
}

.feature .label { color: var(--text); }

@media (max-width: 560px) {
  .feature img { aspect-ratio: 4 / 3; }
}

.statement {
  margin: clamp(32px, 5vw, 56px) 0;
  max-width: 50ch;
  font-size: clamp(1.1rem, 2.2vw, 1.25rem);
  line-height: 1.55;
  color: #b9b9bd;
}
.statement--lead { margin: 0; }

.photo img {
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  filter: saturate(.9);
  transition: opacity .3s;
}
.photo:hover img { opacity: .85; }

/* ---------- How I build ---------- */

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr;
  counter-reset: rule;
  border-top: 1px solid var(--line);
}

.rule {
  counter-increment: rule;
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-content: start;
  column-gap: 8px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.rule::before {
  content: counter(rule, decimal-leading-zero);
  grid-row: span 2;
  padding-top: 5px;
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  color: #6c6c70;
}

.rule h3 { font-size: 1.125rem; font-weight: 500; letter-spacing: -0.01em; }
.rule p { color: var(--muted); margin-top: 4px; }

@media (min-width: 900px) {
  .rules { grid-template-columns: repeat(2, 1fr); column-gap: 64px; border-top: 0; }
  .rule:nth-child(-n+2) { border-top: 1px solid var(--line); }
}

/* ---------- Footer ---------- */

.footer {
  margin-top: clamp(96px, 14vw, 176px);
  padding-top: 48px;
  padding-bottom: 48px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px 40px;
}

.footer__promise { margin-top: 10px; font-size: .8rem; color: #6c6c70; }

.footer__nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 28px;
}
.footer__nav a {
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 0;
  transition: color .2s;
}
.footer__nav a:hover { color: var(--text); }

.footer__version { font-size: .75rem; color: #6c6c70; font-variant-numeric: tabular-nums; }

/* ---------- 404 ---------- */

.lost {
  min-height: 70vh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 1.4rem;
  padding-top: 40px;
  padding-bottom: 40px;
}
.lost h1 {
  font-size: clamp(2.3rem, 7vw, 4rem);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: -0.03em;
  max-width: 14ch;
}
.lost p { color: var(--muted); font-size: 1.15rem; max-width: 40ch; }
.lost .tile__link { margin: 0; }

/* ---------- Scroll reveal (only once reveal.js has added .js to <html>) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .9s var(--ease), transform .9s var(--ease);
}
.js .reveal.is-in { opacity: 1; transform: none; }
.js .tiles .reveal:nth-child(2) { transition-delay: .1s; }
.js .tiles .reveal:nth-child(3) { transition-delay: .2s; }

/* ---------- Reduced motion: everything visible, nothing moves ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .app:hover .app__media img,
  .app:active .app__media img,
  .app:has(.tile__link:focus-visible) .app__media img { transform: translateX(-50%); }
  .feature:hover img { transform: none; }
}
