/* The folder, the pages inside it, and the controls for reading them. Everything in the folder is drawn at a fixed
   size (the folder body is 620 x 900, pages 560 x 820) and app.js scales the whole thing to fit the window, so a page
   holds exactly the same text on every screen. Editing has its own stylesheet, editor.css. */

:root {
  --paper: #ece9df;
  --ink: #1b1b1b;
  --red: #c8232a;
  --move: .95s;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: #000; color: #fff; overflow: hidden; overscroll-behavior: none; }
body { font: 15px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
.nojs { position: fixed; inset: auto 0 12% 0; margin: 0; text-align: center; color: #bbb; z-index: 9; }

/* ---------- the view ---------- */
#stage {
  position: fixed; inset: 0; overflow: hidden; touch-action: none;
  background: radial-gradient(ellipse 58% 52% at 50% 46%, rgba(255, 236, 200, .05), rgba(0, 0, 0, 0) 72%) #000;
}
#cam { position: absolute; inset: 0; transform-origin: 50% 50%; }
#rig { position: absolute; left: 50%; top: 50%; width: 0; height: 0; perspective: 2600px; transition: transform var(--move) cubic-bezier(.3, .6, .2, 1); }
#folder {
  position: absolute; left: -338px; top: -450px; width: 676px; height: 900px;
  transform-style: preserve-3d; transition: transform var(--move) cubic-bezier(.3, .6, .2, 1);
  -webkit-user-select: none; user-select: none;
}
#folder.open { transform: translateX(310px); }
#folder.showing { -webkit-user-select: text; user-select: text; }

/* ---------- the folder ---------- */
.panel.back { position: absolute; left: 0; top: 0; width: 676px; height: 900px; }
.cover {
  position: absolute; left: 0; top: 0; width: 620px; height: 900px;
  transform-origin: 0 50%; transform-style: preserve-3d; transition: transform var(--move) cubic-bezier(.42, .08, .2, 1);
}
#folder.open .cover { transform: rotateY(-180deg); }
.face { position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.face.in { transform: rotateY(180deg); }
.face.out { cursor: pointer; outline: none; }
.face.out:focus-visible .edge path { stroke: #7fb2ff; stroke-width: 5; }

.shape {
  position: absolute; inset: 0;
  background: var(--grain, none), radial-gradient(130% 100% at 28% 16%, #c4a87f 0%, #b59a72 42%, #a2885e 100%);
}
.back .shape { clip-path: path("M10 0H531Q541 0 541 10V28Q541 38 551 38H660Q676 38 676 54V290Q676 306 660 306H636Q620 306 620 322V890Q620 900 610 900H10Q0 900 0 890V10Q0 0 10 0Z"); }
.face.out .shape { clip-path: path("M10 0H531Q541 0 541 10V28Q541 38 551 38H610Q620 38 620 48V890Q620 900 610 900H10Q0 900 0 890V10Q0 0 10 0Z"); }
.face.in .shape {
  clip-path: path("M610 0H89Q79 0 79 10V28Q79 38 69 38H10Q0 38 0 48V890Q0 900 10 900H610Q620 900 620 890V10Q620 0 610 0Z");
  background: var(--grain, none), radial-gradient(130% 100% at 72% 16%, #bfa37a 0%, #b1966e 42%, #9f855c 100%);
}
.face.out:hover .shape { filter: brightness(1.045); }
.edge { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.edge path { fill: none; stroke: rgba(58, 38, 12, .55); stroke-width: 2; }

/* the crease down the middle of the open folder */
.panel.back::after, .face.in::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 46px; pointer-events: none; z-index: 2;
}
.panel.back::after { left: 0; background: linear-gradient(90deg, rgba(40, 24, 6, .44), rgba(40, 24, 6, 0)); }
.face.in::after { right: 0; background: linear-gradient(270deg, rgba(40, 24, 6, .44), rgba(40, 24, 6, 0)); }

/* the word on the front */
.stamp {
  position: absolute; left: 34px; top: 262px; min-width: 40px; min-height: 62px; white-space: pre;
  font: 900 62px/1 "Arial Black", "Segoe UI Black", "Helvetica Neue", Arial, sans-serif; letter-spacing: 1px;
  color: var(--red); opacity: .93; text-shadow: 0 0 1.5px rgba(150, 10, 16, .55);
}

/* the paperclip over the top edge, next to the spine */
.clip { position: absolute; top: -30px; width: 60px; height: 124px; overflow: visible; pointer-events: none; z-index: 3; }
.face.out .clip { left: 20px; transform: rotate(-3deg); }
.face.in .clip { right: 20px; transform: rotate(3deg); }
.clip .wire { fill: none; stroke: #1a1b1e; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.clip .shine { fill: none; stroke: rgba(255, 255, 255, .3); stroke-width: 1.3; stroke-linecap: round; }

/* the white label on the tab */
.tab-label {
  position: absolute; left: 638px; top: 62px; width: 20px; height: 128px; overflow: hidden;
  background: #f3f1ea; border-radius: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  writing-mode: vertical-rl; white-space: pre; text-align: center;
  font: 700 11px/20px "Courier New", Courier, monospace; color: #222;
}

/* ---------- the pages ---------- */
.sheet, .under { position: absolute; top: 50px; width: 560px; height: 820px; }
.back .sheet, .back .under { left: 26px; }
.face.in .sheet, .face.in .under { left: 34px; }
.under { background: #dbd7ca; box-shadow: 0 2px 4px rgba(30, 18, 4, .4); transform: rotate(.7deg); }
.face.in .under { transform: rotate(-.6deg); }
.sheet {
  background: var(--paper); color: var(--ink);
  box-shadow: 0 0 0 1px rgba(60, 50, 30, .16), 0 2px 3px rgba(30, 18, 4, .35), 0 10px 18px rgba(40, 25, 5, .2);
  font: 15px/21px "Courier New", Courier, "Liberation Mono", "Nimbus Mono PS", "Cutive Mono", monospace;
  text-shadow: 0 0 .35px rgba(0, 0, 0, .5);
}
.sheet::before { content: ''; position: absolute; inset: 0; background-image: var(--grain, none); opacity: .42; pointer-events: none; }
.sheet .body { position: absolute; inset: 0; padding: 36px 42px 30px; overflow: hidden; }
.sheet ::selection { background: rgba(40, 110, 255, .3); }
#folder:not(.showing) .sheet, #folder:not(.showing) .under { visibility: hidden; }
.sheet .body { transition: opacity .15s ease; }
#folder.swapping .sheet .body { opacity: 0; }                  /* turning to another pair of pages */
/* a first visit: nothing is written on the folder until the cloud has answered */
.stamp, .tab-label { transition: opacity .3s ease; }
#folder.pending .stamp, #folder.pending .tab-label, #folder.pending .sheet .body { opacity: 0; }
.pageno { position: absolute; left: 0; right: 0; bottom: 9px; text-align: center; font-size: 11px; line-height: 14px; color: #5a5a5a; }

/* a letterhead */
.t-head { display: flex; align-items: center; gap: 13px; margin: 0 0 14px; }
.t-head .logo { width: 62px; height: 62px; flex: none; display: grid; place-items: center; }
.t-head .logo img { max-width: 100%; max-height: 100%; display: block; }
.t-head .logo img:not([src]) { visibility: hidden; }
.emblem { width: 100%; height: 100%; display: block; }
.emblem .e-line { fill: none; stroke: #161616; stroke-width: 3.5; stroke-linejoin: round; }
.emblem .e-fill { fill: #161616; }
.emblem .e-cut { fill: none; stroke: var(--paper); stroke-width: 2.6; stroke-linecap: round; }
.t-head .titles { min-width: 0; flex: 1; text-shadow: none; }
.t-head .title {
  font: 900 40px/1 "Arial Black", "Segoe UI Black", "Helvetica Neue", Arial, sans-serif; letter-spacing: 1px;
  text-transform: uppercase; white-space: pre; min-height: 40px;
}
.t-head .sub {
  font: 700 12px/1.2 Arial, "Helvetica Neue", sans-serif; letter-spacing: .42em; text-transform: uppercase;
  margin-top: 6px; white-space: pre; min-height: 14px;
}

/* photographs */
.t-imgs { display: flex; gap: 10px; margin: 0 0 12px; }
.t-imgs figure { margin: 0; flex: 1 1 0; min-width: 0; position: relative; }
.t-imgs.n2 figure:first-child { flex: 1.8 1 0; }
.ph { position: relative; height: 150px; background: #0c1016; border: 1px solid #0a0a0a; overflow: hidden; }
.size-s .ph { height: 104px; }
.size-l .ph { height: 236px; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph img:not([src]) { visibility: hidden; }
.ph.empty { background: repeating-linear-gradient(135deg, #111720 0 10px, #0c1016 10px 20px); }
.ph .none {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 6px; text-align: center;
  font: 700 10px/1.3 "Courier New", Courier, monospace; letter-spacing: .18em; color: #66717f; text-shadow: none;
}
.ph.loading::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, .07) 50%, rgba(255, 255, 255, 0) 70%);
  background-size: 200% 100%; animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.t-imgs figcaption { font-size: 11.5px; line-height: 15px; margin-top: 4px; color: #2c2c2c; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 15px; }

/* headings and typed text */
.t-h h2 {
  font: inherit; font-weight: 700; font-size: 19px; line-height: 24px; margin: 0 0 9px; min-height: 24px;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.t-p p { margin: 0 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 21px; }
.m-h { background: #f5d033; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.m-b { font-weight: 700; }
.m-u { text-decoration: underline; text-underline-offset: 2px; }
.m-x { background: #131313; color: #131313; text-shadow: none; -webkit-box-decoration-break: clone; box-decoration-break: clone; }

/* the round stamp in the bottom corner of a page */
.t-seal {
  position: absolute; right: 38px; bottom: 30px; width: 122px; height: 122px; padding: 12px; border-radius: 50%;
  border: 3px solid rgba(38, 38, 44, .6); color: rgba(38, 38, 44, .74); text-shadow: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  transform: rotate(-13deg); font-family: Arial, "Helvetica Neue", sans-serif;
}
.t-seal::before { content: ''; position: absolute; inset: 5px; border-radius: 50%; border: 1.5px solid rgba(38, 38, 44, .5); pointer-events: none; }
.t-seal .top, .t-seal .bottom { font-weight: 700; font-size: 8px; line-height: 1.25; letter-spacing: .13em; text-transform: uppercase; max-width: 86px; white-space: pre-wrap; overflow-wrap: anywhere; }
.t-seal .main {
  font: 900 20px/1.05 "Arial Black", "Segoe UI Black", Arial, sans-serif; letter-spacing: .03em; text-transform: uppercase;
  margin: 4px 0; max-width: 98px; white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- opening and closing ---------- */
/* While the cover swings it is a real 3D turn. Once it has landed the folder is laid out flat (same picture, no 3D),
   which keeps the text sharp however far the reader zooms in. */
#folder.turning .face { animation: turn-shade var(--move) ease both; }
@keyframes turn-shade { 50% { filter: brightness(.7); } }
#rig.flat { perspective: none; }
#folder.flat { transform-style: flat; }
#folder.flat .cover { transform: translateX(-100%); transform-style: flat; transition: none; }
#folder.flat .face.in { transform: none; -webkit-backface-visibility: visible; backface-visibility: visible; }
#folder.flat .face.out { display: none; }
.notrans, .notrans * { transition: none !important; animation: none !important; }

/* ---------- controls, bottom right ---------- */
#hud {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px; z-index: 5;
  -webkit-user-select: none; user-select: none;
}
#hud .row {
  all: unset; position: relative; display: flex; align-items: center; gap: 12px; cursor: pointer; color: #fff;
  font: 400 19px/1 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  /* a dark edge round the letters, so they read over the black background and over a page alike */
  -webkit-text-stroke: 3.5px rgba(0, 0, 0, .72); paint-order: stroke fill;
  text-shadow: 0 1px 3px #000, 0 0 8px #000, 0 0 16px rgba(0, 0, 0, .9);
}
/* no room beside the page: just the icons, with each name showing while its icon is pointed at */
#hud.compact .row span { position: absolute; right: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s ease; }
#hud.compact .row { gap: 0; }
#hud.compact .row:hover span, #hud.compact .row:focus-visible span { opacity: 1; }
#hud .ic {
  width: 38px; height: 38px; border-radius: 50%; background: rgba(28, 30, 34, .94); display: grid; place-items: center;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .14), 0 2px 6px rgba(0, 0, 0, .6); font-style: normal; text-shadow: none;
}
#hud .ic svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#hud .ic svg .fill { fill: #fff; stroke: none; }
#hud .ic.key { border-radius: 10px; font: 700 18px/1 "Segoe UI", system-ui, sans-serif; }
#hud .row:hover .ic { background: #3a3d44; }
#hud .row:focus-visible .ic { box-shadow: 0 0 0 2.5px #7fb2ff; }
#hud .row:active .ic { transform: scale(.94); }

.recaptcha-note { display: none; position: fixed; left: 12px; bottom: 8px; margin: 0; max-width: 44vw; font-size: 10px; line-height: 1.35; color: #4e4e4e; z-index: 4; }
.has-recaptcha .recaptcha-note { display: block; }
.recaptcha-note a { color: #6a6a6a; }
.grecaptcha-badge { visibility: hidden !important; }
/* (helper frames that sign-in adds to the page are never meant to be seen) */
body > iframe { position: absolute !important; top: -100px !important; width: 1px !important; height: 1px !important; border: 0 !important; opacity: 0 !important; }

/* the unmarked corner */
#hot {
  position: fixed; top: 0; right: 0; width: 72px; height: 72px; z-index: 8; background: transparent; cursor: default;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
body.editing #hot { display: none; }

/* ---------- messages and dialogs ---------- */
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 30; pointer-events: none; width: min(560px, calc(100vw - 24px)); }
.toast {
  background: #1b1d22; color: #f1f1f3; border: 1px solid #343842; border-radius: 10px; padding: 10px 14px; font-size: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .6); animation: toast-in .18s ease both; max-width: 100%;
}
.toast.bad { border-color: #7a2a2f; background: #2a1517; }
.toast.good { border-color: #2c6a3f; background: #14241a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog.dlg {
  border: 1px solid #2c2f36; background: #15171b; color: #e8e8ea; border-radius: 12px; padding: 22px;
  width: min(390px, calc(100vw - 28px)); max-height: calc(100vh - 28px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .7);
}
dialog.dlg::backdrop { background: rgba(0, 0, 0, .74); }
.dlg h2 { margin: 0 0 4px; font-size: 19px; }
.dlg .sub { margin: 0 0 14px; color: #9a9da6; font-size: 13.5px; }
.dlg label { display: block; font-size: 12.5px; color: #b9bcc4; margin: 12px 0 5px; }
.dlg input[type=text], .dlg input[type=password] {
  width: 100%; background: #0d0e11; border: 1px solid #30333b; color: #fff; border-radius: 8px; padding: 10px 12px; font: inherit;
}
.dlg input:focus { outline: 2px solid #4c8dff; outline-offset: 0; border-color: transparent; }
.dlg .err { min-height: 18px; margin: 10px 0 0; color: #ff8080; font-size: 13px; }
.dlg .btns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.dlg .fine { margin: 14px 0 0; font-size: 11.5px; color: #74777f; }
.btn {
  -webkit-appearance: none; appearance: none; border: 1px solid #353944; background: #22252c; color: #eee; border-radius: 8px;
  padding: 9px 14px; font: 600 14px/1.1 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #2b2f38; }
.btn:focus-visible { outline: 2px solid #7fb2ff; outline-offset: 1px; }
.btn.primary { background: #3b76f0; border-color: #3b76f0; color: #fff; }
.btn.primary:hover { background: #4a84ff; }
.btn.danger { background: #5a1f24; border-color: #7a2a2f; }
.btn.danger:hover { background: #6c262c; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.grow { flex: 1 1 auto; }

/* ---------- small screens, and people who asked for less motion ---------- */
@media (max-width: 720px) {
  #hud { gap: 8px; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); }
  #hud .row { font-size: 15px; gap: 9px; }
  #hud .ic { width: 32px; height: 32px; }
  #hud .ic svg { width: 19px; height: 19px; }
  #hud .ic.key { font-size: 15px; border-radius: 8px; }
  .recaptcha-note { max-width: 40vw; font-size: 9px; }
}
@media (prefers-reduced-motion: reduce) {
  :root { --move: .01s; }
  .ph.loading::after { animation: none; }
}
