/* ============================================================
   The Memory House — handwritten ink on old paper over a desk
   collage of faded photographs.
   ============================================================ */

@font-face {
  font-family: "Special Elite";
  src: url("/fonts/SpecialElite-Regular.woff2") format("woff2"),
       url("/fonts/SpecialElite-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  /* faded brown kraft paper: warm tone, soft vignette, grain */
  background-color: #b99d74;
  background-image:
    radial-gradient(ellipse at 50% 35%, rgba(255, 240, 210, 0.30) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(80, 52, 28, 0.45) 100%),
    url("/img/paper-grain.svg");
  color: #1f2233; /* blue-black ink */
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ============================================================
   Collage — photo prints scattered on the desk
   ============================================================ */

.collage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.print {
  position: absolute;
  width: var(--w, 12vw);
  min-width: 90px;
  max-width: 240px;
  margin: 0;
  padding: 10px 10px 26px; /* white print border, thicker at bottom like a polaroid */
  background: #f4f0e6;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  transform: rotate(var(--r, 0deg));
  transition: transform 0.9s ease;
  opacity: 0.75;
}

.print:nth-child(odd) { opacity: 0.62; }
.print:nth-child(3n) { opacity: 0.8; }

.print img {
  display: block;
  width: 100%;
  height: auto;
  filter: sepia(0.35) contrast(0.85) brightness(1.05) saturate(0.7);
}

/* masking-tape strip across the top of taped prints */
.print.taped::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 46%;
  height: 22px;
  transform: translateX(-50%) rotate(-4deg);
  background: rgba(238, 228, 198, 0.72);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* a few paper scraps lying around */
.scrap {
  position: absolute;
  display: block;
  width: 70px;
  height: 90px;
  background: #e9e0c8;
  opacity: 0.55;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.scrap.s1 { left: 30%; top: 12%; transform: rotate(14deg); }
.scrap.s2 { right: 22%; bottom: 10%; transform: rotate(-22deg); width: 55px; height: 70px; }
.scrap.s3 { left: 12%; bottom: 26%; transform: rotate(40deg); width: 40px; height: 55px; }

/* ============================================================
   The sheet of paper
   ============================================================ */

.page {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: 28px 16px 72px;
  perspective: 1400px;
}

.paper {
  --tilt: 0deg;
  position: relative;
  background-color: #f3ecdb;
  background-image:
    radial-gradient(ellipse at 85% 8%, rgba(160, 130, 80, 0.10) 0%, transparent 45%),
    radial-gradient(ellipse at 10% 95%, rgba(120, 95, 60, 0.10) 0%, transparent 40%),
    url("/img/paper-grain.svg");
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.45);
  padding: 40px 36px 44px;
  margin: 20px 0;
  min-height: 340px;
  border-radius: 3px;
  transform: rotate(var(--tilt));
}

/* slightly wobbly hand-torn edge where clip-path is supported */
@supports (clip-path: polygon(0 0, 100% 0, 100% 100%)) {
  .paper {
    border-radius: 0;
    clip-path: polygon(
      0.4% 1.2%, 8% 0.2%, 22% 1.1%, 37% 0.3%, 52% 1.0%, 68% 0.2%,
      82% 1.2%, 94% 0.4%, 99.6% 1.0%, 99.9% 12%, 99.4% 26%, 99.9% 41%,
      99.3% 56%, 99.8% 71%, 99.4% 86%, 99.8% 97%, 94% 99.6%, 80% 99.0%,
      64% 99.8%, 48% 99.2%, 32% 99.9%, 17% 99.1%, 4% 99.8%, 0.3% 96%,
      0.7% 82%, 0.2% 66%, 0.6% 51%, 0.1% 37%, 0.5% 22%, 0.1% 9%
    );
  }
}

/* faint fold line */
.paper::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 52%;
  width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(90, 70, 40, 0.07) 20%, rgba(90, 70, 40, 0.07) 80%, transparent);
  pointer-events: none;
}

/* occasional coffee-ring stain */
.paper.ring-stain::after {
  content: "";
  position: absolute;
  right: 6%;
  bottom: 10%;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 7px solid rgba(140, 100, 50, 0.07);
  box-shadow: inset 0 0 8px rgba(140, 100, 50, 0.05);
  pointer-events: none;
}

/* ink look — slight bleed */
.paper h1, .paper p, .paper li, .paper label,
.paper textarea, .paper button, .paper td, .paper h2, .paper h3, .paper h4 {
  text-shadow: 0 0 0.4px rgba(31, 34, 51, 0.55);
}

/* ============================================================
   Typography
   ============================================================ */

.site-title {
  font-family: "Special Elite", "Courier New", monospace;
  font-weight: 400;
  font-size: 1.6rem;
  line-height: 1.4;
  margin: 0 0 10px;
  text-align: center;
  transform: rotate(-0.5deg);
}

.cover .site-title {
  font-size: 1.9rem;
  margin-top: 24px;
  animation: ink-reveal 1.6s ease-out;
}

@keyframes ink-reveal {
  from { opacity: 0; letter-spacing: 0.35em; }
  to   { opacity: 1; letter-spacing: normal; }
}

.note {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.82rem;
  color: #565a6e;
  text-align: center;
}

.q-count {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #6d7086;
  margin: 0 0 10px;
}

.prompt {
  font-family: "Special Elite", "Courier New", monospace;
  font-weight: 400;
  font-size: 1.25rem;
  line-height: 1.75;
  margin: 0;
  /* typed, not handwritten: straight lines, spaced-out monospace letters,
     a hint of ink bleed from the ribbon */
  letter-spacing: 0.06em;
  word-spacing: 0.12em;
  color: #15171f;
  text-shadow: 0 0 0.6px rgba(21, 23, 31, 0.9), 0.4px 0.4px 0 rgba(21, 23, 31, 0.35);
}

.prompt-hint {
  font-family: "Special Elite", "Courier New", monospace;
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: #565a6e;
  margin: 6px 0 0;
}

/* hand-drawn underline that draws itself */
.ink-underline {
  display: block;
  width: min(100%, 300px);
  height: 14px;
  margin: 4px 0 18px;
  color: #1f2233;
  opacity: 0.75;
}
.ink-underline path {
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-dasharray: 320;
  stroke-dashoffset: 320;
  animation: draw-line 0.9s ease-out 0.15s forwards;
}
@keyframes draw-line {
  to { stroke-dashoffset: 0; }
}

/* ============================================================
   Answer textarea — ink on ruled lines
   ============================================================ */

.answer-wrap { position: relative; }

.answer-input {
  display: block;
  width: 100%;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 16px; /* px so rules and text can't drift apart at any width */
  line-height: 34px;
  color: #1f2233;
  padding: 0 4px;
  border: none;
  background-color: transparent;
  /* rule at the bottom of each 34px line box — baseline sits on the rule */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 32px,
    rgba(60, 70, 120, 0.28) 32px,
    rgba(60, 70, 120, 0.28) 34px
  );
  background-position: 0 0;
  background-attachment: local;
  resize: none;
  outline: none;
}
.answer-input:focus {
  box-shadow: 0 2px 0 rgba(31, 34, 51, 0.35);
}

/* cosmetic scribble when a question is skipped */
.scribble-x {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: #3a3f5c;
  pointer-events: none;
  animation: scribble-in 0.34s ease-out forwards;
}
.scribble-x path {
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
}
@keyframes scribble-in {
  0% { opacity: 0; }
  30% { opacity: 0.9; }
  100% { opacity: 0; }
}

.char-count {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  color: #7a7d92;
  text-align: right;
  margin: 8px 0 18px;
}

/* ============================================================
   Buttons — hand-drawn ink
   ============================================================ */

.ink-btn {
  font-family: "Special Elite", "Courier New", monospace;
  font-weight: 400;
  font-size: 1rem;
  color: #1f2233;
  background: transparent;
  border: 2px solid #1f2233;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 8px 30px;
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  transition: transform 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.ink-btn:hover, .ink-btn:focus-visible {
  color: #101221;
  border-color: #101221;
  transform: rotate(-1deg) translateY(-1px);
  outline: none;
}
.ink-btn:active { transform: rotate(0.5deg) translateY(1px); }
.ink-btn:disabled {
  color: #8d8fa0;
  border-color: #8d8fa0;
  border-style: dashed;
  cursor: default;
  transform: none;
}

.btn-row { margin-top: 26px; text-align: center; }

/* the Begin button pinned to a little taped note */
.tape-note {
  position: relative;
  margin: 30px auto 10px;
  padding: 26px 30px 20px;
  width: fit-content;
  background: #efe6c9;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: rotate(1.5deg);
  text-align: center;
}
.tape-note::before {
  content: "";
  position: absolute;
  top: -11px;
  left: 50%;
  width: 90px;
  height: 22px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(238, 228, 198, 0.75);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

/* ============================================================
   Page-turn animation
   ============================================================ */

.page.turning { overflow: hidden; }

.paper {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.paper.turn-out {
  transform-origin: left center;
  animation: page-out 0.55s ease-in forwards;
}
@keyframes page-out {
  0%   { transform: rotate(var(--tilt)) rotateY(0deg); opacity: 1; }
  60%  { opacity: 0.9; }
  100% { transform: rotate(var(--tilt)) rotateY(-100deg) translateX(-30px); opacity: 0; }
}

.paper.turn-in { animation: page-in 0.4s ease-out; }
@keyframes page-in {
  0%   { transform: translateY(26px) rotate(calc(var(--tilt) - 2deg)); opacity: 0; }
  70%  { transform: translateY(-4px) rotate(calc(var(--tilt) + 0.4deg)); opacity: 1; }
  100% { transform: translateY(0) rotate(var(--tilt)); opacity: 1; }
}

/* ============================================================
   Submit page
   ============================================================ */

.submit-heading {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1.05rem;
  letter-spacing: 0.3em;
  text-align: center;
  margin: 30px 0 6px;
  text-transform: uppercase;
}
.submit-heading:first-child { margin-top: 6px; }

.submit-note {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.78rem;
  color: #565a6e;
  text-align: center;
  margin: 0 0 18px;
  font-style: italic;
}

/* upload slot = index card with a dashed "attach here" area */
.upload-slot {
  position: relative;
  background: #f7efdb;
  border: 1px solid #ddd0ae;
  box-shadow: 0 2px 6px rgba(60, 45, 20, 0.15);
  padding: 16px 16px 18px;
  margin: 14px 0;
  transform: rotate(0.3deg);
}
.upload-slot:nth-child(odd) { transform: rotate(-0.4deg); }

.upload-slot h3 {
  font-family: "Special Elite", "Courier New", monospace;
  font-weight: 400;
  font-size: 0.95rem;
  margin: 0 0 12px;
}

/* hidden native input; label is the visible ink button (still keyboard reachable) */
.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}
.file-input:focus-visible + .file-label {
  outline: 2px dashed #1f2233;
  outline-offset: 3px;
}

.file-label {
  display: inline-block;
  font-size: 1.15rem;
  padding: 6px 22px;
  border-width: 1.5px;
  border-style: dashed;
}

.file-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}

.file-name {
  flex: 1 1 100%;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.75rem;
  color: #3d4157;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* progress = a thin ink line filling across */
.progress {
  flex: 1 1 auto;
  height: 5px;
  background: rgba(31, 34, 51, 0.12);
  border-radius: 3px;
  overflow: hidden;
}
.progress > .bar {
  height: 100%;
  width: 0;
  background: #1f2233;
  transition: width 0.15s linear;
}

.file-status {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  color: #565a6e;
  min-width: 96px;
  text-align: right;
}
.file-status.error { color: #8e2f22; }

.retry-btn {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.8rem;
  font-weight: 400;
  padding: 3px 12px;
  border: 1.5px solid #8e2f22;
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  background: none;
  color: #8e2f22;
  cursor: pointer;
}

/* TO BRING checklist — real tappable checkboxes drawn by hand */
.bring-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.bring-list li { margin: 6px 0; }

.bring-item {
  display: flex;
  align-items: center;
  position: relative;
  min-height: 44px; /* touch target */
  padding: 4px 4px 4px 36px;
  font-size: 1.25rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* native input stays in the DOM for keyboard/screen readers, just invisible */
.bring-check {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

/* the drawn square */
.bring-box {
  position: absolute;
  left: 4px;
  top: 50%;
  width: 17px;
  height: 17px;
  margin-top: -9px;
  border: 2px solid #1f2233;
  border-radius: 4px 1px 3px 1px / 1px 4px 1px 3px;
  transform: rotate(-3deg);
}
li:nth-child(2) .bring-box { transform: rotate(4deg); }

.bring-check:focus-visible + .bring-box {
  outline: 2px dashed #1f2233;
  outline-offset: 3px;
}

/* scribbled tick that draws itself when checked */
.bring-tick {
  position: absolute;
  left: -3px;
  top: -7px;
  width: 24px;
  height: 20px;
  color: #1f2233;
}
.bring-tick path {
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}
.bring-check:checked + .bring-box .bring-tick path {
  animation: draw-tick 0.15s ease-out forwards;
}
@keyframes draw-tick {
  to { stroke-dashoffset: 0; }
}

/* ============================================================
   Done page
   ============================================================ */

/* done page = a short note, not a half-empty sheet */
.paper.done {
  min-height: 0;
  padding: 52px 30px 60px;
  text-align: center;
}

.code-wrap {
  position: relative;
  display: inline-block; /* shrinks to the text block */
  box-sizing: border-box;
  /* keep the text block narrower than the paper so the ink circle's overshoot
     (below) lands inside the torn-edge clip-path instead of being cropped */
  max-width: 80%;
  margin: 24px 10% 20px;
  padding: 10px 18px;
}

.memory-code,
.farewell {
  font-family: "Special Elite", "Courier New", monospace;
  text-align: center;
  margin: 0;
  transform: rotate(-1deg);
  /* never break inside a word — wrap whole words only */
  overflow-wrap: normal;
  word-break: normal;
  -webkit-hyphens: none;
  hyphens: none;
}

.farewell {
  font-size: clamp(1.15rem, 4.5vw, 1.6rem);
  line-height: 1.7;
}

.ink-circle {
  position: absolute;
  /* loose hand-drawn loop: overshoot the text block on every side */
  left: -15%;
  top: -22%;
  width: 130%;
  height: 144%;
  overflow: visible;
  color: #1f2233;
  opacity: 0.85;
  pointer-events: none;
}
.ink-circle path {
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw-line 1.4s ease-out 0.3s forwards;
}

/* ============================================================
   Team page — same desk, denser and readable
   ============================================================ */

body.team { font-size: 1rem; }
body.team .page { max-width: 860px; }

/* compact header / login sheets — no big empty paper block */
.paper.team-head {
  min-height: 0;
  padding: 18px 28px 14px;
  text-align: center;
  position: relative;
}
.paper.team-head .site-title { font-size: 1.5rem; margin: 0 0 2px; }
.paper.team-head .note { margin: 0; }

.logout-link {
  position: absolute;
  top: 14px;
  right: 18px;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.7rem;
  color: #6d7086;
}
.logout-link:hover { color: #1f2233; }

.login-form {
  text-align: center;
  min-height: 0;
  padding: 22px 28px 26px;
}
.login-form input[type="password"] {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1rem;
  padding: 10px 12px;
  min-height: 44px;
  border: 1px dashed #8a8262;
  background: rgba(255, 253, 244, 0.75);
  color: #1f2233;
}
.login-form .ink-btn { font-size: 1.15rem; padding: 6px 22px; }

.team-entry { padding: 26px 26px 30px; }
.team-entry h2 {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
  margin: 0 0 4px;
}
.team-entry .submitted {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  color: #6d7086;
  margin: 0 0 16px;
}

.answers-table {
  width: 100%;
  border-collapse: collapse;
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.8rem;
  margin-bottom: 20px;
}
.answers-table td {
  border-top: 1px dashed #c9bd97;
  padding: 8px 8px 8px 0;
  vertical-align: top;
}
.answers-table td.q { width: 44%; color: #565a6e; }

.file-group h4 {
  font-family: "Special Elite", "Courier New", monospace;
  font-weight: 400;
  font-size: 0.95rem;
  margin: 16px 0 10px;
}

.file-card {
  display: inline-block;
  margin: 0 14px 18px 0;
  vertical-align: top;
  max-width: 220px;
}
.file-card img, .file-card video {
  display: block;
  max-width: 220px;
  max-height: 170px;
  padding: 6px 6px 18px;
  background: #f4f0e6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  filter: sepia(0.12);
}
.file-card a.dl {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  color: #565a6e;
}

.file-meta {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.68rem;
  color: #7a7d92;
  margin: 6px 0 2px;
}

/* card shown when a browser can't render the file (HEIC, HEVC .mov…) */
.file-fallback {
  display: block;
  width: 220px;
  min-height: 96px;
  padding: 12px 12px 16px;
  background: #f4f0e6;
  border: 1px dashed #b0a480;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.file-fallback .ff-name {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.72rem;
  margin: 0 0 8px;
  word-break: break-all;
}
.file-fallback .ff-hint {
  font-size: 1.05rem;
  color: #565a6e;
  margin: 0;
}

.error-text {
  font-family: "Special Elite", "Courier New", monospace;
  font-size: 0.85rem;
  color: #8e2f22;
}

/* ============================================================
   Responsive — fewer, smaller prints under 700px
   ============================================================ */

@media (max-width: 700px) {
  .print:nth-child(n + 6) { display: none; }
  .print { width: calc(var(--w, 12vw) * 2.1); min-width: 70px; max-width: 150px; opacity: 0.5; }
  .print:nth-child(odd) { opacity: 0.42; }
  .scrap.s2, .scrap.s3 { display: none; }

  .page { padding: 18px 12px 60px; }
  .paper { padding: 26px 20px 32px; min-height: 300px; }
  .site-title { font-size: 1.35rem; }
  .cover .site-title { font-size: 1.55rem; }
  .prompt { font-size: 1.05rem; }
  .memory-code, .farewell { font-size: clamp(1.1rem, 5.5vw, 1.35rem); }
  .answer-input { font-size: 16px; }
}

@media (max-width: 360px) {
  .prompt { font-size: 0.95rem; }
  .site-title { font-size: 1.2rem; }
}

/* ============================================================
   Reduced motion — simple crossfade, no draw animations
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .paper.turn-out {
    transform-origin: center;
    animation: fade-out 0.2s ease-out forwards;
  }
  @keyframes fade-out {
    to { opacity: 0; }
  }
  .paper.turn-in { animation: fade-in 0.2s ease-in; }
  @keyframes fade-in {
    from { opacity: 0; }
  }
  .ink-underline path, .ink-circle path {
    stroke-dasharray: none;
    stroke-dashoffset: 0;
    animation: none;
  }
  .cover .site-title { animation: none; }
  .print { transition: none; }
  .scribble-x { animation: none; opacity: 0.9; }
}
