/* HAVEN DESK — first loop, thread line, staged desktop.
   Sits on top of veil.css and reuses its palette tokens. */

/* ---------- staged desktop: a desk that has not woken up yet ---------- */

#desktop.veil-first-boot .icon {
  opacity: 0.18;
  filter: grayscale(1) brightness(0.7);
  pointer-events: none;
  transition: opacity 220ms linear, filter 220ms linear;
}
#desktop.veil-first-boot .icon[data-id="calendar"],
#desktop.veil-first-boot .icon[data-id="readme"],
#desktop.veil-first-boot .icon[data-id="drawer"] {
  opacity: 1;
  filter: none;
  pointer-events: auto;
  animation: veil-icon-breathe 3.4s ease-in-out infinite;
}
#desktop.veil-first-reveal .icon {
  animation: veil-icon-wake 700ms ease-out both;
}
#desktop.veil-first-reveal .icon:nth-child(2n) { animation-delay: 90ms; }
#desktop.veil-first-reveal .icon:nth-child(3n) { animation-delay: 180ms; }
#desktop.veil-first-reveal .icon:nth-child(5n) { animation-delay: 270ms; }

@keyframes veil-icon-breathe {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-1px); }
}
@keyframes veil-icon-wake {
  from { opacity: 0.15; filter: grayscale(1) brightness(0.6); transform: scale(0.96); }
  to   { opacity: 1; filter: none; transform: scale(1); }
}

/* ---------- the note ---------- */

.veil-first {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(8, 24, 20, 0.72), rgba(2, 7, 6, 0.94));
  backdrop-filter: blur(1.5px);
  animation: veil-first-in 320ms ease-out both;
}
@keyframes veil-first-in { from { opacity: 0; } to { opacity: 1; } }

.veil-first-sheet {
  position: relative;
  width: min(720px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 26px 28px 22px;
  color: #10140f;
  background:
    linear-gradient(180deg, #efe8d4, #e2d9c1 62%, #d9cfb4);
  border: 1px solid #b9ab8b;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
  font-family: "Courier New", Courier, monospace;
  transform: rotate(-0.35deg);
}
.veil-first-sheet::before,
.veil-first-sheet::after {
  content: "";
  position: absolute;
  width: 104px;
  height: 26px;
  background: rgba(233, 226, 207, 0.55);
  border: 1px solid rgba(150, 140, 115, 0.55);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.veil-first-sheet::before { top: -12px; left: 26px; transform: rotate(-3deg); }
.veil-first-sheet::after { top: -12px; right: 26px; transform: rotate(2.4deg); }

.veil-first-sheet.is-shake { animation: veil-shake 320ms ease-in-out; }
@keyframes veil-shake {
  0%, 100% { transform: rotate(-0.35deg) translateX(0); }
  25% { transform: rotate(-0.35deg) translateX(-6px); }
  50% { transform: rotate(-0.35deg) translateX(5px); }
  75% { transform: rotate(-0.35deg) translateX(-3px); }
}

.veil-first-head {
  margin: 0 0 14px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6c5f45;
  border-bottom: 1px dashed #b3a586;
  padding-bottom: 8px;
}

.veil-first-paper {
  margin: 0 0 18px;
  min-height: 132px;
  white-space: pre-wrap;
  font-family: "Courier New", Courier, monospace;
  font-size: 14px;
  line-height: 1.62;
  color: #1d2418;
}
.veil-first-paper::after {
  content: "▌";
  margin-left: 1px;
  color: #1d2418;
  animation: veil-caret 1s steps(1) infinite;
}
.veil-first-paper.is-done::after { content: ""; }
@keyframes veil-caret { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.veil-first-gate { display: grid; gap: 8px; }
.veil-first-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  color: #6c5f45;
}
.veil-first-input {
  width: 100%;
  padding: 10px 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 16px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #12180f;
  background: #f7f2e2;
  border: 1px solid #a2946f;
  box-shadow: inset 1px 1px 0 rgba(0, 0, 0, 0.12);
}
.veil-first-input:focus { outline: 2px solid #7c6a3f; outline-offset: 1px; }
.veil-first-msg {
  min-height: 18px;
  margin: 0;
  font-size: 12px;
  color: #7a3a26;
}
.veil-first-foot {
  margin: 16px 0 0;
  font-size: 10px;
  color: #746a52;
  font-style: italic;
}
.veil-first .veil-primary,
.veil-first .raised {
  font-family: Tahoma, "MS Sans Serif", Verdana, sans-serif;
  font-size: 11px;
  padding: 8px 14px;
  cursor: pointer;
  border: 1px solid #7d6f4e;
  background: #ded3b6;
  color: #1a1d14;
  box-shadow: 1px 1px 0 #8b7d5c;
}
.veil-first .veil-primary {
  background: #2c3b31;
  color: #f2ecd9;
  border-color: #16211a;
  box-shadow: 1px 1px 0 #0d1410;
}
.veil-first .veil-primary:hover { background: #3a4d40; }

.veil-first-done h2 {
  margin: 0 0 10px;
  font-family: Tahoma, "MS Sans Serif", Verdana, sans-serif;
  font-size: 20px;
  color: #1b2418;
}
.veil-first-done p { margin: 0 0 10px; font-size: 13px; line-height: 1.55; }
.veil-first-small { font-size: 11px !important; color: #6c6349; }
.veil-first-done .veil-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* ---------- Field Journal (replaces the old THREAD strip) ---------- */

.veil-journal, .veil-journal-slot {
  position: relative;
  z-index: 4;
  max-width: 760px;
  margin: 8px 12px 12px;
}
.veil-journal {
  display: flex;
  background: #d8c9a4;
  border: 2px solid #6b542e;
  box-shadow: 4px 4px 0 #1a1408, inset 0 0 0 1px #f0e6c8;
  font-family: Georgia, "Times New Roman", serif;
  color: #1b1810;
}
.veil-journal-bind {
  width: 14px;
  flex: none;
  background:
    repeating-linear-gradient(180deg, #3a2a12 0 8px, #2a1c0c 8px 16px);
  border-right: 2px solid #5a4320;
}
.veil-journal-page {
  flex: 1;
  padding: 10px 14px 12px;
  background:
    repeating-linear-gradient(180deg, rgba(90, 70, 30, 0.08) 0 1px, transparent 1px 22px),
    #efe4c4;
}
.veil-journal-kicker {
  margin: 0;
  font: 700 9px Tahoma, "MS Sans Serif", Verdana, sans-serif;
  letter-spacing: 0.14em;
  color: #6a4a18;
}
.veil-journal-chapter {
  margin: 2px 0 6px;
  font: 700 10px Tahoma, "MS Sans Serif", Verdana, sans-serif;
  letter-spacing: 0.08em;
  color: #0d4a44;
}
.veil-journal-page h2 {
  margin: 0 0 6px;
  font: italic 18px Georgia, serif;
  color: #1a1408;
}
.veil-journal-body { margin: 0 0 6px; font-size: 13px; line-height: 1.45; }
.veil-journal-hint { margin: 0 0 10px; font-size: 11px; color: #5a4a28; }
.veil-journal-recover { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.veil-journal-msg { margin: 4px 0 0; font-size: 11px; color: #6a3a12; }
#veil-thread { display: none !important; }

.veil-chapter { margin: 10px 0 16px; max-width: 760px; }
.veil-chapter b {
  display: block;
  margin-bottom: 6px;
  color: #e0b35a;
  font: 700 9px "Courier New", Courier, monospace;
  letter-spacing: 0.1em;
}
.veil-level, .veil-level-index .veil-level {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
  text-align: left;
  margin: 0 0 3px;
  padding: 6px 8px;
  background: #0d1b16;
  border: 1px solid #355246;
  color: #dce9e2;
}
.veil-level strong { flex: 1; font-size: 12px; }
.veil-level span { color: #e0b35a; font: 9px "Courier New", Courier, monospace; min-width: 108px; }
.veil-level small { color: #839b8d; font-size: 9px; }
.veil-level.is-open { border-color: #72e0d1; }
.veil-level.is-unsealed { border-color: #9fe58c; background: #102018; }
.veil-level.is-sealed { opacity: 0.72; }
.veil-level-index { margin-top: 12px; max-height: 280px; overflow: auto; border: 1px solid #2e463a; padding: 8px; background: #07100c; }
.veil-level-index b { display: block; color: #e0b35a; font: 700 9px "Courier New", Courier, monospace; letter-spacing: 0.1em; margin-bottom: 6px; }

/* the next room on the map */

.veil-node.is-next {
  border-color: var(--veil-cyan, #72e0d1);
  box-shadow: 0 0 0 1px rgba(114, 224, 209, 0.5), 0 0 18px rgba(114, 224, 209, 0.22);
  animation: veil-next-pulse 2.2s ease-in-out infinite;
}
@keyframes veil-next-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(114, 224, 209, 0.45), 0 0 12px rgba(114, 224, 209, 0.16); }
  50% { box-shadow: 0 0 0 2px rgba(114, 224, 209, 0.85), 0 0 26px rgba(114, 224, 209, 0.34); }
}

@media (max-width: 640px) {
  .veil-first-sheet { padding: 20px 18px 18px; transform: none; }
  .veil-first-paper { font-size: 13px; min-height: 110px; }
  .veil-journal { margin: 8px; }
}

/* ---------- the boot screen: a machine that has been on for years ---------- */

#boot.veil-boot p { animation: veil-boot-line 360ms ease-out both; }
#boot.veil-boot p:nth-child(1) { animation-delay: 0ms; }
#boot.veil-boot p:nth-child(2) { animation-delay: 140ms; }
#boot.veil-boot p:nth-child(3) { animation-delay: 300ms; }
#boot.veil-boot p:nth-child(4) { animation-delay: 460ms; }
#boot.veil-boot p.hint { animation-delay: 700ms; }
#boot.veil-boot p.hint::after {
  content: "_";
  margin-left: 4px;
  animation: veil-caret 1.1s steps(1) infinite;
}
@keyframes veil-boot-line {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- the memorial card ---------- */

.veil-memorial {
  margin: 12px 0 14px;
  padding: 0;
  background: #0d1a16;
  border: 1px solid var(--veil-line, #2d4a40);
}
.veil-memorial img {
  display: block;
  width: 100%;
  height: auto;
  filter: saturate(0.92) contrast(1.02);
}
.veil-memorial figcaption {
  padding: 10px 12px;
  font-family: "Courier New", Courier, monospace;
  font-size: 11px;
  line-height: 1.5;
  color: var(--veil-amber, #e0b35a);
  border-top: 1px solid var(--veil-line, #2d4a40);
}

/* the completion card gets a warmer sheet */

.veil-final .veil-first-sheet {
  background: linear-gradient(180deg, #f0e8d2, #e5dabd 60%, #dccfb0);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.65), inset 0 0 0 1px rgba(224, 179, 90, 0.35);
}

/* map filter button */

.veil-filter {
  margin-left: auto;
  font-family: Tahoma, "MS Sans Serif", Verdana, sans-serif;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 3px 8px;
}

/* ---------- respect reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .veil-first,
  .veil-first-sheet,
  .veil-first-sheet.is-shake,
  #boot.veil-boot p,
  .veil-first-paper::after,
  .veil-node.is-next,
  #desktop.veil-first-boot .icon,
  #desktop.veil-first-reveal .icon {
    animation: none !important;
    transition: none !important;
  }
  .veil-first-paper::after { content: ""; }
}
