:root {
  color-scheme: dark;
  --bg: oklch(0.12 0.02 290);
  --fg: oklch(0.95 0.02 210);
  --fg-soft: oklch(0.95 0.02 210 / 0.9);
  --card: oklch(0.16 0.03 290 / 0.75);
  --card-soft: oklch(0.16 0.03 290 / 0.6);
  --muted: oklch(0.7 0.04 260);
  --border: oklch(0.86 0.15 195 / 0.25);
  --neon: oklch(0.86 0.15 195);
  --ruby: oklch(0.68 0.26 350);
  --volt: oklch(0.92 0.18 105);
  --blood: oklch(0.5 0.22 25);

  --font-mono: 'JetBrains Mono', 'DotGothic16', ui-monospace, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', monospace;
  --font-dot: 'DotGothic16', 'Hiragino Kaku Gothic ProN', sans-serif;
  --font-brush: 'Yuji Boku', 'Hiragino Mincho ProN', serif;
}

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

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

img,
svg {
  display: block;
}

::selection {
  background: var(--ruby);
  color: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Utilities ---------- */

.clip-cyber {
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.text-glow {
  text-shadow:
    0 0 6px oklch(0.86 0.15 195 / 0.7),
    0 0 18px oklch(0.86 0.15 195 / 0.35);
}

.text-glow-ruby {
  text-shadow:
    0 0 6px oklch(0.68 0.26 350 / 0.8),
    0 0 18px oklch(0.68 0.26 350 / 0.4);
}

/* ---------- Shell / background ---------- */

.shell {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, oklch(0.86 0.15 195 / 0.07) 1px, transparent 1px),
    linear-gradient(to bottom, oklch(0.86 0.15 195 / 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 80%);
}

.bg-glow {
  position: fixed;
  left: 50%;
  width: 40rem;
  height: 24rem;
  transform: translateX(-50%);
  border-radius: 9999px;
  filter: blur(64px);
  pointer-events: none;
}

.bg-glow--top {
  top: -10rem;
  background: oklch(0.68 0.26 350 / 0.2);
}

.bg-glow--bottom {
  bottom: -10rem;
  background: oklch(0.86 0.15 195 / 0.15);
}

.scanlines {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  background-image: repeating-linear-gradient(
    to bottom,
    oklch(1 0 0 / 0.035) 0px,
    oklch(1 0 0 / 0.035) 1px,
    transparent 1px,
    transparent 3px
  );
}

.container {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 28rem;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.prompt {
  color: var(--neon);
}

.back {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--neon);
  transition: color 0.2s;
}

.back:hover {
  color: var(--ruby);
}

.back svg {
  width: 14px;
  height: 14px;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--volt);
  box-shadow: 0 0 8px var(--volt);
}

main {
  flex: 1;
}

.footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.caret {
  margin-left: 0.25rem;
  color: var(--neon);
  animation: blink 1s steps(1) infinite;
}

/* ---------- Profile ---------- */

.profile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.avatar {
  position: relative;
}

.avatar-frame {
  position: absolute;
  inset: -6px;
  background: linear-gradient(to bottom right, var(--neon), transparent, var(--ruby));
  opacity: 0.9;
}

.avatar-inner {
  position: relative;
  padding: 4px;
  background: var(--bg);
}

.avatar img {
  width: 7rem;
  height: 7rem;
  object-fit: cover;
}

.badge {
  position: absolute;
  right: -0.75rem;
  bottom: -0.5rem;
  padding: 2px 6px;
  background: var(--volt);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--bg);
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: var(--ruby);
}

.profile .eyebrow {
  margin-top: 1.5rem;
}

.display {
  font-family: var(--font-dot);
  font-size: 2.25rem;
  font-weight: 400;
  line-height: 2.5rem;
  letter-spacing: 0.1em;
  color: var(--fg);
}

.profile .display {
  margin-top: 0.5rem;
}

.name-en {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: var(--neon);
}

/* ---------- Frames / panels ---------- */

.frame {
  position: relative;
  border: 1px solid var(--border);
  background: var(--card);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.corner {
  position: absolute;
  width: 12px;
  height: 12px;
}

.corner--tl {
  top: 0;
  left: 0;
  border-top: 2px solid var(--neon);
  border-left: 2px solid var(--neon);
}

.corner--br {
  right: 0;
  bottom: 0;
  border-right: 2px solid var(--ruby);
  border-bottom: 2px solid var(--ruby);
}

.frame-label {
  position: absolute;
  top: -10px;
  left: 1rem;
  padding: 0 0.5rem;
  background: var(--bg);
  font-size: 10px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--neon);
}

.motto {
  width: 100%;
  margin-top: 2rem;
  padding: 1.5rem 1.25rem;
  background: var(--card-soft);
}

.motto .frame-label {
  font-size: 9px;
  color: var(--muted);
}

.panel {
  margin-bottom: 1.5rem;
  padding: 1.5rem 1.25rem 1.25rem;
}

/* ---------- Motto emblem ---------- */

.emblem {
  position: relative;
  width: 100%;
  max-width: 22rem;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border: 6px solid var(--blood);
  border-radius: 50%;
  background: #000 url('../images/motto-pattern.png');
  background-size: 220px;
  box-shadow:
    0 0 0 3px #000,
    0 0 0 5px var(--blood),
    0 0 40px oklch(0.55 0.24 25 / 0.45);
}

.emblem-vignette {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, transparent 35%, rgba(0, 0, 0, 0.75) 100%);
}

.emblem-ring {
  position: absolute;
  inset: 12px;
  border: 1px solid oklch(0.5 0.22 25 / 0.6);
  border-radius: 50%;
}

.emblem-text {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  padding: 0 2rem 2.5rem;
  font-family: var(--font-brush);
  line-height: 1;
}

.emblem-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.emblem-col:nth-child(1) { margin-top: 0.5rem; transform: rotate(-3deg); }
.emblem-col:nth-child(2) { margin-top: 2.5rem; transform: rotate(2deg); }
.emblem-col:nth-child(3) { margin-top: 0; transform: rotate(-2deg); }
.emblem-col:nth-child(4) { margin-top: 3rem; transform: rotate(3deg); }
.emblem-col:nth-child(5) { margin-top: 1rem; transform: rotate(-1deg); }

.brush {
  display: block;
  color: #fff;
  -webkit-text-stroke: 0.09em oklch(0.58 0.24 25);
  paint-order: stroke fill;
  text-shadow:
    0.04em 0.05em 0 oklch(0.4 0.2 25),
    0 0 0.35em oklch(0.6 0.25 25 / 0.55);
}

.brush--kanji {
  margin: -2px 0;
  font-size: 2.9rem;
}

.brush--kana {
  margin: 2px 0;
  font-size: 1.45rem;
}

.emblem-mark {
  position: absolute;
  right: 16%;
  bottom: 14%;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
}

/* ---------- Sections ---------- */

.section {
  margin-top: 2.5rem;
}

.section + .section {
  margin-top: 2rem;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 10px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: var(--muted);
}

.section-heading::before,
.section-heading::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------- Link cards ---------- */

.link-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  background: var(--card);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--neon);
  background: oklch(0.86 0.15 195 / 0.1);
}

.card:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: -4px;
}

.card-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 2px;
  background: var(--ruby);
  transition: width 0.2s, background-color 0.2s;
}

.card:hover .card-bar {
  width: 4px;
  background: var(--neon);
}

.card-icon {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--neon);
  transition: color 0.2s, border-color 0.2s;
}

.card:hover .card-icon {
  border-color: var(--ruby);
  color: var(--ruby);
}

.card-icon svg {
  width: 20px;
  height: 20px;
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.card-code {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--muted);
}

.card-title,
.card-sub {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

.card-trail {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--muted);
  transition: transform 0.2s, color 0.2s;
}

.card:hover .card-trail {
  transform: translateX(2px);
  color: var(--neon);
}

/* ---------- Social grid ---------- */

.social-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.card--sm {
  gap: 0.75rem;
  padding: 0.75rem;
}

.card--sm:hover .card-bar {
  width: 2px;
}

.card--sm .card-icon {
  width: 2.25rem;
  height: 2.25rem;
}

.card--sm .card-icon svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.card--sm .card-code {
  font-size: 8px;
}

.card--sm .card-title {
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

/* ---------- Sub pages ---------- */

.page-title {
  margin-bottom: 2rem;
}

.page-title .display {
  margin-top: 0.25rem;
  text-transform: uppercase;
}

.profile-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  font-size: 0.875rem;
}

.profile-list dt {
  font-size: 10px;
  line-height: 1.5rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--muted);
}

.profile-list dd {
  line-height: 1.5rem;
}

.prose {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--fg-soft);
}

.skills {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.skill-group h3 {
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--ruby);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag {
  padding: 0.25rem 0.5rem;
  border: 1px solid oklch(0.86 0.15 195 / 0.4);
  background: oklch(0.86 0.15 195 / 0.05);
  font-size: 0.75rem;
  color: var(--neon);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-left: 1.25rem;
  border-left: 1px solid var(--border);
}

.timeline li {
  position: relative;
}

.timeline li::before {
  content: '';
  position: absolute;
  top: 0.375rem;
  left: -1.6rem;
  width: 0.5rem;
  height: 0.5rem;
  transform: rotate(45deg);
  background: var(--neon);
  box-shadow: 0 0 8px var(--neon);
}

.timeline-year {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--volt);
}

.timeline-text {
  font-size: 0.875rem;
  color: var(--fg-soft);
}

.btn-mail {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--neon);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--bg);
  word-break: break-all;
  transition: background-color 0.2s, color 0.2s;
}

.btn-mail:hover {
  background: var(--ruby);
  color: #fff;
}

.btn-mail:focus-visible {
  outline: 2px solid var(--neon);
  outline-offset: 2px;
}

/* ---------- Glitch ---------- */

.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
}

.glitch::before {
  color: var(--ruby);
  animation: glitch-a 3.2s infinite steps(1);
}

.glitch::after {
  color: var(--neon);
  animation: glitch-b 2.7s infinite steps(1);
}

@keyframes glitch-a {
  0%, 88%, 100% { transform: translate(0); clip-path: inset(0 0 100% 0); }
  90% { transform: translate(-3px, -1px); clip-path: inset(10% 0 55% 0); }
  94% { transform: translate(3px, 1px); clip-path: inset(40% 0 30% 0); }
}

@keyframes glitch-b {
  0%, 84%, 100% { transform: translate(0); clip-path: inset(100% 0 0 0); }
  86% { transform: translate(3px, 1px); clip-path: inset(60% 0 10% 0); }
  92% { transform: translate(-2px, 0); clip-path: inset(20% 0 60% 0); }
}

@keyframes blink {
  50% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch::before,
  .glitch::after,
  .caret {
    animation: none;
  }
  .glitch::before,
  .glitch::after {
    display: none;
  }
  .card,
  .card-trail {
    transition: none;
  }
}
