/* =========================================================
   Digital Meishi — xenosaba.com palette
   bg #0f1419 / accent #00add8 / border #30363d / text #e6edf3
   ========================================================= */

:root {
  --bg: #0f1419;
  --bg-elev: #13191f;
  --bg-soft: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-soft: #c9d1d9;
  --muted: #8b949e;
  --muted-2: #9aa7b3;
  --accent: #00add8;
  --accent-hover: #33c4e8;
  --accent-deep: #00708c;
  --accent-dark: #005b72;
  --accent-soft: rgba(0, 173, 216, .14);
  --mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, Helvetica, Arial, sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 620px at 50% -12%, rgba(0, 173, 216, .16), transparent 62%),
    radial-gradient(900px 520px at 108% 108%, rgba(0, 112, 140, .12), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 173, 216, .28) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 173, 216, .28) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: .07;
  -webkit-mask-image: radial-gradient(80% 60% at 50% 18%, #000 0%, transparent 76%);
  mask-image: radial-gradient(80% 60% at 50% 18%, #000 0%, transparent 76%);
}

/* Large stepped square motif inspired by the card's pixel artwork. */
body::after {
  content: "";
  position: fixed;
  top: 24px;
  right: -8vw;
  width: min(74vw, 980px);
  height: min(92vh, 1040px);
  z-index: 0;
  pointer-events: none;
  opacity: .82;
  border-radius: 0 58px 58px 0;
  clip-path: polygon(
    0 0, 92% 0, 92% 10%, 100% 10%, 100% 100%,
    0 100%, 0 78%, 12% 78%, 12% 68%, 24% 68%,
    24% 48%, 14% 48%, 14% 35%, 0 35%
  );
  background:
    linear-gradient(#0f1419, #0f1419) 57% 16% / 112px 112px no-repeat,
    linear-gradient(#0f1419, #0f1419) 76% 53% / 112px 112px no-repeat,
    linear-gradient(#0f1419, #0f1419) 89% 79% / 116px 116px no-repeat,
    linear-gradient(#0f1419, #0f1419) 31% 88% / 46px 46px no-repeat,
    linear-gradient(rgba(178, 239, 255, .72), rgba(178, 239, 255, .72)) 53% 65% / 44px 44px no-repeat,
    linear-gradient(rgba(230, 250, 255, .11) 1px, transparent 1px),
    linear-gradient(90deg, rgba(230, 250, 255, .11) 1px, transparent 1px),
    linear-gradient(140deg, #00708c 0%, #00add8 45%, #43d8ef 100%);
  background-size: auto, auto, auto, auto, auto, 48px 48px, 48px 48px, auto;
  box-shadow: -14px 0 38px rgba(0, 173, 216, .2);
}

::selection { background: rgba(0, 173, 216, .35); color: #fff; }

img, svg { display: block; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------------- page ---------------- */

.page {
  position: relative;
  z-index: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(30px, 5.5vw, 68px) clamp(16px, 4vw, 32px) 48px;
}

.hero { text-align: center; margin-bottom: clamp(22px, 3.5vw, 38px); }

.kicker {
  margin: 0 0 .9rem;
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--accent);
}
.kicker::before { content: "// "; opacity: .65; }

.hero-name {
  margin: 0 0 .55rem;
  font-size: clamp(1.9rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.02em;
}

.hero-sub {
  max-width: 46rem;
  margin: 0 auto;
  color: var(--muted-2);
  font-size: clamp(.84rem, 2.3vw, 1rem);
}

/* ---------------- card ---------------- */

.card-area { display: flex; flex-direction: column; align-items: center; }

.card-scene {
  width: min(880px, 100%);
  perspective: 1800px;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 275 / 173;
  transform-style: preserve-3d;
  transform: rotateX(var(--rx, 0deg)) rotateY(calc(var(--ry, 0deg) + var(--flip, 0deg)));
  transition: transform .9s cubic-bezier(.2, .75, .25, 1);
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
}

.card.is-flipped { --flip: 180deg; }
.card.is-tilting { transition: transform .18s ease-out; }
.card.no-anim { transition: none; }

.card:focus-visible .card-face {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 173, 216, .32), 0 26px 60px -26px rgba(0, 0, 0, .9);
}

.card-face {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  background: #f2f0ef;
  border: 1px solid rgba(230, 237, 243, .2);
  border-radius: 12px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 26px 64px -26px rgba(0, 0, 0, .88);
  transition: border-color .25s ease;
}

.card:hover .card-face { border-color: rgba(0, 173, 216, .5); }

.card-back { transform: rotateY(180deg); }
.card-back .pixel { transform: scaleY(-1); }

/* pixel pattern (svg use) */
.pixel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* faint graph-paper grid on top */
.card-face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(0, 173, 216, .08), transparent 42%);
}

.card-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.face-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 53%;
  padding: 5cqw 5.4cqw;
  display: flex;
  flex-direction: column;
}

.face-kicker {
  margin: 0 0 1.8cqw;
  font-family: var(--mono);
  font-size: 1.22cqw;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: .9;
}
.face-kicker::before { content: "// "; opacity: .6; }

/* --- front face --- */

.brand { display: flex; align-items: center; gap: 1.9cqw; }

.brand-mark svg { width: 6.2cqw; height: 6.2cqw; }
.brand-mark rect { fill: var(--accent); }
.brand-mark rect.dim { fill: var(--accent-deep); }

.brand-word {
  font-size: 9.4cqw;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .01em;
}

.brand-sub {
  margin: 1.3cqw 0 0;
  font-family: var(--mono);
  font-size: 1.82cqw;
  letter-spacing: .12em;
  color: var(--text-soft);
}

.brand-jp {
  margin: .4cqw 0 0;
  font-size: 1.58cqw;
  letter-spacing: .06em;
  color: var(--muted);
}

.contact-cols,
.back-contacts {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1.15cqw;
  margin: auto 0 0;
  padding: 0;
}

.contact-cols {
  padding-top: 1.7cqw;
  border-top: 1px solid var(--border);
}

.contact-cols li,
.back-contacts li {
  display: grid;
  grid-template-columns: 14ch minmax(0, 1fr);
  gap: 1.8cqw;
  align-items: baseline;
  min-width: 0;
}

.k {
  font-family: var(--mono);
  font-size: 1.12cqw;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--muted);
}

.contact-cols a {
  font-family: var(--mono);
  font-size: 1.36cqw;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.contact-cols a:hover { color: var(--accent); }

.campuses {
  list-style: none;
  margin: auto 0 0;
  padding: 0;
}

.campuses li {
  font-family: var(--mono);
  font-size: 1.28cqw;
  line-height: 1.75;
  color: var(--muted);
}
.campuses li + li { margin-top: .9cqw; }

.campuses span {
  color: var(--accent);
  opacity: .85;
  margin-right: .5em;
}

/* --- back face --- */

.back-head { display: flex; flex-direction: column; }

.back-org {
  margin: .2cqw 0 0;
  display: flex;
  align-items: center;
  gap: 1cqw;
  font-family: var(--mono);
  font-size: 1.4cqw;
  letter-spacing: .1em;
  color: var(--muted-2);
}

.rcc-chip {
  padding: .1cqw .8cqw .15cqw;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 1.1cqw;
  font-weight: 700;
  letter-spacing: .16em;
  color: var(--accent);
}

.name-block { margin-top: auto; }

.dept {
  margin: 0 0 .8cqw;
  font-size: 1.8cqw;
  letter-spacing: .08em;
  color: var(--muted-2);
}

.name {
  margin: 0;
  font-size: 8.6cqw;
  font-weight: 700;
  line-height: 1.12;
  letter-spacing: .02em;
}

.name-en {
  margin: 1cqw 0 0;
  font-family: var(--mono);
  font-size: 1.85cqw;
  letter-spacing: .34em;
  color: var(--accent);
}

.back-contacts .v {
  font-family: var(--mono);
  font-size: 1.32cqw;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}
.back-contacts a.v:hover { color: var(--accent); }

/* ---------------- flip button ---------------- */

.flip-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 1.15rem auto 0;
  padding: .42rem .95rem;
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .08em;
  color: var(--accent);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background-color .2s ease;
  animation: hintPulse 2.4s ease-out 1.2s 2;
}

.flip-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.flip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.flip-icon { display: inline-block; font-size: 1rem; transition: transform .5s ease; }
.flip-btn:hover .flip-icon { transform: rotate(-180deg); }

@keyframes hintPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(0, 173, 216, 0); }
  45% { box-shadow: 0 0 0 6px rgba(0, 173, 216, .13); }
}

.noscript-note {
  margin: .9rem 0 0;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
}

/* ---------------- sections ---------------- */

.section { margin-top: clamp(48px, 8vw, 88px); }

.section h2 {
  display: inline-block;
  margin: 0 0 1.5rem;
  padding-bottom: .25rem;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -.02em;
  border-bottom: 2px solid var(--accent);
}

.section > p {
  margin: 0 0 1rem;
  color: var(--text-soft);
  font-size: 1.05rem;
  line-height: 1.8;
}

.section .section-lead { color: var(--muted); font-size: .95rem; }

.profile-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem 2rem;
  margin: 1.9rem 0 0;
}

.profile-list > div {
  padding-left: .9rem;
  border-left: 2px solid rgba(0, 173, 216, .28);
}

.profile-list dt {
  margin-bottom: .25rem;
  font-family: var(--mono);
  font-size: .76rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--accent);
}

.profile-list dd { margin: 0; color: var(--text-soft); font-size: .97rem; }

.links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: .9rem;
}

.link-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand, var(--accent));
  border-radius: 10px;
  background: rgba(255, 255, 255, .015);
  color: var(--text);
  text-decoration: none;
  transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}

.link-card:hover {
  transform: translateX(4px);
  border-color: var(--brand, var(--accent));
  background: rgba(255, 255, 255, .035);
  text-decoration: none;
}

.link-info { display: flex; align-items: center; gap: .85rem; min-width: 0; }

.link-badge {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 700;
  color: var(--brand, var(--accent));
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .12);
  background: color-mix(in srgb, var(--brand, var(--accent)) 16%, transparent);
  border-color: color-mix(in srgb, var(--brand, var(--accent)) 42%, transparent);
}

.link-text { display: flex; flex-direction: column; min-width: 0; }

.link-name { font-weight: 600; font-size: 1.02rem; transition: color .2s ease; }
.link-card:hover .link-name { color: var(--brand, var(--accent)); }

.link-meta {
  font-family: var(--mono);
  font-size: .74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.link-arrow {
  font-family: var(--mono);
  color: var(--muted);
  transition: color .2s ease, transform .2s ease;
}
.link-card:hover .link-arrow { color: var(--brand, var(--accent)); transform: translateX(2px); }

.footer {
  margin-top: clamp(48px, 8vw, 80px);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  margin: 0;
  font-family: var(--mono);
  font-size: .8rem;
  color: var(--muted);
}

/* ---------------- mobile: keep the printed landscape card ---------------- */

@media (max-width: 680px) {
  .card-scene { width: min(94vw, 880px); }
  .card-face { border-radius: 8px; }

  body::after {
    top: 16px;
    right: -42vw;
    width: 106vw;
    height: 66vh;
    opacity: .62;
    border-radius: 0 34px 34px 0;
  }
}

/* ---------------- motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .card.is-tilting { transition: none; }
  .flip-btn { animation: none; }
  .flip-icon { transition: none; }
  .link-card, .link-arrow, .link-name { transition: none; }
  body::before { opacity: .05; }
}
