/* ============================================================
   dylanbertalli.com
   Intro → horizontal work gallery → detail view.
   No framework, no build step. Devices are drawn in CSS.
   ============================================================ */

:root {
  --bg:        #f9f9f7;
  --ink:       #0b0b0b;
  --ink-soft:  #55554f;
  --ink-faint: #a8a7a0;
  --rule:      #dedcd4;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;

  /* One easing for every large move. Consistency is what reads as "smooth". */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --move: 950ms;

  color-scheme: light only;
}

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

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

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

/* ════════════════════ INTRO ════════════════════ */

.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: var(--bg);
  /* Long and unequal on purpose: the fade finishes before the drift does,
     so the word dissolves rather than sliding away. */
  transition: opacity 1150ms var(--ease), transform 1500ms var(--ease);
}
.intro.is-gone {
  opacity: 0;
  transform: translateY(-10px) scale(.988);
  pointer-events: none;
}

.word {
  margin: 0;
  font-weight: 300;
  font-size: clamp(2.75rem, 8.5vw, 7rem);
  line-height: 1;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.word-type { display: inline-flex; align-items: baseline; }

/* The blink is driven from script.js with the Web Animations API so it can
   finish a whole number of cycles and resolve to solid — a CSS animation
   cancelled by a timer snaps mid-cycle, which is what made it jump. */
.caret {
  display: inline-block;
  width: 2px;
  height: .96em;
  margin-left: .07em;
  background: var(--ink);
  transform: translateY(.1em);
  opacity: 1;
}
.caret.is-done { opacity: 0; transition: opacity 700ms var(--ease); }

/* ════════════════════ CHROME ════════════════════ */

.head {
  position: fixed;
  top: clamp(1.5rem, 4vh, 2.75rem);
  left: clamp(1.5rem, 5vw, 4rem);
  z-index: 20;
  opacity: 0;
  transition: opacity 1000ms var(--ease);
}
.head.is-visible { opacity: 1; }
body.is-detail .head { opacity: 0; pointer-events: none; }

.head-id {
  display: grid;
  font-size: clamp(1.0625rem, 1.6vw, 1.375rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.32;
}
.head-year { font-variant-numeric: tabular-nums; }

.info-btn, .back-btn {
  position: fixed;
  top: clamp(1.5rem, 4vh, 2.75rem);
  width: 30px; height: 30px;
  padding: 0; border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1000ms var(--ease), transform .25s ease;
}
.info-btn svg, .back-btn svg { width: 100%; height: 100%; display: block; }

.info-btn { right: clamp(1.5rem, 5vw, 4rem); }
.info-btn.is-visible { opacity: 1; pointer-events: auto; }
.info-btn:hover { transform: scale(1.08); }
body.is-detail .info-btn { opacity: 0; pointer-events: none; }

.back-btn { left: clamp(1.5rem, 5vw, 4rem); }
body.is-detail .back-btn { opacity: 1; pointer-events: auto; transition-delay: 180ms; }
.back-btn:hover { transform: translateX(-3px); }

/* ════════════════════ GALLERY ════════════════════ */

.gallery {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1300ms var(--ease);
  cursor: grab;
}
.gallery.is-visible { opacity: 1; }
.gallery.is-dragging { cursor: grabbing; }
body.is-detail .gallery { cursor: default; }

.track {
  display: flex;
  align-items: center;
  gap: clamp(3.5rem, 7vw, 8rem);
  padding-inline: clamp(2rem, 18vw, 22rem);
  will-change: transform;
}

.item {
  position: relative;
  flex: 0 0 auto;
  transition: opacity 900ms var(--ease), transform 1250ms var(--ease);
}

/* Before the reveal the devices sit low and invisible. */
.gallery:not(.is-visible) .item { opacity: 0; transform: translateY(22px); }

/* Stagger applies only during the entrance, then the class is dropped so
   later fades (opening a project) aren't delayed by it. */
.gallery.is-entering .item {
  transition-delay: calc(340ms + var(--i, 0) * 95ms);
}

body.is-detail .item:not(.is-active) { opacity: 0; pointer-events: none; }

/* Full-tile hit area, so the whole device is clickable without
   wrapping the mockup markup in a button. */
.item-hit {
  position: absolute;
  inset: -1.5rem;
  z-index: 3;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
body.is-detail .item-hit { pointer-events: none; }

.device {
  transform-origin: 50% 50%;
  transition: transform var(--move) var(--ease);
  will-change: transform;
}

/* ════════════════════ MACBOOK ════════════════════ */

.mac { width: clamp(19rem, 36vw, 34rem); }

.mac-lid {
  position: relative;
  background: linear-gradient(158deg, #494c50 0%, #2f3134 42%, #3c3f43 100%);
  border-radius: 12px 12px 4px 4px;
  padding: 9px 9px 11px;
  box-shadow:
    0 1px 0 rgba(255,255,255,.16) inset,
    0 18px 34px -18px rgba(0,0,0,.34);
}

.mac-screen {
  position: relative;
  aspect-ratio: 16 / 10.3;
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
  container-type: size;
}

.mac-notch {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 17%; height: 9px;
  background: #2f3134;
  border-radius: 0 0 5px 5px;
  z-index: 2;
}

.mac-base {
  position: relative;
  width: 118%;
  margin-left: -9%;
  height: 11px;
  background: linear-gradient(180deg, #c8ccd0 0%, #9ea3a8 62%, #7d8287 100%);
  border-radius: 0 0 9px 9px;
  box-shadow: 0 12px 20px -12px rgba(0,0,0,.4);
}
.mac-lip {
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 15%; height: 5px;
  background: #8a8f94;
  border-radius: 0 0 6px 6px;
}

/* ════════════════════ IPHONE ════════════════════ */

.phone { width: clamp(8.5rem, 13vw, 12.5rem); }

.phone-frame {
  position: relative;
  aspect-ratio: 9 / 19.5;
  padding: 3.5px;
  border-radius: 15.5%/7.2%;
  background: linear-gradient(147deg, #d9d5cd 0%, #8e8a82 26%, #6d6a64 55%, #b9b5ad 100%);
  box-shadow:
    0 0 0 .5px rgba(0,0,0,.22),
    0 22px 38px -20px rgba(0,0,0,.42);
}

.phone-screen {
  position: relative;
  height: 100%;
  border-radius: 14%/6.6%;
  overflow: hidden;
  background: #fff;
  container-type: size;
}

.phone-island {
  position: absolute;
  top: 2.4%; left: 50%;
  transform: translateX(-50%);
  width: 31%; height: 3.5%;
  background: #0a0a0a;
  border-radius: 99px;
  z-index: 2;
}

/* ════════════════════ SCREEN CONTENT ════════════════════ */
/* Sized in cqw so the mock UI scales with the device, not the page. */

.ui { height: 100%; background: #fff; }

.ui--desktop { display: flex; font-size: 2.6cqw; }

.ui-side {
  width: 27%;
  padding: 5.5cqh 3cqw;
  background: var(--accent-soft);
  border-right: .3cqw solid rgba(0,0,0,.05);
  display: flex;
  flex-direction: column;
  gap: 2.2cqh;
}
.ui-title { display: block; height: 2.6cqh; width: 72%; background: rgba(0,0,0,.62); border-radius: 99px; }
.ui-row   { display: block; height: 2.2cqh; width: 88%; background: rgba(0,0,0,.13); border-radius: 99px; }
.ui-row.is-on { background: var(--accent); width: 96%; }

.ui-meters { display: flex; flex-direction: column; gap: 1.6cqh; margin-top: 1.5cqh; }
.ui-meters span {
  display: block; height: 1.3cqh; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) 0 68%, #e8534f 68% 100%);
}

.ui-main { flex: 1; padding: 5cqh 3.4cqw; display: flex; flex-direction: column; gap: 3cqh; }
.ui-bar { display: flex; align-items: center; justify-content: space-between; }
.ui-h    { display: block; height: 2.8cqh; width: 34%; background: rgba(0,0,0,.72); border-radius: 99px; }
.ui-pill { display: block; height: 3.4cqh; width: 13%; background: rgba(0,0,0,.09); border-radius: 99px; }

.ui-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.6cqw; }
.ui-grid i {
  display: block;
  aspect-ratio: 1;
  border-radius: .9cqw;
  background: var(--accent-soft);
  border: .25cqw solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.ui-grid i:nth-child(4n+2) { background: color-mix(in srgb, var(--accent) 22%, #fff); }
.ui-grid i:nth-child(7)    { background: color-mix(in srgb, var(--accent) 42%, #fff); }

.ui-chart { flex: 1; display: flex; align-items: flex-end; gap: 1.8cqw; }
.ui-chart i {
  flex: 1;
  height: var(--v);
  border-radius: .6cqw .6cqw 0 0;
  background: linear-gradient(180deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 45%, #fff) 100%);
}

/* Mobile screen */
.ui--mobile { display: flex; flex-direction: column; font-size: 5cqw; }
.ui-hero {
  height: 34%;
  background:
    radial-gradient(120% 90% at 30% 20%, color-mix(in srgb, var(--accent) 65%, #fff) 0%, transparent 60%),
    linear-gradient(160deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 40%, #111) 100%);
}
.ui-hero.is-tall { height: 46%; }

.ui-lines { padding: 4.5cqh 6cqw 0; display: flex; flex-direction: column; gap: 1.8cqh; }
.ui-lines .ui-h { height: 2.4cqh; width: 62%; }
.ui-lines span  { display: block; height: 1.5cqh; width: 100%; background: rgba(0,0,0,.11); border-radius: 99px; }
.ui-lines span.is-short { width: 55%; }

.ui-cards { margin-top: auto; padding: 0 6cqw 6cqh; display: flex; flex-direction: column; gap: 2cqh; }
.ui-cards i {
  display: block; height: 8.5cqh;
  border-radius: 3cqw;
  background: var(--accent-soft);
  border: .6cqw solid color-mix(in srgb, var(--accent) 26%, transparent);
}

/* ════════════════════ DETAIL PANEL ════════════════════ */

.detail {
  position: fixed;
  z-index: 15;
  top: 50%;
  left: clamp(1.5rem, 7vw, 7.5rem);
  width: min(20rem, 32vw);
  transform: translateY(-50%) translateY(.75rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 620ms var(--ease), transform 780ms var(--ease);
}
body.is-detail .detail {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%);
  transition-delay: 260ms;
}

.detail-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.detail-meta {
  margin: 0;
  display: grid;
  font-size: 1.0625rem;
  font-weight: 400;
  color: var(--ink-soft);
  line-height: 1.45;
}
.detail-year {
  margin: .9rem 0 0;
  font-size: 1.0625rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.play-btn {
  margin: 1.9rem 0 0;
  width: 34px; height: 34px;
  padding: 0; border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  transition: transform .25s ease;
}
.play-btn svg { width: 100%; height: 100%; display: block; }
.play-btn:hover { transform: scale(1.09); }

.detail-credits {
  list-style: none;
  margin: 2.2rem 0 0;
  padding: 0;
  display: grid;
  gap: .28rem;
  font-size: 1.0625rem;
  color: var(--ink-faint);
  line-height: 1.35;
}

/* ════════════════════ ABOUT OVERLAY ════════════════════ */

.overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  overflow-y: auto;
  opacity: 0;
  transition: opacity .32s ease;
}
.overlay.is-open { opacity: 1; }
.overlay[hidden] { display: none; }

.close-btn {
  position: fixed;
  top: clamp(1.5rem, 4vh, 2.75rem);
  right: clamp(1.5rem, 5vw, 4rem);
  width: 30px; height: 30px;
  padding: 0; border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  z-index: 51;
  transition: transform .25s ease;
}
.close-btn svg { width: 100%; height: 100%; display: block; }
.close-btn:hover { transform: rotate(90deg); }

.overlay-inner {
  max-width: 44rem;
  margin: 0 auto;
  padding: clamp(4.5rem, 14vh, 9rem) clamp(1.5rem, 6vw, 3rem) 5rem;
}
.overlay-name {
  margin: 0 0 2.5rem;
  font-weight: 400;
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  letter-spacing: -0.02em;
}
.overlay-body p {
  margin: 0 0 1.15em;
  font-size: clamp(1.0625rem, 1rem + .35vw, 1.25rem);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 38ch;
}
.overlay-list {
  margin: 3rem 0 0;
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem 2rem;
  border-top: 1px solid var(--rule);
  padding-top: 2rem;
}
.overlay-list dt {
  font-size: .8125rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 500;
  padding-top: .35rem;
}
.overlay-list dd { margin: 0; display: grid; gap: .5rem; justify-items: start; }
.overlay-list a {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.0625rem;
  border-bottom: 1px solid var(--rule);
  padding-bottom: .1em;
  transition: border-color .2s ease;
}
.overlay-list a:hover { border-bottom-color: var(--ink); }

/* ════════════════════ RESPONSIVE ════════════════════ */

@media (max-width: 900px) {
  .detail {
    top: auto;
    bottom: clamp(1.5rem, 5vh, 3rem);
    left: 50%;
    width: min(24rem, 86vw);
    transform: translateX(-50%) translateY(.75rem);
    text-align: center;
    justify-items: center;
  }
  body.is-detail .detail { transform: translateX(-50%); }
  .detail-meta, .detail-credits { justify-items: center; }
  .play-btn { margin-inline: auto; }
  .detail-credits { gap: .2rem; }
}

@media (max-width: 560px) {
  .detail-credits { display: none; }   /* no room; the essentials stay */
}

/* ════════════════════ MOTION PREFERENCES ════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .caret { animation: none; opacity: 0; }
  .intro, .gallery, .head, .info-btn, .back-btn, .detail, .device, .item, .overlay {
    transition-duration: 1ms !important;
    transition-delay: 0ms !important;
  }
  .info-btn:hover, .back-btn:hover, .close-btn:hover, .play-btn:hover { transform: none; }
}
