/* ══════════════════════════════════════════════════════════════
   HOME — styles unique to index.html
   ══════════════════════════════════════════════════════════════ */

/* ── HERO ────────────────────────────────────────────────────── */
#hero {
  min-height: 100vh;   /* fallback for browsers that don't understand svh */
  min-height: 100svh;
  display: flex; align-items: center;
  padding: 7rem 0 4rem;
  position: relative;
}

/* the hero's two-column (text + avatar) layout needs more breathing room
   than the site's 860px reading-width container — everything else stays
   narrow for text-block readability, just the hero widens. */
#hero .container { max-width: 1180px; }

.hero-bg-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.22;
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 0;
}

.hero-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
  cursor: grab;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.hero-canvas:active { cursor: grabbing; }
.hero-canvas.is-ready { opacity: 1; }

.globe-label {
  /* deliberately no z-index: an explicit z-index here would make this
     paint above .container's static content (the hero text) regardless
     of DOM order, which is exactly the bug this avoided — leaving it
     auto keeps it in the same paint layer as .hero-canvas, ordered by
     DOM position (see hero-scene.js, inserted right after the canvas),
     so it sits behind the text and the (position:relative) avatar. */
  position: absolute; top: 0; left: 0;
  display: flex; align-items: center; gap: 0.4rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--accent2);
  background: rgba(9, 9, 15, 0.55);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.globe-label-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 6px rgba(var(--accent2-rgb), 0.8);
  flex-shrink: 0;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4rem;
  align-items: center;
}

.hero-tag {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 1rem;
}

.hero-name {
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.02;
  margin-bottom: 0.5rem;
}

.hero-role {
  font-family: var(--display);
  font-size: clamp(1.1rem, 3vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--accent2);
  margin-bottom: 1.5rem;
}

.hero-bio {
  color: var(--muted);
  font-size: 1rem;
  max-width: 480px;
  line-height: 1.7;
  margin-bottom: 2.5rem;
}

.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

/* avatar — no background/border/frame by design: just the 3D voxel bust
   (avatar-scene.js) floating transparently over the hero itself. "FB" is
   the plain-text fallback, visible only if the WebGL render never happens. */
.hero-avatar {
  width: clamp(260px, 26vw, 400px); height: clamp(260px, 26vw, 400px);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent2);
  flex-shrink: 0;
  position: relative;
}
.hero-avatar-fallback { transition: opacity .5s ease; }
.hero-avatar.is-ready .hero-avatar-fallback { opacity: 0; }
.hero-avatar-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: 0;
  transition: opacity .8s ease;
  cursor: grab;
}
.hero-avatar-canvas:active { cursor: grabbing; }
.hero-avatar-canvas.is-ready { opacity: 1; }

/* ── EXPERIENCE ──────────────────────────────────────────────── */
#experience { padding: 6rem 0; }

.exp-list { display: flex; flex-direction: column; gap: 0; }

.exp-item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 1.5rem 2.5rem;
  padding: 2.2rem 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease, transform .5s ease;
}
.exp-item.visible { opacity: 1; transform: none; }

.exp-date {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.01em;
  padding-top: 0.2rem;
}

.exp-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}
.exp-thumb {
  width: 56px; height: 56px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.exp-company {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.exp-role {
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.01em;
}

/* ── PROJECTS ────────────────────────────────────────────────── */
#projects { padding: 6rem 0; }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

a.project-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .5s ease, transform .3s ease, border-color .25s;
  position: relative;
  overflow: hidden;
}
.project-card.visible { opacity: 1; transform: none; }
.project-card.visible:hover { border-color: var(--muted); transform: translateY(-2px); }

.project-num {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  position: relative; z-index: 1;
}
.project-title {
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: 0.7rem;
  color: var(--text);
  position: relative; z-index: 1;
}
.project-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.65;
  position: relative; z-index: 1;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  overflow: hidden;
}

/* ── CARD MEDIA (cover photo, or a plain placeholder until one is added) ── */
.card-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  margin: -1.8rem -1.8rem 1.4rem;
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg);
}
.card-media-icon {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display);
  font-size: 2.6rem;
  color: var(--border);
  z-index: 0;
}
.card-media-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
  transition: transform .5s ease;
}
.card-media-scrim {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(9,9,15,0) 55%, rgba(9,9,15,.7) 100%);
  pointer-events: none;
  z-index: 2;
}
.card-media .project-num {
  position: absolute; z-index: 3;
  left: 1.4rem; bottom: 1rem;
  margin-bottom: 0;
  color: var(--text);
}
.project-card.visible:hover .card-media-img { transform: scale(1.03); }
.project-card .project-tags {
  margin-top: 1.2rem;
  position: relative; z-index: 1;
}
.project-open {
  font-family: var(--mono);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--muted);
  margin-top: 1.4rem;
  display: flex; align-items: center; gap: 0.4rem;
  position: relative; z-index: 1;
  transition: color .25s;
}
.project-open::after { content: '→'; }
.project-card:hover .project-open { color: var(--text); }

/* ── CHESS (latest game, replayed on scroll) ─────────────────── */
#chess {
  padding: 6rem 0;
  /* Chess.com's default "green" board */
  --chess-light: #ebecd0;
  --chess-dark: #739552;
  --chess-loss: #e0907f;
}

.chess-card {
  display: grid;
  grid-template-columns: minmax(0, 400px) minmax(0, 1fr);
  gap: 2rem 2.6rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.chess-board-wrap { display: flex; flex-direction: column; gap: 0.65rem; min-width: 0; }

.chess-player {
  display: flex; align-items: center; gap: 0.7rem;
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  min-height: 40px;
}
/* profile picture, square with softly rounded corners like on Chess.com */
.chess-avatar-wrap { position: relative; width: 40px; height: 40px; flex-shrink: 0; }
.chess-avatar {
  display: block; width: 100%; height: 100%;
  border-radius: 4px; object-fit: cover;
  background: var(--bg);
  /* faint inner edge so a dark (or pure-black) picture still reads as a tile on the dark card */
  outline: 1px solid rgba(255, 255, 255, 0.16); outline-offset: -1px;
}
/* initial tile for players with no picture */
.chess-avatar-fallback {
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  font-family: var(--display); font-size: 1.15rem; font-weight: 700; line-height: 1;
  color: var(--accent2); text-transform: uppercase;
}
/* which color they played — a small badge on the avatar's corner */
.chess-player .chess-swatch {
  position: absolute; right: -4px; bottom: -4px;
  width: 13px; height: 13px; border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 0 2px var(--surface); /* ring in the card color so it separates from the picture */
}
.chess-player .chess-swatch.w { background: #fbfbf6; }
.chess-player .chess-swatch.b { background: #2b2825; border-color: rgba(255, 255, 255, 0.4); }
.chess-player .chess-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chess-player .chess-rating { color: var(--muted); font-weight: 500; }
.chess-player .chess-tag {
  margin-left: auto;
  font-size: 0.74rem; font-weight: 600;
  color: var(--bg); background: var(--accent);
  padding: 0.18rem 0.5rem; border-radius: 4px;
  opacity: 0; transform: translateY(2px);
  transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}
.chess-player.is-winner .chess-tag { opacity: 1; transform: none; }

.chess-board {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 4px; /* Chess.com's board is flat — no frame, just softly rounded corners */
  overflow: hidden;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.7);
  user-select: none; -webkit-user-select: none;
}
.chess-sq { position: relative; }
.chess-sq.l { background: var(--chess-light); }
.chess-sq.d { background: var(--chess-dark); }
/* from/to of the move that just played — Chess.com's yellow overlay */
.chess-sq.is-last::before {
  content: ''; position: absolute; inset: 0;
  background: rgba(255, 255, 51, 0.5);
}
/* the king in check after a move that gives it — Chess.com's red radial glow */
.chess-sq.is-check::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, #ff0000 0%, #e70000 25%, rgba(169, 0, 0, 0) 89%, rgba(158, 0, 0, 0) 100%);
}
/* rank/file labels sit inside the edge squares in the opposite square's color,
   drawn over the pieces (z-index above a moving piece's 3) like on Chess.com */
.chess-coord {
  position: absolute; z-index: 4;
  font-family: var(--body); font-size: 0.68rem; font-weight: 700; line-height: 1;
  pointer-events: none;
}
.chess-coord.r { top: 4px; left: 4px; }
.chess-coord.f { bottom: 3px; right: 4px; }
.chess-sq.l .chess-coord { color: var(--chess-dark); }
.chess-sq.d .chess-coord { color: var(--chess-light); }

.chess-pieces { position: absolute; inset: 0; pointer-events: none; }
.chess-piece {
  position: absolute; left: 0; top: 0;
  width: 12.5%; height: 12.5%;
  background: center / 100% 100% no-repeat; /* the piece image: see the .wk/.bq/… rules below */
  z-index: 1;
  /* like Chess.com, a piece glides in a straight line to its square (knights included) */
  transition: transform var(--chess-slide, 350ms) ease;
  will-change: transform;
}
.chess-piece.is-moving { z-index: 3; }      /* the mover passes over whatever it captures */
.chess-piece.is-captured { z-index: 0; }    /* …which stays under it until it lands, then is removed */
/* open-licensed Cburnett set (CC BY-SA 3.0) — credited under the card in index.html */
.chess-piece.wk { background-image: url(../img/pieces/wk.svg); } .chess-piece.bk { background-image: url(../img/pieces/bk.svg); }
.chess-piece.wq { background-image: url(../img/pieces/wq.svg); } .chess-piece.bq { background-image: url(../img/pieces/bq.svg); }
.chess-piece.wr { background-image: url(../img/pieces/wr.svg); } .chess-piece.br { background-image: url(../img/pieces/br.svg); }
.chess-piece.wb { background-image: url(../img/pieces/wb.svg); } .chess-piece.bb { background-image: url(../img/pieces/bb.svg); }
.chess-piece.wn { background-image: url(../img/pieces/wn.svg); } .chess-piece.bn { background-image: url(../img/pieces/bn.svg); }
.chess-piece.wp { background-image: url(../img/pieces/wp.svg); } .chess-piece.bp { background-image: url(../img/pieces/bp.svg); }

.chess-info { min-width: 0; }
.chess-result {
  padding-bottom: 1.2rem; margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.chess-result-title {
  display: block;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2.8vw, 1.55rem);
  font-weight: 700; letter-spacing: -0.025em; line-height: 1.2;
  color: var(--muted);
  transition: color 0.5s ease;
  overflow-wrap: break-word; /* break at spaces first; only split a long name if it truly can't fit */
}
.chess-result-detail {
  display: block; margin-top: 0.35rem;
  font-family: var(--mono); font-size: 0.9rem; font-weight: 500;
  color: var(--muted);
}
.chess-result.is-win .chess-result-title { color: var(--accent2); }
.chess-result.is-loss .chess-result-title { color: var(--chess-loss); }
.chess-result.is-draw .chess-result-title { color: var(--text); }

/* the move list, laid out like Chess.com's: number | White | Black */
.chess-moves {
  list-style: none; margin: 0 0 1.2rem; padding: 0;
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.chess-row { display: grid; grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 1fr); }
.chess-row:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
.chess-row .num {
  display: flex; align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem; font-weight: 500;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border-right: 1px solid var(--border);
}
.chess-move {
  display: flex; align-items: center;
  min-height: 2.5rem; padding: 0.45rem 0.85rem;
  font-size: 0.95rem; font-weight: 600;
  color: var(--muted);
  transition: color 0.3s, background 0.3s;
}
.chess-move.is-gap { font-weight: 500; opacity: 0.5; }
.chess-move.is-played { color: var(--text); }
.chess-move.is-current { color: var(--accent2); background: rgba(var(--accent-rgb), 0.16); }
/* piece icon standing in for the SAN letter; the white piece reads on the dark card */
.chess-fig {
  display: inline-block; flex-shrink: 0;
  width: 1.35em; height: 1.35em; margin: -0.2em 0.04em -0.2em -0.1em;
  background: center / contain no-repeat;
  opacity: 0.55; transition: opacity 0.3s;
}
.chess-move.is-played .chess-fig, .chess-move.is-current .chess-fig { opacity: 1; }
.chess-fig.k { background-image: url(../img/pieces/wk.svg); }
.chess-fig.q { background-image: url(../img/pieces/wq.svg); }
.chess-fig.r { background-image: url(../img/pieces/wr.svg); }
.chess-fig.b { background-image: url(../img/pieces/wb.svg); }
.chess-fig.n { background-image: url(../img/pieces/wn.svg); }

.chess-meta {
  font-family: var(--mono); font-size: 0.82rem; letter-spacing: 0; line-height: 1.8;
  color: var(--muted); margin: 0 0 1.4rem;
}
.chess-credit {
  margin: 0.9rem 0 0;
  font-size: 0.74rem; line-height: 1.5;
  color: var(--muted);
}
.chess-credit a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.chess-credit a:hover { color: var(--text); }
.chess-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.chess-actions .btn { font-size: 0.84rem; padding: 0.65rem 1.2rem; }

@media (max-width: 720px) {
  .chess-card { grid-template-columns: minmax(0, 1fr); padding: 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .chess-piece, .chess-player .chess-tag { transition: none !important; }
}

/* ── CONTACT ─────────────────────────────────────────────────── */
#contact { padding: 6rem 0 5rem; }

.contact-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
}
.contact-box h2 { margin-bottom: 0.7rem; }
.contact-sub { color: var(--muted); font-size: 0.95rem; margin-bottom: 2rem; }

.contact-links {
  display: flex; justify-content: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 2rem;
}
.contact-link {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--border);
  padding: 0.6rem 1.3rem;
  border-radius: 6px;
  transition: color .2s, border-color .2s, transform .35s cubic-bezier(.16,1,.3,1);
}
.contact-link:hover { color: var(--accent2); border-color: var(--accent); }

/* ── ENTRANCE ANIMATIONS (hero only fires once, on load) ───────── */
.hero-tag    { animation: fadeUp .6s ease both; animation-delay: .1s; }
.hero-name   { animation: fadeUp .6s ease both; animation-delay: .2s; }
.hero-role   { animation: fadeUp .6s ease both; animation-delay: .3s; }
.hero-bio    { animation: fadeUp .6s ease both; animation-delay: .4s; }
.hero-actions{ animation: fadeUp .6s ease both; animation-delay: .5s; }
.hero-avatar { animation: fadeUp .6s ease both; animation-delay: .3s; }

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 680px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-avatar { display: none; }
  .exp-item { grid-template-columns: 1fr; }
  .exp-date { padding-bottom: 0; }
  .projects-grid { grid-template-columns: 1fr; }
  .contact-box { padding: 2rem 1.5rem; }
}
