/* ============================================================
   ngchenyi — landing + shared shell
   Design tokens & card spec are 1:1 from the "Design A" handoff.
   No inline styles anywhere (keeps a strict 'self' CSP).
   ============================================================ */
:root {
  --bg: #141210;
  --stage: #0e0c0a;
  --ink: #f2ede3;
  --muted: #948d80;
  --faint: rgba(242, 237, 227, 0.09);
  --accent: #ff7b72;
  --serif: "Newsreader", Georgia, serif;
  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }

body {
  min-height: 100vh;
  background: var(--stage);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;            /* safety net against any sub-pixel overflow */
}

/* full-viewport animated shader stage */
.bg-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; display: block;
}
/* graceful CSS fallback under the canvas */
.bg-canvas::after { content: ""; }
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(120% 80% at 70% 15%, rgba(255, 123, 114, 0.05), transparent 60%),
    radial-gradient(100% 90% at 20% 90%, rgba(120, 110, 95, 0.06), transparent 55%),
    var(--stage);
}

.stage {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 20px;
}

/* perspective wrapper for the 3D tilt */
.card-wrap { perspective: 1100px; width: 100%; max-width: 460px; }

/* ============ the card ============ */
.pcard {
  position: relative;
  width: 100%;
  max-width: 460px;
  /* grows to fit the extra Blog / Leave-a-message rows (design baseline was 624px) */
  min-height: 624px;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  border-radius: 6px;
  padding: 44px 40px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(242, 237, 227, 0.04);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
}
.pcard a { color: inherit; text-decoration: none; }

/* subtle moving sheen driven by tilt (pure CSS var, JS feeds --mx/--my) */
.pcard .sheen {
  position: absolute; inset: -1px; pointer-events: none; z-index: 3; opacity: .55;
  background: radial-gradient(220px 220px at var(--mx, 50%) var(--my, 0%),
    rgba(255, 123, 114, 0.10), transparent 60%);
  transition: opacity .4s var(--ease);
}

.grain {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.5; z-index: 2;
  background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 4px 4px;
}

.kicker {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
}
.accent { color: var(--accent); }

.avatar {
  width: 96px; height: 96px; border-radius: 50%;
  object-fit: cover; object-position: 50% 20%;
  filter: grayscale(0.15) contrast(1.02);
  box-shadow: 0 0 0 1px var(--faint), 0 14px 40px rgba(0, 0, 0, 0.5);
  z-index: 4;
}

.name {
  font-family: var(--serif); font-weight: 400; font-size: 40px;
  line-height: 1.05; letter-spacing: -0.01em; margin: 26px 0 0; z-index: 4;
}

.handle {
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  margin-top: 10px; letter-spacing: 0.04em; z-index: 4;
}
.handle .dot { opacity: 0.4; }

.section { width: 100%; text-align: left; z-index: 4; }
.section.ctf { margin-top: 30px; }

.ctf-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.ctf-row { display: flex; align-items: baseline; gap: 12px; }
.ctf-rank {
  font-family: var(--mono); font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.05em; white-space: nowrap;
}
.ctf-name { font-size: 14px; line-height: 1.35; }
.ctf-name .yr { color: var(--muted); font-family: var(--mono); font-size: 11.5px; }

.edu-label { margin-top: 24px; }
.edu-value { font-size: 14px; margin-top: 10px; }

/* link rows */
.links { width: 100%; margin-top: 26px; display: flex; flex-direction: column; z-index: 4; }
.lrow {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 11px 0; border-top: 1px solid var(--faint);
  transition: padding-left 0.35s var(--ease), color 0.25s ease;
}
.lrow:last-child { border-bottom: 1px solid var(--faint); }
.lrow .lname { font-size: 14px; font-weight: 500; letter-spacing: 0.01em; }
.lrow .lmeta { display: flex; align-items: baseline; gap: 10px; }
.lrow .lhandle { font-family: var(--mono); font-size: 11.5px; color: var(--muted); transition: color 0.25s ease; }
.lrow .arrow { font-family: var(--mono); font-size: 12px; color: var(--muted); transition: transform 0.35s var(--ease), color 0.25s ease; }
.lrow:hover { padding-left: 8px; }
.lrow:hover .lname { color: var(--accent); }
.lrow:hover .arrow { color: var(--accent); transform: translate(3px, -3px); }
.lrow:hover .lhandle { color: var(--ink); }

/* the "Writing" → blog row, set apart a little */
.writing { margin-top: 18px; }
.writing .lname { font-family: var(--sans); }
.writing .lhandle { color: var(--accent); opacity: .8; }

/* ===== entrance motion + stagger ===== */
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes fadeBlur { from { opacity: 0; filter: blur(6px); } to { opacity: 1; filter: blur(0); } }
@media (prefers-reduced-motion: no-preference) {
  .anim { opacity: 0; animation: riseIn 0.7s var(--ease) forwards; animation-delay: var(--d, 0s); }
  .anim-blur { opacity: 0; animation: fadeBlur 0.9s var(--ease) forwards; animation-delay: var(--d, 0s); }
}
/* stagger steps (no inline styles, CSP-clean) */
.s1{--d:.05s}.s2{--d:.18s}.s3{--d:.30s}.s4{--d:.36s}.s5{--d:.42s}.s6{--d:.48s}
.s7{--d:.56s}.s8{--d:.60s}.s9{--d:.66s}.s10{--d:.72s}.s11{--d:.78s}.s12{--d:.84s}.s13{--d:.92s}

/* scramble: while settling, characters glow faintly */
.scramble.is-running { color: var(--accent); }
.handle .scramble.is-running { color: var(--accent); }

/* button rows reset (the "Leave a message" trigger is a <button>) */
button.lrow {
  background: none; border: 0; border-top: 1px solid var(--faint);
  width: 100%; font: inherit; color: inherit; cursor: pointer; text-align: left;
}

/* ===== contact modal ===== */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(8, 7, 6, 0.66);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fadeIn .3s var(--ease);
}
.modal-card {
  position: relative; width: 100%; max-width: 420px;
  max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--faint); border-radius: 10px;
  padding: 28px 26px 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  animation: popIn .4s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-x {
  position: absolute; top: 12px; right: 14px; background: none; border: 0;
  color: var(--muted); font-size: 14px; cursor: pointer; font-family: var(--mono);
}
.modal-x:hover { color: var(--accent); }
.modal-title { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0 0 4px; }
.modal-sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%; background: #0e0c0a; border: 1px solid var(--faint); border-radius: 6px;
  color: var(--ink); font-family: var(--sans); font-size: 14px; padding: 10px 12px;
  transition: border-color .2s ease, box-shadow .2s ease; resize: vertical;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 123, 114, 0.12);
}
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.submit {
  width: 100%; margin-top: 4px; padding: 11px; border: 0; border-radius: 6px;
  background: var(--accent); color: #2a0f0c; font-family: var(--sans); font-weight: 700;
  font-size: 14px; cursor: pointer; transition: filter .2s ease, transform .2s ease;
}
.submit:hover { filter: brightness(1.06); }
.submit:disabled { opacity: .6; cursor: default; }
.form-status { min-height: 18px; margin-top: 10px; font-size: 13px; color: var(--muted); text-align: center; }
.form-status.ok { color: #7ee2a8; }
.form-status.err { color: var(--accent); }

@media (max-width: 500px) {
  .pcard { min-height: 0; padding: 36px 24px 30px; }
  .stage { padding: 24px 14px; }
  .name { font-size: 34px; }
  .modal { padding: 12px; }
  .modal-card { padding: 24px 20px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-card { animation: none; }
}
