/* L'Uccello Meccanico — manuscript stylesheet
   Sepia iron-gall ink on aged parchment; Renaissance serif; hand-drawn annotations. */

@font-face {
  font-family: 'IM Fell English';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/im-fell-english-regular.woff2') format('woff2');
}
@font-face {
  font-family: 'IM Fell English';
  font-style: italic; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/im-fell-english-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'IM Fell English SC';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('../assets/fonts/im-fell-english-sc.woff2') format('woff2');
}

:root {
  --parchment: #e7d9b8;
  --parchment-deep: #d8c69c;
  --ink: #3d2c1a;
  --ink-soft: #5c4527;
  --ink-faint: #8a6f47;
  --accent: #7a2e1d;       /* iron-gall red-brown for rubrication */
  --gold: #9a7420;
  --panel: rgba(231, 217, 184, 0.92);
  --serif: 'IM Fell English', 'Palatino Linotype', Palatino, Georgia, serif;
  --serif-sc: 'IM Fell English SC', 'Palatino Linotype', Palatino, Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--serif);
}

#scene {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.dragging { cursor: grabbing; }

#leader-layer {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 3;
}
#leader-layer line, #leader-layer path {
  stroke: var(--ink-soft);
  stroke-width: 1.1;
  stroke-dasharray: 4 3;
  fill: none;
}
#leader-layer circle { fill: var(--ink-soft); }

#label-layer { position: fixed; inset: 0; pointer-events: none; z-index: 4; }

.part-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--panel);
  border: 1px solid var(--ink-soft);
  border-radius: 2px;
  box-shadow: 2px 2px 0 rgba(61, 44, 26, 0.25);
  padding: 2px 8px 3px;
  font-family: var(--serif-sc);
  font-size: 13px;
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: var(--ink);
}
.part-label .idx {
  color: var(--accent);
  margin-right: 5px;
  font-family: var(--serif);
  font-style: italic;
}

.anno-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--panel);
  font-size: 12px;
  font-style: italic;
  display: flex; align-items: center; justify-content: center;
  pointer-events: auto;
  cursor: pointer;
}

/* ---------- masthead ---------- */
#masthead {
  position: fixed; top: 10px; left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  pointer-events: none;
  text-align: center;
  width: max-content;
  max-width: 92vw;
}
#masthead .plate {
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 4px 26px 6px;
  background: linear-gradient(180deg, rgba(231,217,184,0.0), rgba(231,217,184,0.75) 30%, rgba(231,217,184,0.75) 70%, rgba(231,217,184,0.0));
}
#masthead h1 {
  font-family: var(--serif-sc);
  font-weight: 400;
  font-size: clamp(20px, 3.2vw, 34px);
  letter-spacing: 0.06em;
  color: var(--ink);
  text-shadow: 1px 1px 0 rgba(255, 246, 220, 0.6);
}
#masthead .subtitle {
  font-style: italic;
  font-size: clamp(11px, 1.3vw, 14px);
  color: var(--ink-soft);
}

/* ---------- left margin: chapters ---------- */
#chapters {
  position: fixed; left: 14px; top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex; flex-direction: column; gap: 8px;
  width: 190px;
}
.margin-title {
  font-family: var(--serif-sc);
  font-size: 15px;
  letter-spacing: 0.18em;
  color: var(--accent);
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 3px;
  margin-bottom: 2px;
  text-align: center;
}
.chapter-btn {
  display: grid;
  grid-template-columns: 26px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--ink-faint);
  border-radius: 3px;
  padding: 6px 10px;
  font-family: var(--serif);
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.chapter-btn:hover { transform: translateX(3px); box-shadow: 3px 3px 0 rgba(61,44,26,0.25); }
.chapter-btn .num {
  grid-row: 1 / 3;
  font-style: italic;
  font-size: 18px;
  color: var(--accent);
  text-align: center;
}
.chapter-btn .name { font-size: 15px; line-height: 1.1; }
.chapter-btn .eng { font-size: 11px; font-style: italic; color: var(--ink-faint); }
.chapter-btn.active {
  border-color: var(--accent);
  border-left-width: 4px;
  background: #efe2c2;
  box-shadow: 3px 3px 0 rgba(122, 46, 29, 0.25);
}

/* ---------- right margin: annotation panel ---------- */
#annotation-panel {
  position: fixed; right: 14px; top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 250px;
  max-height: 72vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--ink-faint);
  border-radius: 3px;
  padding: 14px 16px 14px;
  box-shadow: 4px 4px 0 rgba(61,44,26,0.18);
}
#annotation-panel h2 {
  font-family: var(--serif-sc);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--accent);
  border-bottom: 1px solid var(--ink-faint);
  padding-bottom: 4px;
  margin-bottom: 6px;
}
#anno-mirror {
  font-style: italic;
  font-size: 13px;
  color: var(--ink-faint);
  transform: scaleX(-1);
  text-align: right;
  border-bottom: 1px dashed var(--ink-faint);
  padding-bottom: 5px;
  margin-bottom: 8px;
  user-select: none;
}
#anno-body { font-size: 14px; line-height: 1.45; margin-bottom: 8px; }
#anno-notes { list-style: none; }
#anno-notes li {
  font-size: 12.5px;
  font-style: italic;
  line-height: 1.35;
  color: var(--ink-soft);
  padding-left: 16px;
  position: relative;
  margin-bottom: 5px;
}
#anno-notes li::before {
  content: '\2771';        /* ❱ fleuron */
  position: absolute; left: 0;
  color: var(--gold);
}

/* ---------- bottom rail ---------- */
#rail {
  position: fixed; left: 50%; bottom: 12px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex; align-items: center; gap: 18px;
  flex-wrap: wrap; justify-content: center;
  background: var(--panel);
  border: 1px solid var(--ink-faint);
  border-radius: 4px;
  padding: 8px 16px;
  box-shadow: 4px 4px 0 rgba(61,44,26,0.18);
  max-width: 94vw;
}
.rail-group { display: flex; align-items: center; gap: 10px; }
.rail-btn {
  font-family: var(--serif);
  font-size: 14px;
  color: var(--ink);
  background: #efe2c2;
  border: 1px solid var(--ink-soft);
  border-radius: 3px;
  padding: 8px 14px;
  min-height: 40px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.rail-btn:hover { background: #f6ecd2; }
.rail-btn:active { transform: translateY(1px); }
.rail-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #f2e6c8;
  border-color: var(--accent);
}
.slider-label { font-style: italic; font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
#speed {
  width: 130px;
  accent-color: var(--accent);
  min-height: 40px;
}
.rail-hint {
  font-size: 11.5px;
  font-style: italic;
  color: var(--ink-faint);
  white-space: nowrap;
}

/* ---------- help card ---------- */
#help-card {
  position: fixed; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 9;
  width: min(430px, 92vw);
  background: #efe2c2;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 8px 8px 0 rgba(61,44,26,0.3);
  padding: 20px 24px;
}
#help-card h3 {
  font-family: var(--serif-sc);
  font-weight: 400;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.05em;
}
#help-card ul { list-style: none; margin-bottom: 14px; }
#help-card li { font-size: 14px; line-height: 1.5; padding-left: 14px; position: relative; margin-bottom: 4px; }
#help-card li::before { content: '·'; position: absolute; left: 2px; color: var(--accent); font-weight: bold; }

/* ---------- veil ---------- */
#veil {
  position: fixed; inset: 0;
  background: var(--parchment);
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.9s ease;
}
#veil.lifted { opacity: 0; pointer-events: none; }
.veil-inner { text-align: center; color: var(--ink-soft); font-style: italic; }
.veil-quill {
  width: 46px; height: 46px; margin: 0 auto 12px;
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1.4s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- flight mode ---------- */
body.in-flight #chapters,
body.in-flight #annotation-panel { opacity: 0; pointer-events: none; transition: opacity 0.8s ease; }
body.in-flight #rail-hint { visibility: hidden; }
#chapters, #annotation-panel { transition: opacity 0.8s ease; }

/* ---------- narrow viewports ---------- */
@media (max-width: 900px) {
  #chapters {
    top: auto; bottom: 158px; left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    width: auto; max-width: 96vw;
    overflow-x: auto;
    gap: 6px;
  }
  .margin-title { display: none; }
  .chapter-btn {
    grid-template-columns: 20px 1fr;
    min-width: 96px;
    padding: 5px 8px;
  }
  .chapter-btn .eng { display: none; }
  .chapter-btn .name { font-size: 13px; }
  #annotation-panel {
    top: 64px; right: 8px; left: 8px;
    transform: none;
    width: auto;
    max-height: 24vh;
    padding: 8px 12px;
  }
  #annotation-panel h2 { font-size: 16px; margin-bottom: 2px; }
  #anno-mirror { display: none; }
  #anno-body { font-size: 12.5px; margin-bottom: 2px; }
  #anno-notes li { font-size: 11.5px; margin-bottom: 2px; }
  #rail { gap: 10px; padding: 6px 10px; bottom: 8px; }
  .rail-hint { display: none; }
  #speed { width: 90px; }
  .rail-btn { padding: 8px 10px; font-size: 13px; }
}
