/* Atelier EMAr · dossier viewer. Full-viewport "table" of three documents, then a reader. */
:root {
  --paper: #F3EFE7;
  --ink: #2B2620;
  --ink-soft: #6E655B;
  --brick: #B5502F;
  --sheet: #FFFFFF;
  --dim: rgba(43, 38, 32, .9);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --text: "Work Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  overflow: hidden;
}

/* Table view */
.table {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.table header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.table h1 { font-family: var(--display); font-style: italic; font-weight: 600; font-size: clamp(20px, 2.6vw, 30px); margin: 0; }
.table header p { margin: 0; font-size: 13px; color: var(--ink-soft); }
.docs { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.docs.col { flex-direction: column; }

.doc { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.doc button {
  position: relative; display: block; padding: 0; border: 0; background: var(--sheet); cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(43,38,32,.10), 0 8px 22px rgba(43,38,32,.12);
  transition: transform .25s ease, box-shadow .25s ease;
}
.doc button.stack {
  box-shadow: 3px 3px 0 -1px var(--sheet), 3px 3px 0 0 rgba(43,38,32,.18),
              6px 6px 0 -1px var(--sheet), 6px 6px 0 0 rgba(43,38,32,.14),
              0 8px 22px rgba(43,38,32,.12);
}
.doc img { display: block; width: 100%; height: 100%; object-fit: cover; }
.doc button::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s ease;
  background: radial-gradient(circle at var(--x, 50%) var(--y, 50%), rgba(255, 248, 230, .28), rgba(255, 248, 230, 0) 45%);
}
@media (hover: hover) {
  .doc button:hover::after { opacity: 1; }
  .doc button:hover { transform: translateY(-2px); }
}
.doc button:focus-visible::after { opacity: 1; }
.doc button:focus-visible { outline: 2px solid var(--brick); outline-offset: 4px; }
.doc .cap { text-align: center; line-height: 1.3; width: 0; min-width: 100%; }
.doc .cap strong { display: block; font-family: var(--display); font-weight: 600; font-size: 15px; }
.doc .cap span { font-size: 12px; color: var(--ink-soft); }

/* Reader */
.reader {
  position: fixed; inset: 0; z-index: 10; background: var(--dim);
  display: flex; align-items: center; justify-content: center;
  animation: fade .2s ease;
}
.frame { position: relative; display: flex; }
.frame.right { justify-content: flex-end; }
.frame.left { justify-content: flex-start; }
.frame.center { justify-content: center; }
.page { display: block; height: 100%; width: auto; background: var(--sheet); cursor: pointer; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.frame.fold::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 30px; transform: translateX(-50%); pointer-events: none;
  background: linear-gradient(90deg, rgba(43,38,32,0), rgba(43,38,32,.12) 48%, rgba(43,38,32,.18) 50%, rgba(43,38,32,.12) 52%, rgba(43,38,32,0));
}
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px; border: 0; background: transparent; color: var(--paper);
  font: 400 34px/1 var(--display); cursor: pointer; opacity: .7; z-index: 2;
}
.nav:hover:not(:disabled) { opacity: 1; }
.nav:disabled { opacity: .15; cursor: default; }
.nav.prev { left: max(4px, env(safe-area-inset-left, 0px)); }
.nav.next { right: max(4px, env(safe-area-inset-right, 0px)); }
.bar {
  position: absolute; left: 0; right: 0; bottom: 0; text-align: center; color: var(--paper);
  font-size: 13px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom, 0px)); pointer-events: none;
  font-variant-numeric: tabular-nums;
}
.bar .hint { opacity: .6; margin-left: 10px; }
.close {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: max(12px, env(safe-area-inset-right, 0px));
  border: 1px solid rgba(243,239,231,.4); background: transparent; color: var(--paper);
  font: 500 13px var(--text); padding: 6px 12px; cursor: pointer; border-radius: 2px; z-index: 2;
}
.reader button:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .reader { animation: none; }
  .doc button, .doc button::after { transition: none; }
  .doc button:hover { transform: none; }
}
@media (hover: none) { .bar .hint { display: none; } }
