:root {
  color-scheme: light;
  --ink: #111;
  --muted: #585858;
  --dim: #959595;
  --line-text: #666;
  --ease: cubic-bezier(.22, .8, .2, 1);
  --gutter-x: max(20px, env(safe-area-inset-left), env(safe-area-inset-right));
  --name-size: clamp(22px, min(3.3vw, 6.2svh), 54px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  padding: max(20px, env(safe-area-inset-top)) var(--gutter-x) max(20px, env(safe-area-inset-bottom));
  color: var(--ink);
  background: #fff;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Masthead: the logo on the left, the tagline and motion toggle on the right. */
.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-inline: clamp(0px, 1.5vw, 24px);
}

.wordmark { margin: 0; line-height: 0; }
.ojoolo-logo { display: block; width: clamp(46px, 3.8vw, 62px); height: auto; overflow: visible; }
.ojoolo-pupil { transform: translateX(var(--rest, 36px)); }
.ojoolo-pupil:nth-of-type(-n + 2) { --rest: -36px; }
[data-motion='on'] .ojoolo-pupil { transition: transform 150ms var(--ease); }

.masthead-end { display: flex; align-items: center; gap: 8px; }

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  white-space: nowrap;
}

.motion-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 5px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.motion-toggle svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.motion-toggle:hover { color: var(--ink); }
.icon-pause, [data-motion='on'] .icon-play { display: none; }
[data-motion='on'] .icon-pause { display: inline; }

/* Index: a typeset list of names beside one preview of the selected project. */
.projects {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.18fr);
  align-items: center;
  column-gap: clamp(28px, 4vw, 64px);
  min-height: 0;
  padding: clamp(16px, 3svh, 40px) clamp(0px, 1.5vw, 24px);
}

.project-list {
  display: grid;
  gap: calc(var(--name-size) * .08);
  margin: 0;
  padding: 0;
  list-style: none;
}

.project-link {
  display: grid;
  justify-items: start;
  gap: 4px;
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.project-name {
  color: var(--dim);
  font-size: var(--name-size);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.025em;
  transition: color 250ms;
}

.project-line {
  max-height: 0;
  overflow: hidden;
  color: var(--line-text);
  font-size: clamp(13px, 1vw, 15px);
  line-height: 1.3;
  opacity: 0;
  transition: max-height 350ms var(--ease), opacity 300ms, margin 350ms var(--ease);
}

.project.is-active .project-name, html:not([data-js]) .project-name { color: var(--ink); }
.project.is-active .project-line, html:not([data-js]) .project-line { max-height: 2.8em; margin-bottom: 6px; opacity: 1; }
.project-link:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 3px; }

.project-preview {
  position: relative;
  display: block;
  justify-self: center;
  width: min(100%, (100svh - 170px) * 1.6);
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 8px;
  background: var(--preview-bg, #f5f5f5);
  -webkit-tap-highlight-color: transparent;
}

.project-preview img, .project-preview video {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.project-preview img { opacity: 0; }
.project-preview img.is-active { opacity: 1; }
.project-preview video { z-index: 1; opacity: 0; }
.project-preview video.is-playing { opacity: 1; }
[data-motion='on'] .project-preview img { transition: opacity 300ms; }

.preview-action {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px 9px 15px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
  line-height: 1;
  letter-spacing: .1em;
  white-space: nowrap;
}

.preview-action svg { width: 16px; height: 16px; }
.preview-action path { stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.project-preview:hover .preview-action { background: #000; }

.project-preview[href$="maze-impossible/"] .preview-action { left: 14px; right: auto; }
.project-preview[href$="maze-impossible/"]::after {
  content: "";
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 10px;
  width: 52px;
  height: 42px;
  background: url("maze-impossible/made-by.svg") center / contain no-repeat;
  pointer-events: none;
}

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

/* Phones: the preview sits on top and the list below it. */
@media (max-width: 760px) {
  :root { --name-size: clamp(22px, min(7.6vw, 4.2svh), 34px); }
  .masthead, .projects { padding-inline: 0; }
  .ojoolo-logo { width: 42px; }
  .motion-toggle span { display: none; }
  .projects {
    grid-template-columns: minmax(0, 1fr);
    align-content: center;
    row-gap: clamp(16px, 3svh, 28px);
    padding-block: 16px 4px;
  }
  .project-preview { grid-row: 1; width: 100%; }
  .preview-action { right: 10px; bottom: 10px; padding: 8px 10px 8px 12px; font-size: 10px; }
}

@media (max-width: 340px) {
  .tagline { display: none; }
}
