/* =========================================================
   1. TOKENS & THEME
   ========================================================= */
:root {
  --bg: #000;
  --fg: #f0f0f0;
  --dim: #858585;
  --line: #262626;
  --ease: cubic-bezier(.77, 0, .18, 1);
  --d: "Doto", "Courier New", monospace;
  --m: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #f2f2f2; --fg: #000; --dim: #6a6a6a; --line: #cfcfcf; }
}
:root[data-theme="light"] { --bg: #f2f2f2; --fg: #000; --dim: #6a6a6a; --line: #cfcfcf; }

/* =========================================================
   2. BASE
   ========================================================= */
* { box-sizing: border-box; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.6 var(--m);
  -webkit-font-smoothing: antialiased;
  transition: background .5s, color .5s;
}
body.lock { overflow: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
ul { list-style: none; margin: 0; padding: 0; }

.dim  { color: var(--dim); }
.disp { font-family: var(--d); font-weight: 700; line-height: 1; margin: 0; }
.view { display: none; }
.view.on { display: block; }

/* shared underline-on-hover link style */
.links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.links a {
  color: inherit;
  text-decoration: none;
  background: linear-gradient(currentColor, currentColor) left bottom / 0 1px no-repeat;
  transition: background-size .45s var(--ease);
}
.links a:hover,
.links a:focus-visible { background-size: 100% 1px; }

/* =========================================================
   3. HEADER
   ========================================================= */
header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 24px 16px;
  color: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
}
header > * { pointer-events: auto; }
.logo { font-family: var(--d); font-weight: 800; font-size: 22px; }

nav.top { display: flex; gap: 22px; }
nav.top button { position: relative; padding: 2px 0; }
nav.top button::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s var(--ease);
}
nav.top button:hover::after,
nav.top button.on::after { transform: scaleX(1); }

/* =========================================================
   4. HOME: HERO + CLOCK
   ========================================================= */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 120px 24px 40px;
}
.clock {
  font-family: var(--d);
  font-weight: 800;
  font-size: clamp(44px, 15vw, 230px);
  line-height: 1;
  white-space: nowrap;
  margin: 18px 0 8px;
}
.clock .d { display: inline-block; width: .62em; text-align: center; }
.clock .d.tick { animation: tick .4s var(--ease); }
.clock .c { display: inline-block; width: .34em; text-align: center; animation: blink 1s steps(1) infinite; }
@keyframes tick  { from { transform: translateY(-35%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes blink { 50% { opacity: .15; } }

.date { font-size: 15px; }

.intro {
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end;
  gap: 16px 64px;
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}
.intro h1 { font-family: var(--m); font-weight: 400; font-size: 18px; margin: 0; }
.intro p  { margin: 0; max-width: 46ch; color: var(--dim); }

/* =========================================================
   5. HOME: PROJECT GRID
   ========================================================= */
.work { padding: 40px 0 0; }
.work-h { display: flex; justify-content: space-between; align-items: baseline; padding: 0 24px 32px; }
.work-h h2 { font-size: clamp(24px, 3.6vw, 40px); }

#list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 36px;
  padding: 8px 24px 32px;
}
.row {
  position: relative;
  isolation: isolate;
  display: flex; flex-direction: column; gap: 6px;
  width: 100%; min-height: 240px;
  padding: 32px;
  text-align: left;
  border: 1px solid var(--line);
  transition: color .4s var(--ease), border-color .4s, transform .5s var(--ease);
}
.row::before {
  content: "";
  position: absolute; inset: 0; z-index: -1;
  background: var(--fg);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform .5s var(--ease);
}
.row:hover,
.row:focus-visible { color: var(--bg); border-color: var(--fg); transform: translateY(-4px); }
.row:hover::before,
.row:focus-visible::before { transform: scaleY(1); }

.row .n { font-family: var(--d); font-weight: 700; font-size: clamp(20px, 2.2vw, 28px); line-height: 1.15; }
.row .t,
.row .k { display: block; color: var(--dim); font-size: 14px; transition: color .4s; }
.row .t { margin-top: auto; }
.row:hover .t,
.row:hover .k { color: var(--bg); }

/* =========================================================
   6. FOOTER
   ========================================================= */
footer {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 12px 24px;
  padding: 48px 24px calc(32px + env(safe-area-inset-bottom, 0px));
  color: var(--dim);
  font-size: 14px;
}

/* =========================================================
   7. ABOUT
   ========================================================= */
.about { min-height: 100svh; max-width: 1100px; padding: 140px 24px 60px; }
.about h2 { font-size: clamp(40px, 9vw, 120px); margin-bottom: 40px; }
.about p  { max-width: 60ch; font-size: 18px; margin: 0 0 20px; }
.about .links { margin-top: 36px; font-size: 18px; }

.tags { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; }
.tags li { border: 1px solid var(--line); padding: 4px 14px; transition: background .3s, color .3s, border-color .3s; }
.tags li:hover { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* =========================================================
   8. PROJECT PANEL
   ========================================================= */
.panel {
  position: fixed; inset: 0; z-index: 30;
  overflow: auto;
  background: var(--fg);
  color: var(--bg);
  visibility: hidden;
  clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
  transition: clip-path .85s var(--ease), visibility 0s .85s;
}
.panel.open {
  visibility: visible;
  clip-path: circle(150% at var(--x, 50%) var(--y, 50%));
  transition: clip-path .85s var(--ease), visibility 0s;
}
.pin {
  max-width: 1100px;
  margin: 0 auto;
  padding: calc(28px + env(safe-area-inset-top, 0px)) 24px calc(32px + env(safe-area-inset-bottom, 0px));
}

/* staggered reveal for panel children (.r) */
.r { opacity: 0; transform: translateY(16px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
.panel.open .r { opacity: 1; transform: none; transition-delay: calc(.4s + var(--i, 0) * .07s); }
.panel.swap .r { transition: none !important; opacity: 0; transform: translateY(16px); }

.x { display: block; margin-left: auto; padding: 4px 16px; border: 1px solid currentColor; }
.x:hover { background: var(--bg); color: var(--fg); }

.pin h2 { font-size: clamp(40px, 10vw, 128px); margin: 56px 0 28px; overflow-wrap: anywhere; }
.sum { font-size: 20px; max-width: 56ch; margin: 0 0 48px; }

.cols { display: grid; grid-template-columns: 1fr 1.6fr; gap: 32px; padding-top: 20px; border-top: 1px solid currentColor; }
.cols h3 { font: inherit; opacity: .55; margin: 0 0 10px; }
.cols li { padding: 4px 0; }

.pn { display: flex; justify-content: space-between; margin-top: 64px; padding-top: 16px; border-top: 1px solid currentColor; }
.pn button { position: relative; padding: 2px 0; }
.pn button::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .4s var(--ease);
}
.pn button:hover::after { transform: scaleX(1); }

/* single cover image */
.pimg { display: none; width: 100%; max-width: 380px; margin: 0 0 44px; border: 1px solid currentColor; }
.pimg.on { display: block; }

/* slideshow */
.show { display: none; width: 100%; max-width: 720px; margin: 0 0 44px; border: 1px solid currentColor; }
.show.on { display: block; }
.show img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: contain; background: #000; }
.show .ctl {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-top: 1px solid currentColor;
  font-size: 14px;
}
.show .ctl button:hover { text-decoration: underline; }

.project-demo {
  display: inline-block;
  margin: 0 0 44px;
  padding: 8px 16px;
  border: 1px solid currentColor;
  color: inherit;
  text-decoration: none;
}
.project-demo:hover,
.project-demo:focus-visible { background: var(--bg); color: var(--fg); }

/* =========================================================
   9. PAGE-TRANSITION WIPE
   ========================================================= */
.wipe {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  background: var(--fg);
  color: var(--bg);
  font-family: var(--d); font-weight: 800; font-size: clamp(32px, 8vw, 96px);
  transform: translateY(100%);
  pointer-events: none;
}
.wipe.in  { transform: none; transition: transform .5s var(--ease); pointer-events: auto; }
.wipe.out { transform: translateY(-100%); transition: transform .55s var(--ease); }

/* =========================================================
   10. RESPONSIVE & ACCESSIBILITY
   ========================================================= */
@media (max-width: 720px) {
  #list { gap: 24px; }
  .cols { grid-template-columns: 1fr; }
  .hero { padding-inline: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}
