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

:root {
  --bg: #030712;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --faint: #71717a;
  --dim: #52525b;
  --line: #ffffff14;
  --accent: #38bdf8;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

html { background: var(--bg); }
body {
  min-height: 100vh;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* Background layers */
#aurora { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-reduced-motion: reduce) { #aurora { display: none; } }

/* The column is exactly as wide as the home page's "Hello" line (capped at the
   screen, where the line wraps). Only children marked .sizes set that width; the
   rest (nav, portfolio list) are contained so their content can't widen it.
   Pages without that line carry an invisible .sizer copy of it. */
.wrap { position: relative; z-index: 2; width: fit-content; max-width: 100%; margin: 0 auto; padding: 0 1.75rem; }
.wrap > :not(.sizes) { contain: inline-size; }
.sizer { margin: 0; height: 0; overflow: hidden; visibility: hidden; }

/* Nav */
nav { display: flex; justify-content: space-between; align-items: center; height: 72px; font-size: .875rem; }
nav .logo { font-weight: 650; letter-spacing: -.02em; font-size: 1.05rem; color: #fff; }
nav .links { display: flex; gap: 1.75rem; color: var(--muted); }
nav .links a { transition: color .15s; }
nav .links a:hover, nav .links a[aria-current="page"] { color: #fff; }

/* Home hero */
.hero { padding: 18vh 0 14vh; width: fit-content; max-width: 100%; } /* shrink-wraps to the h1 line */
.pill {
  display: inline-flex; align-items: center; gap: .5rem;
  font-size: .8rem; color: var(--muted);
  border: 1px solid var(--line); background: #ffffff08;
  padding: .4rem .8rem; border-radius: 999px; backdrop-filter: blur(8px);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; background: #34d399; box-shadow: 0 0 10px #34d399; }
h1 { margin-top: 1.4rem; }
h1, .sizer { font-size: clamp(2.8rem, 7vw, 4.6rem); font-weight: 650; letter-spacing: -.045em; line-height: 1; }
/* The Latin-tuned negative tracking crushes CJK glyphs. */
:lang(ja) h1, :lang(ja) .sizer, :lang(zh) h1, :lang(zh) .sizer { letter-spacing: normal; }
/* Japanese breaks between any two kana, which split the name mid-word; the ja hello
   line marks its break points with <wbr> instead (anywhere is the narrow-screen fallback). */
:lang(ja) .hero h1, :lang(ja) .sizer {
  word-break: keep-all; overflow-wrap: anywhere;
  /* Below ~408px the 7-em バーラティです no longer fits the column; scale so it does. */
  font-size: min(clamp(2.8rem, 7vw, 4.6rem), 11vw);
}
.lede { margin-top: 1.25rem; max-width: 32rem; font-size: 1.1rem; line-height: 1.6; color: var(--muted); }
.cta { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 1rem 1.25rem; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: #fff; color: var(--bg); font-weight: 550; font-size: .9rem;
  padding: .7rem 1.15rem; border-radius: 999px; transition: transform .15s;
}
.btn:hover { transform: translateY(-1px); }

/* "Find me on:" icon row */
.socials { margin-top: 3rem; display: flex; align-items: center; gap: .5rem; }
.socials p { color: var(--faint); font-size: .85rem; margin-right: .5rem; }
.socials a {
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: .6rem;
  color: var(--muted); border: 1px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
}
.socials a:hover { color: var(--accent); border-color: var(--line); background: #ffffff08; }
.socials svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }

/* Home portfolio reel: auto-scrolling window, content pulled from /portfolio/ */
.reel {
  display: block; margin-top: 2.5rem; width: 100%; /* matches the h1 line: .hero shrink-wraps to it */
  border: 1px solid var(--line); border-radius: .9rem; overflow: hidden;
  background: #ffffff06; backdrop-filter: blur(8px);
  transition: border-color .2s, background .2s, transform .2s;
  view-transition-name: portfolio;
}
.reel[hidden] { display: none; }
.reel:hover { border-color: #ffffff2a; background: #ffffff0a; transform: translateY(-1px); }
.reel:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.reel-head {
  display: flex; justify-content: space-between; padding: .7rem .9rem;
  font-family: var(--mono); font-size: .72rem; color: var(--faint);
  border-bottom: 1px solid var(--line);
}
.reel-go { transition: color .15s; }
.reel:hover .reel-go, .reel:focus-visible .reel-go { color: var(--accent); }
.reel-window {
  height: 15.75rem; overflow: hidden;
  -webkit-mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
          mask-image: linear-gradient(transparent, #000 18%, #000 82%, transparent);
}
.reel-track { animation: reel-scroll var(--dur, 15s) linear infinite; }
.reel:hover .reel-track, .reel:focus-visible .reel-track { animation-play-state: paused; }
@keyframes reel-scroll { to { transform: translateY(-50%); } }
.reel-row { display: grid; grid-template-columns: 3.5rem 1fr auto; gap: .8rem; align-items: center; padding: .5rem .9rem; }
.reel-row .preview { width: 3.5rem; border-radius: .35rem; }
.reel-row .name { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reel-row .year { font-family: var(--mono); font-size: .72rem; color: var(--dim); }

/* Portfolio */
.page-head { padding: 12vh 0 3rem; }
.page-head h1 { margin-top: 0; font-size: clamp(2.4rem, 6vw, 3.6rem); }
.page-head .lede { font-size: 1rem; }

.index { view-transition-name: portfolio; list-style: none; border-bottom: 1px solid var(--line); margin-bottom: 16vh; }
.item { position: relative; border-top: 1px solid var(--line); transition: background .2s; }
.item:hover, .item:focus-within { background: #ffffff0a; }
.item .row {
  display: grid; grid-template-columns: 3.5rem 1fr auto; gap: 1rem; align-items: baseline;
  padding: 1.05rem .75rem;
}
.item .year { font-family: var(--mono); font-size: .8rem; color: var(--dim); }
.item .name { font-size: 1rem; }
.item .role { color: var(--faint); }
.item .go { color: var(--faint); transition: color .15s; }
.item:hover .go, .item:focus-within .go { color: var(--accent); }
/* Stretched link: the arrow's hit area covers the whole row, expanded blurb included.
   Don't put a transform on .go: it would become the containing block and shrink this. */
.item .go::after { content: ""; position: absolute; inset: 0; }
.item .go:focus-visible { outline: none; }
.item .go:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Expand on hover / tap (focus) using the 0fr -> 1fr grid trick */
.item .more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s ease; }
.item:hover .more, .item:focus-within .more { grid-template-rows: 1fr; }
.item .more > div { overflow: hidden; }
/* Touch: a tap follows the link, so there's no hover state to reveal the blurb with. */
@media (hover: none) { .item .more { grid-template-rows: 1fr; } }
.item .detail { display: grid; grid-template-columns: 3.5rem 1fr; gap: 1rem; padding: 0 .75rem 1.1rem; }
.item .detail > * { grid-column: 2; }
.item .preview { width: 100%; max-width: 420px; border-radius: .6rem; }
.preview {
  display: block; aspect-ratio: 16 / 9; object-fit: cover;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #1e3a8a55, #0e749055);
}
.item .blurb { margin-top: .75rem; font-size: .9rem; color: var(--muted); line-height: 1.55; max-width: 34rem; }

/* Page-to-page transition (cross-document View Transitions; browsers without
   support just navigate normally). The home reel and the portfolio list share
   the name "portfolio", so the small window morphs into the full list. */
@view-transition { navigation: auto; }
::view-transition-group(*) { animation-duration: .5s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
::view-transition-old(portfolio), ::view-transition-new(portfolio) {
  height: 100%; object-fit: cover; object-position: top;
}
/* The reel's snapshot gets stretched as the group grows; fade it out early. */
::view-transition-old(portfolio) { animation-duration: .18s; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .reel-track { animation: none; }
}

/* Language switcher: native <details> dropdown; lang.js closes it on Esc / outside click */
.langs { position: relative; margin-left: .25rem; padding-left: 1.25rem; border-left: 1px solid var(--line); font-size: .8rem; letter-spacing: .04em; }
.langs summary { list-style: none; cursor: pointer; transition: color .15s; }
.langs summary::-webkit-details-marker { display: none; }
.langs summary::after { content: ""; display: inline-block; width: .35em; height: .35em; margin: 0 0 .2em .45em; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.langs summary:hover, .langs[open] summary { color: #fff; }
.langs ul {
  position: absolute; top: calc(100% + 1.1rem); right: 0; z-index: 10; list-style: none; padding: .35rem; min-width: 9rem;
  border: 1px solid var(--line); border-radius: .9rem; background: #0a0a0fd9; backdrop-filter: blur(8px);
}
.langs li a { display: block; padding: .6rem .85rem; border-radius: .55rem; }
.langs li a[aria-current="true"] { color: #fff; }
.langs li a:hover { background: #ffffff08; }

@media (max-width: 560px) {
  nav .links { gap: .9rem; }
  .langs { padding-left: .9rem; margin-left: 0; }
  .socials { flex-wrap: wrap; }
  .socials p { width: 100%; margin-bottom: .25rem; }
  .item .row, .item .detail { grid-template-columns: 2.75rem 1fr auto; gap: .75rem; }
}

.no-nick .nick { display: none; }
