/* membrane.css — period stylesheet for Marcy's page plus the decay-stage
 * un-styling. The 1999 page is mostly inline attributes; this file owns the
 * stragglers and the six states the story moves through. */

body {
  font-family: "Times New Roman", Times, serif;
  background-color: #000040;
  color: #000000;
  margin: 0;
  padding: 0;
}
.drw { display: inline; }

/* The one authored moment: the page's own voice takes the new words like ink
 * settling into paper. 460ms, one element, one clue that clicking mattered. */
@keyframes inkset {
  from { opacity: .18; filter: blur(1.1px); }
  to   { opacity: 1;   filter: blur(0); }
}
#intro-1.inkset { animation: inkset 720ms cubic-bezier(.16, 1, .3, 1) both; }
@media (prefers-reduced-motion: reduce) {
  @keyframes inkset { from { opacity: .55; } to { opacity: 1; } }
  #intro-1.inkset { animation-duration: 120ms; }
}

/* 1 - drift: a tiny mark that the page has been edited */
body.decay-1 { background-color: #0a0a3a; }

/* 2 - dim: background tile changes via JS; animated GIFs freeze via JS */

/* 3 - bleed: colour starts to drain */
body.decay-3 { background-color: #ffffff; }

/* 4 - raw: the stylesheet starts to come apart */
body.decay-4 {
  background-color: #ffffff !important;
  background-image: none !important;
  color: #000000 !important;
  font-family: "Times New Roman", Times, serif !important;
}
body.decay-4 #pageTable,
body.decay-4 #pageTable table,
body.decay-4 #pageTable td {
  width: auto !important;
  border: 0 !important;
  background: transparent !important;
  padding: 2px !important;
}
body.decay-4 #pageTable td[bgcolor] { background: transparent !important; }
body.decay-4 .drw { display: block; }
body.decay-4 marquee { display: none; }
body.decay-4 a { color: #0000ff !important; text-decoration: underline !important; }
body.decay-4 #restoreLink,
body.decay-4 #unlockForm { display: block !important; }

/* 5 - stripped: nothing left but the message */
body.decay-5 {
  background-color: #ffffff !important;
  background-image: none !important;
  color: #000000 !important;
  font-family: "Times New Roman", Times, serif !important;
}
body.decay-5 > table,
body.decay-5 > marquee { display: none !important; }
body.decay-5 #pageTable { display: none !important; }
body.decay-5 .drw { display: none !important; }
body.decay-5 #rawLayer {
  display: block !important;
  max-width: 660px;
  margin: 8vh auto 12vh;
  padding: 0 24px;
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
  line-height: 1.85;
  color: #000000;
  white-space: normal;
}
body.decay-5 #rawLayer br { display: block; content: ""; margin-top: 12px; }
body.decay-5 #rawLayer br + br { margin-top: 0; }
body.decay-5 #restoreLink,
body.decay-5 #unlockForm { display: block !important; }
body.decay-5 .toast { display: none !important; }

/* My Pix stays fixed-width on desktop and shrinks with the page on a phone */
#pageTable table.album { width: 100%; max-width: 360px; table-layout: fixed; }
#pageTable table.album img { border: 1px solid #333; }
@media (max-width: 820px) {
  #pageTable table.album td {
    display: inline-block; width: 48% !important; box-sizing: border-box;
  }
  #pageTable table.album img { width: 100%; height: auto; }
}

/* long guestbook notes and long answers stay inside the page */
#guestList, #quizResult { overflow-wrap: anywhere; }

/* the fixed-width 1999 layout has to fit a phone without horizontal scroll */
@media (max-width: 820px) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body > table,
  body #pageTable { width: 100% !important; max-width: 760px !important; }
  body #pageTable > tbody > tr > td { display: block; width: 100% !important; box-sizing: border-box; }
  #pageTable form table,
  #pageTable form table tbody,
  #pageTable form table tr,
  #pageTable form table td { display: block; width: 100% !important; }
  input, textarea { max-width: 100%; }
  img { max-width: 100%; height: auto; }
  marquee { font-size: 11px; }
}

/* Touch is not a small mouse. Keep the period surface, enlarge the hit areas. */
@media (pointer: coarse) {
  .qopt {
    display: inline-flex; align-items: center; gap: 4px;
    min-height: 44px; padding: 0 8px; cursor: pointer;
  }
  .qopt input { width: 20px; height: 20px; margin: 0; }
  input[type="text"], textarea { min-height: 44px; font-size: 16px; }
  input[type="submit"] { min-height: 44px; min-width: 132px; font-size: 14px; }
  #pageTable a[onclick*="ring"] {
    display: inline-block; min-height: 44px; line-height: 44px; padding: 0 12px;
  }
  #pageTable a[href="assets/img/pic"] { display: inline-block; min-height: 44px; }
  #unlockForm input { min-height: 44px; font-size: 16px; }
}

/* short landscape phones: one column, like a phone; keep the nameplate short */
@media (max-height: 500px) and (orientation: landscape) {
  body > table:first-of-type img { max-height: 88px; width: auto; }
  body > table,
  body #pageTable { width: 100% !important; max-width: 100% !important; }
  body #pageTable > tbody > tr > td { display: block; width: 100% !important; box-sizing: border-box; }
  #pageTable form table,
  #pageTable form table tbody,
  #pageTable form table tr,
  #pageTable form table td { display: block; width: 100% !important; }
  input, textarea { max-width: 100%; }
  img { max-width: 100%; height: auto; }
}

/* stage 5 on a phone: the plain text keeps a readable measure */
@media (max-width: 600px) {
  body.decay-5 #rawLayer {
    margin: 4vh auto 8vh; padding: 0 18px;
    font-size: 14px; line-height: 1.75;
  }
}
