/* ============================================================
   Roy Hsia — portfolio (clean rebuild, no framework)
   ============================================================ */

:root {
  --ink:        #101010;
  --paper:      #ffffff;
  --black:      #000000;
  --muted:      #888888;
  --line:       #ececec;

  --maxw:       1280px;
  --pad:        64px;   /* nav / hero side padding */
  --pad-work:   128px;  /* work grid side padding (taper down on small screens) */
  --gap:        24px;   /* grid gutter */
  --radius:     16px;

  /* Roy's five-color identity gradient (hero logo / title) */
  --grad: linear-gradient(90deg, #ee7752, #e73c7e, #23a6d5, #23d5ab, #dae74d, #23a6d5, #e73c7e, #ee7752);

  --font: bogle, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-display: "Reddit Sans", var(--font);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── shared container ── */
.nav-inner,
.hero-inner,
.work-inner {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

/* ── NAV ── */
.nav {
  background: var(--black);
  position: sticky;
  top: 0;
  z-index: 10;
}
.nav-inner {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-logo {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: #fff;
}
.nav-links {
  display: flex;
  gap: 32px;
}
.nav-links a {
  color: rgba(255,255,255,0.78);
  font-size: 15px;
  transition: color 0.15s ease;
}
.nav-links a:hover { color: #fff; }

/* ── HERO ── */
.hero {
  background: var(--black);
  color: #fff;
  position: relative;
}
.hero-inner {
  min-height: calc(100vh - 64px);   /* fill viewport below the sticky nav */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-top: 64px;
  padding-bottom: 64px;
  transform: translateY(-64px);
}

/* scroll-down hint — mouse outline with a dot drifting down */
.hero-scroll {
  position: absolute;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  width: 24px;
  height: 40px;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 14px;
}
.hero-scroll::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: #fff;
  animation: scroll-dot 1.1s ease-in-out infinite;
}
@keyframes scroll-dot {
  0%   { opacity: 0; transform: translateY(16px); }
  30%  { opacity: 1; }
  60%  { opacity: 1; }
  100% { opacity: 0; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-scroll::before { animation: none; }
}
.hero-avatar {
  position: relative;
  width: 208px;
  height: 208px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
}
.hero-avatar-img {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── left-monitor screen: black panel + cycling company logos ── */
/* clip-path traces the 4 corners of the left screen (% of the image).
   Tune these + the skew + .screen-logo position/size by eye. */
.hero-screen {
  position: absolute;
  inset: 0;
  background: #E8D7CF;
  clip-path: polygon(9.4% 33.5%, 32.9% 36.1%, 34.2% 54.6%, 10.3% 57.1%);
}
.hero-screen-stage {
  position: absolute;
  inset: 0;
  transform: skewY(4deg);    /* match the screen's perspective tilt */
}
.screen-logo {
  position: absolute;
  left: 23%;                 /* screen center, nudged right */
  top: 48%;                  /* screen center, nudged down */
  width: 10.5%;
  height: auto;
  opacity: 0;
  transform: translate(-50%, -50%) translateY(20px);
  animation: screen-logo 9.45s ease-in-out infinite;
}
.screen-logo:nth-child(2) { animation-delay: 3.15s; }
.screen-logo:nth-child(3) { animation-delay: 6.3s; }

@keyframes screen-logo {
  0%      { opacity: 0; transform: translate(-50%, -50%) translateY(20px); }  /* rise from below */
  4.23%   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }     /* in + settled (0.4s) */
  20.1%   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }     /* hold (1.5s) */
  24.34%  { opacity: 0; transform: translate(-50%, -50%) translateY(-20px); } /* rise out + fade (0.4s) */
  100%    { opacity: 0; transform: translate(-50%, -50%) translateY(-20px); } /* wait for next */
}
@media (prefers-reduced-motion: reduce) {
  .screen-logo { animation: none; }
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 9vw, 72px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: #fff;
}
.hero-sub {
  margin-top: 8px;
  font-size: 18px;
  font-weight: 300;
  color: rgba(255,255,255,0.7);
  max-width: 420px;
}

/* ── WORK GRID ── */
.work { background: var(--black); }
.work-inner {
  padding-top: 64px;
  padding-bottom: 96px;
  padding-left: var(--pad-work);
  padding-right: var(--pad-work);
}
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 48px var(--gap);
}
.work-card {
  display: block;
  text-align: center;
  transition: transform 0.2s ease;
}
.work-card[href]:hover { transform: translateY(-4px); }
.work-card[href]:hover .work-thumb { filter: brightness(1.08); }

.work-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  transition: filter 0.2s ease;
}
.work-title {
  margin-top: 16px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: #fff;
}
.work-sub {
  margin-top: 8px;
  font-size: 15px;
  color: rgba(255,255,255,0.6);
  line-height: 1.45;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .work-grid { grid-template-columns: repeat(2, 1fr); }
  .work-inner { padding-left: 64px; padding-right: 64px; }
}
@media (max-width: 600px) {
  .work-grid { grid-template-columns: 1fr; gap: 40px; }
  .work-inner { padding-left: 32px; padding-right: 32px; }
}

/* ============================================================
   CASE STUDY PAGE
   ============================================================ */
.page-dark { background: var(--black); color: #fff; }

/* full-screen case hero — bg photo darkened + blurred, centered text */
.case-hero {
  position: relative;
  min-height: calc(100vh - 64px);   /* fill viewport below sticky nav */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 64px var(--pad);
  overflow: hidden;
}
.case-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.38) blur(3px);
  transform: scale(1.06);   /* hide blur edge bleed */
  z-index: 0;
}
/* vignette — darken the four corners */
.case-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
              rgba(0,0,0,0) 40%,
              rgba(0,0,0,0.55) 100%);
}
.case-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 720px;
}
.case-hero .hero-scroll { z-index: 1; }
.case-hero .case-title,
.case-hero .case-tagline,
.case-hero .case-meta,
.case-hero .case-meta-label { color: #fff; }
.case-hero .case-meta-label { font-weight: 400; }
.case-hero .case-tagline { margin-top: 16px; }
.case-hero .case-meta { margin-top: 24px; }

.case { padding-top: 64px; padding-bottom: 128px; overflow-x: clip; }

/* outer (wide) container — big visuals span this */
.case-wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 64px;
  padding-right: 64px;
}
/* inner reading column — text sits here, narrower & centered */
.case-col {
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

/* header */
.case-head { padding-top: 32px; }
.case-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}
.case-tagline {
  margin-top: 16px;
  font-size: 20px;
  color: rgba(255,255,255,0.7);
}
.case-meta {
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255,255,255,0.5);
}
.case-meta-label { color: rgba(255,255,255,0.8); font-weight: 700; margin-right: 8px; }

/* typography */
.case h2 {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.5vw, 34px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.case h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.case p {
  font-size: 17px;
  line-height: 1.65;
  color: rgba(255,255,255,0.7);
}
.case h2 + p,
.case h3 + p { margin-top: 16px; }
.case p + p { margin-top: 16px; }

/* highlighted key sentence — white, weight unchanged */
.case .hl { color: #fff; font-weight: 600; }

/* customer-pain lists (The Frame) */
.case .pain-head { margin-top: 32px; }
.pains {
  list-style: decimal;
  padding-left: 1.5em;
  margin-top: 16px;
}
.pains li {
  font-size: 17px;
  line-height: 1.6;
  color: rgba(255,255,255,0.7);
  padding-left: 4px;
}
.pains li + li { margin-top: 8px; }
.case .pains + p { margin-top: 24px; }
/* "✓ solved in Project 1" marker on already-resolved insights */
.pains .solved {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #23D5AB;
  white-space: nowrap;
}

/* "Addresses:" insight line under a layer heading */
.addresses {
  font-size: 14px !important;
  line-height: 1.5;
  color: rgba(255,255,255,0.55) !important;
  font-style: italic;
}
.case h3 + .addresses { margin-top: 12px; }
.addresses + p { margin-top: 12px; }
.addresses-label {
  font-style: normal;
  font-weight: 700;
  color: rgba(255,255,255,0.8);
  margin-right: 6px;
}

/* impact stats — horizontal row, big number + small caption */
.stats {
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px var(--gap);
}
.case .stats + p { margin-top: 32px; }
.stat { text-align: center; }
.stat-num {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.stat-label {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  line-height: 1.4;
  color: rgba(255,255,255,0.6);
}

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 400px) {
  .stats { grid-template-columns: 1fr; }
}

/* caption */
.case-caption {
  font-size: 14px !important;
  color: rgba(255,255,255,0.5) !important;
  margin-top: 16px;
}
/* stacked captions sit closer together */
.case-caption + .case-caption { margin-top: 8px; }
/* captions hug the image above; push the following table away */
.case-img + .case-caption { margin-top: 16px; }
.case-caption + .matrix-frame { margin-top: 32px; }
/* captions aligned under thirds of an image */
.caption-row {
  margin-top: 16px;
  display: grid;
  gap: var(--gap);
}
.caption-row--3 { grid-template-columns: repeat(3, 1fr); }
.caption-row .case-caption { margin-top: 0; text-align: center; }
@media (max-width: 600px) {
  .caption-row { gap: 12px; }
}

/* sub-layers */
.layer { margin-top: 64px; }
.layer:first-child { margin-top: 32px; }

/* major-section divider (full container width) */
.case-rule {
  border: 0;
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 64px 0;
}

/* media placeholders */
.media {
  background: #222;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  margin-top: 24px;
  color: rgba(255,255,255,0.4);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.media + .media,
.media + p,
.layer .media { margin-top: 24px; }
.media--video { aspect-ratio: 16 / 9; }
.media:not(.media--video) { min-height: 280px; }
/* stacked video placeholders: let the flex gap own the spacing */
.video-stack .media { margin-top: 0; }

/* wide blocks break out of the reading column to full container width */
.media--wide { margin-top: 32px; margin-bottom: 32px; }

/* real images dropped into the case */
.case-img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 24px;
  border-radius: 0;
}
/* Project 1: square corners on all case images (prototype frames keep their radius) */
.case-square-img .case-img { border-radius: 0; }

/* full-bleed: break out to full viewport width */
.case-img--bleed {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  border-radius: 0;
}
/* centered, 80% of viewport — wider than the reading column but not full bleed */
.case-img--wide {
  width: 80vw;
  max-width: 80vw;
  margin-left: calc(50% - 40vw);
  margin-top: 32px;
}

/* ── live hand-coded prototypes (phone frames) ── */
.case .proto-label {
  margin-top: 40px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #fff;
}
.proto-label + .proto-row { margin-top: 20px; }

/* break out wider than the reading column, like .case-img--wide */
.proto-row {
  /* --phone-screen-w = the iframe's logical width (prototype's mobile breakpoint) */
  --phone-screen-w: 320px;
  width: min(90vw, 1280px);
  margin-top: 40px;
  margin-bottom: 32px;
  margin-left: calc(50% - min(45vw, 640px));
  display: flex;
  justify-content: center;
  gap: 16px;
}
.phone {
  margin: 0;
  flex: 0 1 var(--phone-screen-w);
  display: flex;
  flex-direction: column;
  align-items: center;
}
.phone-bezel {
  width: 100%;
  aspect-ratio: 320 / 568;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}
.phone-screen {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  display: block;
}
.phone-reset {
  margin-top: 16px;
  padding: 7px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.phone-reset:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}
.phone-cap {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,0.55);
  text-align: center;
}

/* fallback links shown only on narrow screens */
.proto-fallback { display: none; }
.proto-fallback-note {
  color: rgba(255,255,255,0.55);
  font-size: 15px;
}
.proto-open-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}
.proto-open {
  display: block;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  transition: border-color 0.15s, background 0.15s;
}
.proto-open:hover {
  border-color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.04);
}

/* below the breakpoint: hide live frames, show open-in-new-tab links */
@media (max-width: 900px) {
  .proto-row { display: none; }
  .proto-fallback { display: block; }
}

/* ── structure variants (Tab / Accordion / Filter): title row + image ── */
.variant { margin: 40px 0 0; }
.variant-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.case .variant-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
/* "See prototype" — same style as Project 1's reset button */
.variant-proto {
  flex: none;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s;
}
.variant-proto:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.45);
}
.variant .case-img { margin-top: 16px; }

/* three videos side by side */
.media-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.media-row .media { margin-top: 0; }

/* stacked videos */
.video-stack {
  margin-top: 32px;
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.video-stack .media { margin-top: 0; }
/* responsive 16:9 YouTube embed */
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  background: #222;
}
.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ── Prototypes & Experiments (lightweight gallery) ── */
.exp-actions {
  margin-top: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.exp-actions .variant-proto { display: inline-block; }
.exp-video { margin: 0; }
.exp-video figcaption {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 10px;
}

/* 2×2 image mosaic */
.mosaic {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.mosaic .media { aspect-ratio: 4 / 3; min-height: 0; margin-top: 0; }

/* channel matrix table */
.matrix-frame {
  margin-top: 24px;
  border: 1px solid rgba(255,255,255,0.2);   /* the rounded outer frame */
  border-radius: var(--radius);
  overflow: hidden;
}
.matrix {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 15px;
}
/* cells draw inner separators only — outer edge is the frame */
.matrix th,
.matrix td {
  border-right: 1px solid rgba(255,255,255,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  padding: 14px 10px;
  line-height: 1.3;
}
.matrix tr > *:last-child { border-right: 0; }
.matrix tbody tr:last-child > * { border-bottom: 0; }

.matrix thead th,
.matrix tbody th[scope="rowgroup"] {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}
.matrix tbody th[scope="row"] {
  font-weight: 400;
  color: rgba(255,255,255,0.8);
}
.matrix td { color: #fff; }
.matrix .yes { font-size: 18px; }

@media (max-width: 600px) {
  .matrix { font-size: 13px; }
  .matrix thead th, .matrix tbody th[scope="rowgroup"] { font-size: 13px; }
  .matrix th, .matrix td { padding: 10px 4px; }
}

/* footer back-link */
.case-foot a {
  color: rgba(255,255,255,0.7);
  font-size: 15px;
  transition: color 0.15s ease;
}
.case-foot a:hover { color: #fff; }

@media (max-width: 900px) {
  .case-wrap { padding-left: 48px; padding-right: 48px; }
}
@media (max-width: 600px) {
  .case-wrap { padding-left: 32px; padding-right: 32px; }
  .media-row { grid-template-columns: 1fr; }
  .mosaic { grid-template-columns: 1fr; }
  .case-rule { margin: 64px 0; }
}
