/* Skadi dossier: page layout on top of endfield.css.
   Colours, type and components come from the kit; this file only places them. */

@font-face {
  font-family: 'Saira Variable';
  src: url('./fonts/Saira.ttf') format('truetype-variations');
  font-weight: 100 900;
  font-stretch: 50% 125%;
  font-display: swap;
}

:root {
  /* Locally installed Chinese sans first, so the site works offline. */
  --ef-font-ui: 'Saira Variable', 'Saira', 'Microsoft YaHei UI', 'Microsoft YaHei',
    'PingFang SC', 'Noto Sans SC', sans-serif;
  --ef-font-text: 'Microsoft YaHei UI', 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC',
    sans-serif;
  /* Cold-sea three-colour strip: blue, accent, mint. */
  --ef-tri-a: #2f6bff;
  /* The kit's dialogs use a literal scrim; name it so this page can reuse it. */
  --ef-scrim: rgb(22 22 22 / 0.5);
}

:root[data-theme='dark'] {
  --ef-scrim: rgb(0 0 0 / 0.63);
}

/* ---------- shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 12rem minmax(0, 1fr);
  min-height: calc(100dvh - 3px);
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
}

.rail a:not(.brand) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.rail a small {
  color: var(--ef-ink-2);
  font-size: 0.625rem;
  font-stretch: var(--ef-wider);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.rail a[aria-current] small {
  color: inherit;
}

.rail .rail-foot {
  margin-top: auto;
  padding: 1rem 1.25rem 0;
  border-top: 1px solid var(--ef-rule);
}

.rail .rail-foot p {
  margin: 0 0 0.6rem;
}

@media (max-width: 1099px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .rail {
    position: static;
    height: auto;
  }
  .rail .brand {
    flex-basis: 100%;
    padding: 0 0 0.5rem;
  }
  .rail a:not(.brand) {
    padding: 0.35rem 0.6rem;
  }
  .rail .rail-foot {
    display: none;
  }
}

/* ---------- reading head ---------- */

.op-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
  margin: 1.25rem 0 0;
  font-size: clamp(2.1rem, 6vw, 2.9rem);
  font-stretch: 112%;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.02;
}

.op-title .en {
  color: var(--ef-ink-2);
  font-size: 0.34em;
  font-stretch: var(--ef-wider);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.op-head .ef-tri {
  margin: 1.25rem 0 1rem;
}

.ids {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
}

.ef-lede {
  max-width: 34rem;
  margin: 0.75rem 0 0;
  font-family: var(--ef-font-text);
  font-size: 1.0625rem;
  line-height: 1.85;
}

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

.idcard {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2rem;
  align-items: start;
  margin: 2.5rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--ef-rule);
}

.idcard .ef-frame {
  height: 19rem;
  margin-bottom: 1.5rem;
}

.idcard .ef-frame .window svg {
  display: block;
  width: 100%;
  height: 100%;
  padding: 1.1rem;
}

.idcard .ef-plate {
  font-size: 0.75rem;
}

.kv {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--ef-rule);
}

.kv li {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--ef-rule);
  font-size: 0.875rem;
  line-height: 1.6;
}

.kv li > span:first-child {
  color: var(--ef-ink-2);
  font-size: 0.75rem;
  font-weight: 600;
}

.kv li > span:last-child {
  font-family: var(--ef-font-text);
}

.kv li b {
  font-family: var(--ef-font-ui);
  font-stretch: var(--ef-wide);
  font-weight: 600;
}

@media (max-width: 700px) {
  .idcard {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
  .idcard .ef-frame {
    height: 24rem;
    max-width: 18rem;
  }
  .idcard .ef-plate {
    left: -0.5rem;
  }
}

/* ---------- figures beside tables ---------- */

.facts-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0 0 1.25rem;
}

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

.rank i {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border: 1px solid var(--ef-ink);
}

.rank i.on {
  background: var(--ef-ink);
}

.rank i.half {
  background: linear-gradient(90deg, var(--ef-ink) 50%, transparent 50%);
}

/* ---------- range ---------- */

.range-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  margin: 1rem 0 0;
}

.range {
  display: grid;
  grid-template-columns: repeat(3, 2.45rem);
  grid-template-rows: repeat(3, 2.45rem);
  border: 1px solid var(--ef-ink);
}

.range span {
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--ef-rule);
  border-bottom: 1px solid var(--ef-rule);
  color: var(--ef-ink-2);
  font-size: 0.75rem;
}

.range span:nth-child(3n) {
  border-right: 0;
}

.range span:nth-child(n + 7) {
  border-bottom: 0;
}

.range span.is-range {
  background: var(--ef-hatch);
  color: var(--ef-ink);
}

.range span.is-self {
  background: var(--ef-ink);
  color: var(--ef-panel);
  font-weight: 700;
}

/* ---------- skills ---------- */

.skill {
  margin: 2.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ef-ink);
}

.skill:first-of-type {
  margin-top: 1.75rem;
}

.skill-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
}

.skill-head h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.skill-head .ef-tag {
  font-size: 0.75rem;
}

.skill-meta {
  margin: 0.35rem 0 1rem;
}

.skill .ef-table-wrap {
  margin-top: 0.5rem;
}

.ef-table tr.is-max td {
  font-weight: 700;
}

.ef-table td:first-child {
  white-space: nowrap;
}

/* Row headers are content, not column labels. */
.ef-table tbody th {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--ef-rule);
  color: var(--ef-ink);
  font-size: 0.9375rem;
  font-stretch: normal;
  font-weight: 600;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  white-space: nowrap;
}

.doc .ef-prose.compact p {
  margin-bottom: 0.35em;
}

/* ---------- materials ---------- */

.mat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.5rem 2rem;
  margin-top: 1rem;
}

.mat-grid h3 {
  margin: 0 0 0.5rem;
}

.mats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.35rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
}

.mats li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--ef-rule);
}

.mats li span:last-child {
  font-family: var(--ef-font-ui);
  font-stretch: var(--ef-wide);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* ---------- prose blocks ---------- */

.doc {
  margin: 2rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ef-rule);
}

.doc h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
  font-weight: 700;
}

.doc h3 .ef-field {
  font-weight: 400;
}

.doc .ef-prose p {
  margin: 0 0 1em;
  font-size: 1rem;
  line-height: 1.9;
}

.doc .ef-prose p:last-child {
  margin-bottom: 0;
}

.doc .ef-prose .sign {
  color: var(--ef-ink-2);
  text-align: right;
}

/* ---------- modules ---------- */

.module {
  margin: 2.75rem 0 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--ef-ink);
}

.module:first-of-type {
  margin-top: 1.75rem;
}

.module-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.25rem;
}

.module-head h2 {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
}

/* ---------- voice ---------- */

.voice-tools {
  display: grid;
  gap: 1rem;
  margin: 1.75rem 0 0;
  padding: 1.25rem 0;
  border-top: 1px solid var(--ef-rule);
  border-bottom: 1px solid var(--ef-rule);
}

.voice-tools .row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.voice-tools .row > .ef-field {
  min-width: 4rem;
}

.voice {
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--ef-rule);
}

.voice:first-child {
  border-top: 1px solid var(--ef-rule);
}

.voice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.voice-head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.voice-text {
  margin: 0;
  font-family: var(--ef-font-text);
  font-size: 1.0625rem;
  line-height: 1.9;
}

.voice-text[data-lang='ja'],
.voice-text[data-lang='en'] {
  color: var(--ef-ink-2);
  font-size: 0.9375rem;
}

.voice-cond {
  margin: 0.5rem 0 0;
}

.voice[hidden] {
  display: none;
}

:root[data-show-lang='zh'] .voice-text:not([data-lang='zh']),
:root[data-show-lang='ja'] .voice-text:not([data-lang='ja']),
:root[data-show-lang='en'] .voice-text:not([data-lang='en']) {
  display: none;
}

.no-result {
  margin: 1.5rem 0;
}

/* ---------- margin ---------- */

.toc {
  position: sticky;
  top: 2rem;
  max-width: 18rem;
}

.toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--ef-rule);
}

.toc ol a {
  display: block;
  margin-left: -1px;
  padding: 0.28rem 0 0.28rem 0.9rem;
  border-left: 3px solid transparent;
  color: var(--ef-ink-2);
  font-size: 0.875rem;
}

.toc ol a[aria-current] {
  color: var(--ef-ink);
  border-left-color: var(--ef-trace);
}

.margin-h {
  margin: 2.5rem 0 0.5rem;
}

.margin-h:first-child {
  margin-top: 0;
}

.ledger-note {
  margin: 0.75rem 0 0;
  color: var(--ef-ink-2);
  font-size: 0.75rem;
  line-height: 1.7;
}

/* ---------- footer ---------- */

.foot {
  margin: 3.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ef-ink);
  color: var(--ef-ink-2);
  font-size: 0.8125rem;
  line-height: 1.8;
}

.foot p {
  margin: 0 0 0.5rem;
}

.foot a {
  color: var(--ef-ink);
}

@media (max-width: 959px) {
  .idcard {
    gap: 1.5rem;
  }
}

/* ---------- header row, avatar, gallery ---------- */

.head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}

.op-icon {
  flex: none;
  width: 4.5rem;
  height: 4.5rem;
  border: 1px solid var(--ef-rule);
  background: var(--ef-panel);
  object-fit: cover;
}

.idcard .ef-frame {
  height: 21rem;
}

.idcard .ef-frame .window img {
  object-fit: contain;
  object-position: 50% 50%;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

/* Thumbnails open the full art: a cut corner says they can be pressed. */
.shot {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 1px solid var(--ef-rule);
  background: var(--ef-panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  clip-path: polygon(
    0 0,
    100% 0,
    100% calc(100% - var(--ef-cut) * 2),
    calc(100% - var(--ef-cut) * 2) 100%,
    0 100%
  );
}

.shot:hover {
  border-color: var(--ef-ink);
}

.shot:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px currentColor;
}

.shot .pic {
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.shot .pic img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.shot .cap {
  display: block;
  padding: 0.6rem 0.7rem 0.7rem;
}

.shot .cap b {
  display: block;
  font-size: 0.875rem;
  font-weight: 700;
}

.shot .cap small {
  display: block;
  color: var(--ef-ink-2);
  font-size: 0.75rem;
}

.outfit-notes {
  margin-top: 1.25rem;
}

.outfit-notes p {
  font-size: 0.9375rem;
}

dialog.lightbox {
  width: min(92vw, 56rem);
  max-width: min(92vw, 56rem);
  padding: 1rem 1rem 0.75rem;
  border: 1px solid var(--ef-ink);
  background: var(--ef-panel);
  color: var(--ef-ink);
}

dialog.lightbox::backdrop {
  background: var(--ef-scrim);
}

dialog.lightbox figure {
  margin: 0;
}

dialog.lightbox img {
  display: block;
  max-width: 100%;
  max-height: 72vh;
  margin: 0 auto;
}

dialog.lightbox figcaption {
  margin-top: 0.75rem;
}

dialog.lightbox .ef-actions {
  margin: 0.75rem 0 0;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .op-icon {
    width: 3.25rem;
    height: 3.25rem;
  }
}

/* ---------- motion: responses (B pack) ---------- */

/* Thumbnails: the trace bar drops in and the caption steps right, 200ms snap,
   the same grammar as a record row. */
.shot {
  position: relative;
  transition: border-color 200ms var(--ef-ease);
}

.shot::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  z-index: 1;
  width: 4px;
  background: var(--ef-trace);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 200ms var(--ef-snap);
}

.shot:hover::before,
.shot:focus-visible::before {
  transform: scaleY(1);
}

.shot .cap > * {
  transition: transform 200ms var(--ef-snap);
}

.shot:hover .cap > *,
.shot:focus-visible .cap > * {
  transform: translateX(6px);
}

/* Filter chips: a short press, 100ms. The cut-corner gradient cannot be wiped
   without breaking its shape, so the press is the response. */
.ef-chip {
  transition: transform 100ms var(--ef-ease);
}

.ef-chip:active {
  transform: translateY(1px) scale(0.985);
}

/* The table-of-contents marker slides instead of jumping. */
.toc ol {
  position: relative;
}

.toc-mark-li {
  margin: 0;
  padding: 0;
}

.toc-mark {
  position: absolute;
  left: -1px;
  top: 0;
  width: 3px;
  background: var(--ef-trace);
  transition: transform 200ms var(--ef-mech);
  pointer-events: none;
}

.toc ol:has(.toc-mark) a[aria-current] {
  border-left-color: transparent;
}

/* The "here" block travels between pages with the shutter. */
.rail a[aria-current] {
  view-transition-name: nav-here;
}

::view-transition-group(nav-here) {
  animation-duration: 360ms;
  animation-timing-function: var(--ef-mech);
}

/* Lightbox: backdrop fades, the picture opens from the top, closing is 180ms. */
@media (prefers-reduced-motion: no-preference) {
  dialog.lightbox[open] > * {
    animation: none;
  }
  dialog.lightbox[open]::backdrop {
    animation: lb-fade-in 200ms var(--ef-ease) both;
  }
  dialog.lightbox[open] img {
    animation: lb-shut 320ms var(--ef-mech) both;
  }
  dialog.lightbox.is-closing {
    animation: lb-out 180ms var(--ef-mech) both;
  }
  dialog.lightbox.is-closing::backdrop {
    animation: lb-fade-out 160ms var(--ef-mech) both;
  }
}

@keyframes lb-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes lb-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes lb-shut {
  from {
    clip-path: inset(0 0 100% 0);
    opacity: 0.35;
  }
  to {
    clip-path: inset(0 0 0 0);
    opacity: 1;
  }
}

@keyframes lb-out {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* ---------- wallpaper gallery (home) ---------- */

.wall-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.wall {
  margin: 0;
}

.wall .shot.wide .pic {
  aspect-ratio: 16 / 9;
}

.wall .shot.wide .pic img {
  object-fit: cover;
}

.wall-meta {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.1rem 0;
}

.wall-meta b {
  font-size: 0.9375rem;
  font-weight: 700;
}

.wall-meta small {
  color: var(--ef-ink-2);
  font-size: 0.75rem;
}

.wall-dl {
  justify-self: start;
  margin-top: 0.35rem;
  padding-bottom: 1px;
  border-bottom: 1px solid currentColor;
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.wall-dl:hover {
  color: var(--ef-trace);
  border-color: var(--ef-trace);
}

.wall-meta .ef-eyebrow {
  margin: 0;
}

@media (max-width: 640px) {
  .wall-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
  }
}

@media print {
  .rail,
  .toc,
  .voice-tools,
  .ef-tri {
    display: none;
  }
  .shell {
    display: block;
  }
}
