:root {
  color-scheme: dark;
  --ink: #11110f;
  --paper: #f2eee5;
  --paper-deep: #e6dfd2;
  --text: #22211e;
  --muted: #706d66;
  --line: #d4ccbe;
  --accent: #d25235;
  --accent-dark: #963a27;
  --white: #fffdf8;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--ink);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.65;
}

a {
  color: inherit;
}

.skip-link {
  position: fixed;
  top: -5rem;
  left: 1rem;
  z-index: 20;
  padding: 0.65rem 1rem;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
}

.skip-link:focus {
  top: 1rem;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(20rem, 42vw) minmax(0, 1fr);
  min-height: 100vh;
}

.portrait {
  position: sticky;
  top: 0;
  height: 100vh;
  min-height: 38rem;
  overflow: hidden;
  background: #44413d;
}

.portrait > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.78) contrast(1.04);
}

.portrait-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgb(8 8 7 / 45%), transparent 30%),
    linear-gradient(to top, rgb(8 8 7 / 62%), transparent 35%);
  pointer-events: none;
}

.profile-card {
  min-width: 0;
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1.5rem, 4vw, 4rem) clamp(2rem, 4vw, 3rem);
  background:
    radial-gradient(circle at 100% 0, rgb(210 82 53 / 9%), transparent 28rem),
    var(--paper);
}

.profile-header,
.bio,
.links-section {
  width: min(100%, 54rem);
  margin-inline: auto;
}

.eyebrow {
  margin: 0 0 1.4rem;
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

h1,
h2,
p {
  text-wrap: pretty;
}

h1 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.8rem, 7vw, 6.5rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.82;
}

.identity-switch {
  display: grid;
  width: max-content;
  color: inherit;
  text-decoration: none;
}

.identity-name,
.identity-alias {
  grid-area: 1 / 1;
  transition: opacity 180ms ease, transform 180ms ease;
}

.identity-alias {
  opacity: 0;
  transform: translateY(0.15em);
}

.identity-switch:hover .identity-name,
.identity-switch:focus-visible .identity-name {
  opacity: 0;
  transform: translateY(-0.15em);
}

.identity-switch:hover .identity-alias,
.identity-switch:focus-visible .identity-alias {
  opacity: 1;
  transform: translateY(0);
}

.identity-switch:focus-visible {
  border-radius: 0.08em;
  outline: 2px solid var(--accent);
  outline-offset: 0.08em;
}

.tag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  margin: 1.25rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0.28rem rgb(210 82 53 / 14%);
}

.name-note {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 39rem;
  margin: 1.25rem 0 0;
  padding: 0.65rem 0.85rem;
  border-left: 2px solid var(--accent);
  background: rgb(210 82 53 / 6%);
  color: var(--muted);
  font-size: 0.88rem;
}

.name-note p {
  margin: 0;
}

.kiba-image {
  display: block;
  flex: 0 0 3.25rem;
  width: 3.25rem;
  height: 3.25rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 0.2rem;
}

.kiba-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.name-note strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.04em;
}

.pronunciation {
  color: var(--muted);
  font-style: italic;
}

.citation {
  margin-left: 0.18rem;
  font-size: 0.72em;
  line-height: 0;
  vertical-align: super;
}

.citation a,
.references a {
  color: var(--accent-dark);
  font-weight: 750;
  text-underline-offset: 0.2em;
}

.references {
  width: min(100%, 54rem);
  margin: 1.5rem auto 0;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.references h2 {
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.references ol {
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.references li:target {
  background: rgb(210 82 53 / 8%);
}

.references strong {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.back-reference {
  margin-left: 0.2rem;
  text-decoration: none;
}

.bio {
  margin-top: 1.75rem;
  font-size: clamp(0.9rem, 1.3vw, 1.02rem);
  line-height: 1.55;
}

.bio p {
  margin: 0 0 0.65em;
}

.bio .sign-off {
  margin-bottom: 0;
  color: var(--accent-dark);
  font-style: italic;
}

.links-section {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 2.5vw, 2.25rem);
  font-weight: 400;
  letter-spacing: -0.04em;
  line-height: 1;
}

.section-heading > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  white-space: nowrap;
}

.link-groups {
  display: grid;
  gap: 0.85rem;
}

.link-group h3 {
  margin: 0 0 0.3rem;
  color: var(--accent-dark);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  list-style: none;
}

.link-grid li {
  min-width: 0;
  background: var(--paper);
}

.link-grid li:not(:nth-child(7n)):not(:last-child) {
  border-right: 1px solid var(--line);
}

.link-grid a {
  display: grid;
  grid-template-columns: 1.5rem minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: center;
  min-height: 2.65rem;
  padding: 0.4rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 650;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease, padding 160ms ease;
}

.link-grid a > span:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-grid a:hover,
.link-grid a:focus-visible {
  padding-left: 0.7rem;
  background: var(--paper-deep);
  color: var(--accent-dark);
  outline: none;
}

.link-mark {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.48rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.link-mark img {
  display: block;
  width: 0.9rem;
  height: 0.9rem;
}

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

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 75% 20%, rgb(210 82 53 / 22%), transparent 25rem),
    var(--ink);
}

.error-card {
  width: min(100%, 42rem);
  padding: clamp(2rem, 7vw, 5rem);
  background: var(--paper);
}

.error-card > p:not(.eyebrow) {
  margin: 2rem 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.error-card > a {
  display: inline-block;
  color: var(--accent-dark);
  font-weight: 750;
  text-underline-offset: 0.25em;
}

@media (max-width: 920px) {
  .page-shell {
    display: block;
  }

  .portrait {
    position: relative;
    height: min(78vh, 48rem);
    min-height: 32rem;
  }

  .portrait > img {
    object-position: center;
  }

  .profile-card {
    padding-top: 2.5rem;
  }

  .link-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .link-grid li:not(:nth-child(7n)):not(:last-child) {
    border-right: 0;
  }

  .link-grid li:not(:nth-child(5n)):not(:last-child) {
    border-right: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .portrait {
    height: 68vh;
    min-height: 28rem;
  }

  .profile-card {
    padding-inline: 1.25rem;
  }

  h1 {
    font-size: clamp(3.7rem, 19vw, 5.4rem);
  }

  .section-heading {
    display: block;
  }

  .section-heading > span {
    display: block;
    margin-top: 0.75rem;
  }

  .link-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .link-grid li:not(:nth-child(5n)):not(:last-child) {
    border-right: 0;
  }

  .link-grid li:nth-child(odd):not(:last-child) {
    border-right: 1px solid var(--line);
  }

}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
