/* The manila folders on the desk: tabs, the folder (back panel, papers, steel clip, front cover that
   flexes as it swings on its fold), the pile underneath, and the duty tag. Swaps are driven by shell.js. */

.desk-stage {
  position: absolute;
  left: max(16px, calc((100vw - 1240px) / 2), 15vw);
  right: max(16px, calc((100vw - 1240px) / 2), 13vw);
  top: clamp(104px, 17vh, 190px);
  bottom: 2.2vh;
  display: grid;
  grid-template-rows: auto 1fr;
  perspective: 2600px;
  perspective-origin: 50% 30%;
}
.desk-stage.arriving { animation: stack-arrive 0.95s cubic-bezier(.2, .8, .25, 1) both; }
@keyframes stack-arrive {
  from { transform: translate3d(-24vw, 34vh, 0) rotate(-11deg) scale(0.78); opacity: 0; }
  55% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

/* ---------- Duty tag (who is signed in) ---------- */

.duty-tag {
  position: fixed;
  z-index: 7;
  top: clamp(10px, 2vh, 22px);
  right: clamp(12px, 2vw, 30px);
  display: grid;
  gap: 2px;
  padding: 8px 14px 9px 26px;
  max-width: 260px;
  background-color: #e3d9bf;
  background-image: var(--img-paper, none);
  background-size: 500px;
  background-blend-mode: multiply;
  clip-path: polygon(14px 0, 100% 0, 100% 100%, 14px 100%, 0 50%);
  filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.55));
  transform: rotate(2deg);
  transform-origin: 0 50%;
  cursor: pointer;
  border: 0;
  text-align: left;
  font: inherit;
  color: var(--ink);
}
.duty-tag::before { /* eyelet */
  content: '';
  position: absolute;
  left: 15px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: #2a2017;
  box-shadow: 0 0 0 2px #b48f3e;
}
.duty-tag .rank { font-family: var(--font-type); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft); }
.duty-tag .who { font-family: var(--font-hand); font-size: 1.35rem; line-height: 1; color: var(--graphite); }
.duty-menu {
  position: fixed;
  z-index: 8;
  top: calc(clamp(10px, 2vh, 22px) + 62px);
  right: clamp(12px, 2vw, 30px);
  display: grid;
  min-width: 220px;
  padding: 6px;
  gap: 2px;
}
.duty-menu button { text-align: left; border: 0; background: none; padding: 8px 10px; font-family: var(--font-type); font-size: 0.85rem; cursor: pointer; color: var(--ink); }
.duty-menu button:hover { background: rgba(0, 0, 0, 0.07); }

/* ---------- Manila card (shared by tabs, panels, cover) ---------- */

.manila {
  background-color: var(--manila);
  background-image:
    linear-gradient(180deg, rgba(255, 248, 225, 0.13), transparent 30%, transparent 72%, rgba(70, 45, 10, 0.10)),
    var(--img-manila, none);
  background-size: auto, 640px 640px;
  background-blend-mode: normal, multiply;
}

/* ---------- Tabs: the folders in the pile, each showing its tab ---------- */

.folder-tabs {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 3px;
  padding: 0 18px;
  height: 40px;
  margin-bottom: -1px;
}
.ftab {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 170px;
  height: 31px;
  padding: 0 9px;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  border-radius: 7px 7px 0 0;
  clip-path: polygon(0 100%, 9px 0, calc(100% - 9px) 0, 100% 100%);
  box-shadow: inset 0 1px 0 rgba(255, 246, 220, 0.4), inset 0 -10px 12px -8px rgba(60, 40, 10, 0.35);
  filter: brightness(0.74) saturate(0.9);
  transform: translateY(6px);
  transition: transform 0.28s cubic-bezier(.3, .8, .3, 1), filter 0.28s, height 0.28s;
}
.ftab:hover { transform: translateY(2px); filter: brightness(0.86); }
.ftab.active {
  filter: none;
  transform: none;
  height: 38px;
  z-index: 5 !important;
  box-shadow: inset 0 1px 0 rgba(255, 246, 220, 0.5);
}
.ftab .label {
  display: block;
  margin: 7px auto 0;
  padding: 2px 7px 1px;
  max-width: 100%;
  font-family: var(--font-type);
  font-size: clamp(0.6rem, 0.72vw, 0.76rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #2a241b;
  background-color: #efe7d2;
  background-image: var(--img-paper, none);
  background-size: 400px;
  background-blend-mode: multiply;
  box-shadow: 0 0 0 0.5px rgba(60, 45, 25, 0.4), 0 1px 1px rgba(0, 0, 0, 0.18);
}
.ftab.secret .label { color: var(--stamp-red); }
.ftab.secret::after {
  content: 'DO NOT OPEN';
  position: absolute;
  right: 6px;
  top: -9px;
  font-family: var(--font-type);
  font-size: 0.48rem;
  letter-spacing: 0.08em;
  color: var(--stamp-red);
  border: 1.5px solid currentColor;
  padding: 1px 3px;
  background: rgba(240, 232, 214, 0.9);
  transform: rotate(6deg);
  mix-blend-mode: multiply;
}

/* ---------- The pile + folders ---------- */

.folder-pile {
  position: relative;
  min-height: 0;
  transform-style: preserve-3d;
}
/* Two folders lying underneath the open one. */
.folder-pile::before, .folder-pile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 5px 5px 2px 2px;
  background-color: var(--manila-2);
  background-image: var(--img-manila, none);
  background-size: 640px;
  background-blend-mode: multiply;
  box-shadow: 0 0 0 1px rgba(70, 48, 15, 0.4), 0 14px 30px rgba(0, 0, 0, 0.5);
}
.folder-pile::before { transform: translate(9px, 10px) rotate(0.6deg); filter: brightness(0.62); }
.folder-pile::after { transform: translate(-7px, 18px) rotate(-0.7deg); filter: brightness(0.48); }

.folder {
  position: absolute;
  inset: 0;
  z-index: 2;
  transform-style: preserve-3d;
  will-change: transform;
}
.folder.under { z-index: 1; }

.folder-back {
  position: absolute;
  inset: 0;
  border-radius: 6px 6px 3px 3px;
  padding: clamp(12px, 1.5vw, 22px) clamp(12px, 1.6vw, 24px) 0;
  display: grid;
  box-shadow:
    0 0 0 1px rgba(78, 54, 18, 0.42),
    inset 0 1px 0 rgba(255, 246, 222, 0.45),
    inset 0 0 26px rgba(95, 62, 18, 0.2),
    0 2px 2px rgba(0, 0, 0, 0.3),
    0 18px 34px rgba(0, 0, 0, 0.42),
    0 40px 80px rgba(0, 0, 0, 0.3);
}
/* Score lines parallel to the fold at the bottom. */
.folder-back::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  height: 12px;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(80, 55, 18, 0.28) 0 1px, rgba(255, 244, 215, 0.25) 1px 2px, transparent 2px) 0 0 / 100% 6px repeat-y;
  opacity: 0.8;
}

/* The papers: two sheets underneath, the top one holds the content. */
.paper-stack { position: relative; min-height: 0; display: grid; }
.paper-stack::before, .paper-stack::after {
  content: '';
  position: absolute;
  inset: 0;
  background-color: var(--paper-2);
  background-image: var(--img-paper, none);
  background-size: 700px;
  background-blend-mode: multiply;
  box-shadow: 0 0 0 0.5px rgba(70, 55, 35, 0.35), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.paper-stack::before { transform: translate(5px, 4px) rotate(0.45deg); }
.paper-stack::after { transform: translate(-3px, 7px) rotate(-0.35deg); filter: brightness(0.96); }
.sheet {
  position: relative;
  z-index: 1;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 2.4vw, 38px) clamp(18px, 3vw, 48px) 70px;
  border-radius: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(60, 45, 25, 0.5) transparent;
}
.sheet::-webkit-scrollbar { width: 9px; }
.sheet::-webkit-scrollbar-thumb { background: rgba(60, 45, 25, 0.45); border-radius: 9px; }

/* Steel gem clip over the papers. */
.paperclip {
  position: absolute;
  z-index: 4;
  top: -12px;
  left: clamp(34px, 5vw, 64px);
  width: 26px;
  height: 78px;
  overflow: visible;
  pointer-events: none;
  filter: drop-shadow(1.5px 3px 1.5px rgba(0, 0, 0, 0.45));
}

/* The cover's shadow falling across the papers as it closes. */
.folder-shade {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(10, 6, 2, 0.7), rgba(10, 6, 2, 0.25) 60%, rgba(10, 6, 2, 0.05));
  opacity: 0;
  border-radius: 6px 6px 3px 3px;
}

/* ---------- Front cover: two hinged panels so the card flexes as it swings ---------- */

.folder-cover {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(100% - 10px);
  z-index: 5;
  transform-origin: 50% 100%;
  transform: rotateX(-180deg);
  transform-style: preserve-3d;
  visibility: hidden;
  pointer-events: none;
}
.folder.shut .folder-cover, .folder.moving .folder-cover { visibility: visible; }
.folder.shut .folder-cover { transform: none; }
.cv-a, .cv-b { position: absolute; left: 0; right: 0; transform-style: preserve-3d; }
.cv-a { bottom: 0; height: 56%; }
.cv-b { bottom: 100%; height: calc(44 / 56 * 100%); transform-origin: 50% 100%; }
.cv-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.cv-face.in { transform: rotateX(180deg); filter: brightness(0.86); }
.cv-a > .cv-face { border-radius: 0 0 3px 3px; }
.cv-b > .cv-face { border-radius: 6px 6px 0 0; }
.cv-face.out { box-shadow: inset 0 0 0 1px rgba(78, 54, 18, 0.35), inset 0 1px 0 rgba(255, 246, 222, 0.4); }
.cv-a > .cv-face.out::before { /* score lines on the cover too */
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  height: 12px;
  background: linear-gradient(180deg, rgba(80, 55, 18, 0.28) 0 1px, rgba(255, 244, 215, 0.25) 1px 2px, transparent 2px) 0 0 / 100% 6px repeat-y;
}
/* Light on the panels changes as they turn (opacity driven by shell.js). */
.cv-light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.2));
  opacity: 0;
}
.cover-label {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%) rotate(-0.8deg);
  display: grid;
  gap: 6px;
  justify-items: center;
  padding: 14px 30px 12px;
  min-width: 46%;
  color: #2a241b;
  background-color: #efe7d2;
  background-image: var(--img-paper, none);
  background-size: 500px;
  background-blend-mode: multiply;
  box-shadow: 0 0 0 0.5px rgba(60, 45, 25, 0.45), 0 1px 2px rgba(0, 0, 0, 0.25);
}
.cover-label .typed { font-size: clamp(1rem, 2vw, 1.6rem); letter-spacing: 0.12em; text-transform: uppercase; }
.cover-label .no { font-family: var(--font-type); font-size: 0.72rem; letter-spacing: 0.2em; color: var(--ink-soft); }
.cover-stamp { position: absolute; right: 11%; bottom: 30%; font-size: clamp(1rem, 2.3vw, 1.9rem); }
.cover-ring { /* a coffee ring someone left on it */
  position: absolute;
  left: 9%;
  bottom: 18%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 7px solid rgba(110, 70, 30, 0.13);
  box-shadow: inset 0 0 14px rgba(110, 70, 30, 0.12);
  transform: scaleY(0.94) rotate(-8deg);
  mix-blend-mode: multiply;
}

/* ---------- Content on the sheet ---------- */

.sheet-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px 20px;
  border-bottom: 2px solid rgba(30, 25, 20, 0.6);
  padding-bottom: 10px;
  margin-bottom: 22px;
}
.sheet-head h1 {
  margin: 0;
  font-family: var(--font-type);
  font-weight: 400;
  font-size: clamp(1.3rem, 2.4vw, 2.1rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sheet-head .sub { font-family: var(--font-type); font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); }
.sheet-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.placeholder-memo { max-width: 620px; margin: 40px auto; text-align: center; }
.placeholder-memo .hand { font-size: 1.8rem; }

@media (max-width: 860px) {
  .desk-stage { left: 6px; right: 6px; top: 64px; bottom: 76px; }
  .folder-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; padding: 0 6px; }
  .ftab { flex: 0 0 auto; max-width: none; }
  .duty-tag { max-width: 190px; }
  #props { z-index: 5; pointer-events: none; }
}
@media (prefers-reduced-motion: reduce) {
  .desk-stage.arriving { animation: none; }
}
/* The shell focuses the sheet for keyboard users; no ring after a mouse click. */
.sheet:focus-visible { outline: none; }
