/* Dossier: a plain white column on the right, divided by one hairline. */
.dossier {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: var(--dossier-w);
  background: var(--paper);
  border-left: 1px solid var(--hairline);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform var(--slow) var(--ease), visibility 0s linear var(--slow);
  z-index: 10;
  outline: none;
}
.app.is-open .dossier {
  transform: none; visibility: visible;
  transition: transform var(--slow) var(--ease), visibility 0s;
}

.d-bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px;
  background: var(--paper);
}
.d-level { font-size: 12px; color: var(--muted); }
.d-level b { font-weight: 500; color: var(--tone, var(--water-1)); margin-right: 6px; font-variant-numeric: tabular-nums; }

.d-nav { display: flex; gap: 2px; }
.d-nav button {
  width: 32px; height: 32px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--ink-2);
  transition: background-color var(--mid) var(--ease), color var(--mid) var(--ease);
}
.d-nav button:hover { background: var(--wash); color: var(--ink); }
.d-nav svg { width: 16px; height: 16px; }

.d-body { padding: 8px 28px 48px; }
.d-body.is-swapping { animation: swap 420ms var(--ease) both; }
@keyframes swap { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.d-photo {
  width: 112px; height: 112px; border-radius: 50%;
  object-fit: cover; background: var(--wash);
  outline: 1px solid rgba(17, 18, 20, 0.06);
  outline-offset: -1px;
}
.d-name { margin: 22px 0 0; font-size: 26px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; }
.d-latin { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.d-role { margin: 14px 0 0; font-size: 15px; color: var(--ink-2); }

.d-section { margin-top: 28px; }
.d-section h3 {
  margin: 0 0 6px;
  font-size: 12px; font-weight: 500; color: var(--muted);
  letter-spacing: 0.02em;
}
.d-section p { margin: 0; font-size: 15px; line-height: 1.6; }

.d-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.d-links a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--hairline); border-radius: 999px;
  font-size: 13px; text-decoration: none; color: var(--ink);
  transition: border-color var(--mid) var(--ease), background-color var(--mid) var(--ease);
}
.d-links a:hover { border-color: var(--ink); }
.d-links svg { width: 14px; height: 14px; flex: none; }

/* Nothing chosen yet: the column stays open on wide screens with a hint. */
.app:not(.is-open) .d-nav { visibility: hidden; }
.d-empty { margin: 34vh 0 0; text-align: center; color: var(--muted); font-size: 14px; }

/* Desktop: compact dossier, photo beside the name, so a whole entry fits one screen. */
@media (min-width: 701px) {
  .d-bar { padding: 14px 24px 6px; }
  .d-body {
    display: grid; grid-template-columns: 76px 1fr; column-gap: 16px; align-items: center;
    padding: 6px 24px 14px;
  }
  .d-body > * { grid-column: 1 / -1; }
  .d-body > .d-photo { grid-column: 1; grid-row: 1 / span 2; width: 76px; height: 76px; }
  .d-body > .d-name { grid-column: 2; margin: 0; font-size: 22px; align-self: end; }
  .d-body > .d-latin { grid-column: 2; margin: 2px 0 0; font-size: 13px; align-self: start; }
  .d-role { margin-top: 14px; font-size: 14.5px; }
  .d-section { margin-top: 18px; }
  .d-section h3 { margin-bottom: 4px; }
  .d-section p { font-size: 14.5px; line-height: 1.55; }
  .d-links { margin-top: 20px; gap: 6px; }
  .d-links a { padding: 5px 11px; font-size: 12.5px; }
  .d-body > .d-empty { grid-column: 1 / -1; }
}

/* Wide screens: picture on the left, dossier column always on the right. */
/* One group centred on the screen: levels, picture, dossier. The dossier is a sticky column of
   the page grid instead of a panel glued to the window edge, so no empty field opens between them. */
@media (min-width: 1100px) {
  .app {
    --dossier-w: 440px;
    display: grid; grid-template-columns: max-content var(--dossier-w);
    justify-content: center; column-gap: 40px;
    padding: 0 var(--gutter);
  }
  .stage { padding: 0 0 24px; }
  .dossier {
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    transform: none; visibility: visible;
    transition: none;
  }
  /* the picture also yields to the window width, never pushing the dossier off screen */
  .o-frame {
    width: min(900px, (100dvh - var(--chrome)) * 0.75,
               100vw - var(--dossier-w) - var(--labels) - 40px - 2 * var(--gutter) - 16px);
  }
}

/* Phones: the dossier is a bottom sheet with two heights (peek and full), see src/sheet.js. */
.d-handle { display: none; }

@media (max-width: 700px) {
  .dossier {
    --sheet: 92vh;
    --peek: 54vh;
    top: auto; left: 0; width: 100%;
    height: var(--sheet);
    border-left: 0; border-top: 1px solid var(--hairline);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  @supports (height: 1dvh) {
    .dossier { --sheet: 92dvh; --peek: 54dvh; }
  }
  .app.is-open .dossier { transform: translateY(calc(var(--sheet) - var(--peek))); }
  .app.is-open.is-full .dossier { transform: none; }
  .dossier.is-dragging { transition: none !important; }

  .d-bar { padding: 22px 12px 8px 20px; touch-action: none; cursor: grab; }
  .d-handle {
    display: block;
    position: absolute; top: 8px; left: 50%;
    width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--hairline);
  }
  .d-nav button { width: 40px; height: 40px; border-radius: 10px; }
  .d-nav svg { width: 18px; height: 18px; }

  /* Photo beside the name, so the peek shows who it is without scrolling. */
  .d-body {
    display: grid; grid-template-columns: 64px 1fr; column-gap: 14px; align-items: center;
    padding: 2px 20px calc(40px + env(safe-area-inset-bottom));
  }
  .d-body > * { grid-column: 1 / -1; }
  .d-body > .d-photo { grid-column: 1; grid-row: 1 / span 2; width: 64px; height: 64px; }
  .d-body > .d-name { grid-column: 2; margin: 0; font-size: 21px; align-self: end; }
  .d-body > .d-latin { grid-column: 2; margin: 2px 0 0; font-size: 13px; align-self: start; }
  .d-role { margin-top: 14px; }
  .d-section { margin-top: 22px; }
  .d-links { margin-top: 24px; }
  .d-links a { padding: 9px 14px; font-size: 14px; }
}

/* No Latin line (English page): the name alone sits centred beside the photo. */
.d-body:not(:has(.d-latin)) > .d-name { grid-row: 1 / span 2; align-self: center; }
