/* ==========================================================================
   Pine Hill Falls: pages.css
   Styles for the inner pages: directory listings, festival schedule,
   motel, forms, town map viewer, archive documents, legal text.
   ========================================================================== */

.page-intro { max-width: 44rem; font-size: 1.1rem; }

/* ---------- Directory listing (Living here) ---------- */
.listings { display: grid; gap: 2.5rem; }
.listing {
  display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  background: #fbf6ea; border: 1px solid var(--paper-edge);
  scroll-margin-top: 1rem;
}
.listing:nth-child(even) .listing__media { order: 2; }
.listing__media { position: relative; min-height: 16rem; }
.listing__media > .photo { position: absolute; inset: 0; }
.listing__body { padding: 1.5rem 1.6rem 1.7rem; display: grid; gap: 0.8rem; align-content: start; }
.listing__name {
  font-family: var(--font-sign); font-weight: 400; font-size: var(--fs-2xl);
  line-height: 0.95; letter-spacing: 0.03em; color: var(--navy);
}
.listing__kind { font-style: italic; color: var(--pine); margin-top: -0.4rem; }
.listing__facts { display: grid; gap: 0.1rem; font-size: var(--fs-sm); color: var(--ink-soft); padding: 0; list-style: none; }
.listing__facts li { padding-left: 1.2rem; position: relative; }
.listing__facts li::before { content: ""; position: absolute; left: 0; top: 0.55em; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--gold); }
.listing__quote { font-family: var(--font-hand); font-size: 1.35rem; line-height: 1.3; color: #9a3b5a; }
.listing--dots .listing__body { grid-template-columns: 1fr auto; column-gap: 1.2rem; }
.listing--dots .listing__body > *:not(.inset-portrait) { grid-column: 1; }
.inset-portrait { grid-column: 2; grid-row: 1 / span 4; width: 8.5rem; display: grid; gap: 0.3rem; align-self: start; }
.inset-portrait .mayor__frame .photo { aspect-ratio: 4 / 5; }
.inset-portrait figcaption { font-size: 0.8rem; color: var(--ink-soft); text-align: center; }
.listing__status {
  font-family: var(--font-doc); font-size: 0.95rem; color: #7d1410;
  border: 2px solid #7d1410; padding: 0.4rem 0.7rem; justify-self: start;
}
.illegible {
  display: inline-block; filter: blur(2.2px); opacity: 0.85;
  text-decoration: line-through wavy rgba(80, 60, 30, 0.6);
  user-select: none;
}
.useful { padding: 0; list-style: none; border-top: 1px solid var(--paper-edge); }
.useful li { padding: 0.75rem 0; border-bottom: 1px solid var(--paper-edge); }
@media (max-width: 46rem) {
  .listing { grid-template-columns: 1fr; }
  .listing:nth-child(even) .listing__media { order: 0; }
  .listing__media { min-height: 0; aspect-ratio: 3 / 2; }
  .listing__body { padding: 1.1rem 1rem 1.3rem; }
  .listing--dots .listing__body { grid-template-columns: 1fr; }
  .inset-portrait { grid-column: 1; grid-row: auto; width: 9rem; justify-self: center; }
}

/* ---------- Two-column feature (text + image) ---------- */
.feature { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem var(--gap); align-items: start; }
.feature__text { display: grid; gap: 0.9rem; max-width: 38rem; }
.feature .photo { aspect-ratio: 3 / 2; }
.feature--square .photo { aspect-ratio: 1 / 1; }
@media (max-width: 46rem) { .feature { grid-template-columns: 1fr; } }

/* Archive photograph with a white border and caption */
.archive-photo { background: #fff; padding: 0.8rem 0.8rem 0.6rem; box-shadow: 0 10px 24px rgba(40, 30, 10, 0.2); transform: rotate(-0.6deg); max-width: 54rem; }
.archive-photo .photo { aspect-ratio: 8 / 5; }
.archive-photo figcaption { font-family: var(--font-hand); font-size: 1.15rem; color: #3b3528; padding-top: 0.5rem; }

/* ---------- Festival schedule ---------- */
.schedule { padding: 0; list-style: none; border-left: 4px solid var(--gold); display: grid; gap: 0; max-width: 46rem; }
.schedule li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: 0.9rem 0 0.9rem 1.2rem; position: relative; }
.schedule li + li { border-top: 1px dashed var(--paper-edge); }
.schedule li::before {
  content: ""; position: absolute; left: -0.6rem; top: 1.25rem;
  width: 0.9rem; height: 0.9rem; border-radius: 50%; background: var(--cream); border: 3px solid var(--gold);
}
.schedule__time { font-family: var(--font-sign); font-size: var(--fs-lg); line-height: 1; color: var(--navy); padding-top: 0.15rem; }
.schedule__title { font-weight: 700; }
.schedule__date { font-weight: 700; color: var(--pine); margin-bottom: 1rem; }
@media (max-width: 36rem) { .schedule li { grid-template-columns: 1fr; gap: 0.2rem; } }

.fest-countdown { background: #f5d24a; color: #2a2412; padding: 1.3rem 1.3rem 1rem; max-width: 30rem; box-shadow: 0 6px 14px rgba(60, 45, 10, 0.25); }
.fest-countdown h2 { font-family: var(--font-sign); font-weight: 400; font-size: var(--fs-lg); letter-spacing: 0.06em; color: #6b4e0a; }

.rules { padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.rules li::marker { color: var(--gold); font-weight: 700; }

/* ---------- Motel ---------- */
.amenities { padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.amenities li { background: var(--pine); color: var(--cream); padding: 0.3rem 0.7rem; font-size: var(--fs-sm); border-radius: 2px; }
.price-tag {
  justify-self: start; font-family: var(--font-sign); font-size: var(--fs-xl); letter-spacing: 0.04em;
  color: #fff; background: #d63384; padding: 0.35rem 0.9rem 0.2rem;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #d63384;
}
.host { display: grid; grid-template-columns: 10rem 1fr; gap: 1.5rem; align-items: start; }
.host .mayor__frame .photo { aspect-ratio: 4 / 5; }
@media (max-width: 36rem) { .host { grid-template-columns: 1fr; } .host figure { max-width: 10rem; } }

/* ---------- Official forms ---------- */
.form-doc { padding: clamp(1.2rem, 4vw, 2.2rem); display: grid; gap: 1.2rem; max-width: 44rem; font-family: var(--font-doc); }
.form-doc__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 2px solid #2a2418; padding-bottom: 0.6rem; }
.form-doc__head h2 { font-family: var(--font-sign); font-weight: 400; font-size: var(--fs-xl); letter-spacing: 0.03em; line-height: 1; }
.form-doc__num { font-size: 0.85rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.2rem; }
.field { display: grid; gap: 0.3rem; }
.field--wide { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: 0.9rem; }
.field input, .field select {
  font-family: var(--font-doc); font-size: 1rem; min-height: 2.75rem;
  padding: 0.4rem 0.2rem; border: 0; border-bottom: 2px solid #2a2418; background: rgba(255, 255, 255, 0.35);
  border-radius: 0; width: 100%;
}
.field input:focus, .field select:focus { outline: 3px solid var(--gold); outline-offset: 2px; background: rgba(255, 255, 255, 0.7); }
.field input:disabled { background: repeating-linear-gradient(135deg, rgba(0,0,0,.05) 0 6px, transparent 6px 12px); color: #6b5f48; cursor: not-allowed; }
.field__note { font-size: 0.85rem; color: #7d1410; min-height: 1.2em; }
.field--emergency { padding: 0.8rem; border: 1px dashed #7d1410; }
.form-actions { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.form-status { font-family: var(--font-body); font-size: var(--fs-md); font-style: italic; min-height: 1.5em; }
.form-error { color: #7d1410; font-family: var(--font-body); }
.fict-note { font-family: var(--font-body); font-size: 0.8rem; color: #6b5f48; }
@media (max-width: 36rem) { .form-grid { grid-template-columns: 1fr; } }

/* Join page: offers + house */
.offers { padding: 0; list-style: none; display: grid; gap: 0.7rem; }
.offers li { padding-left: 1.6rem; position: relative; }
.offers li::before { content: "✓"; position: absolute; left: 0; color: var(--pine); font-weight: 700; }

/* After submitting the join form */
.join-thanks {
  font-family: var(--font-sign); font-size: clamp(2rem, 6vw, 3.4rem); line-height: 1;
  color: var(--navy); text-align: center; padding: 2rem 0;
}
.resident-card { position: relative; max-width: 34rem; padding: 1.6rem 1.6rem 1.4rem; display: grid; gap: 0.6rem; font-family: var(--font-doc); }
.resident-card h2 { font-family: var(--font-sign); font-weight: 400; font-size: var(--fs-xl); line-height: 1; }
.resident-card dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1rem; margin: 0; }
.resident-card dt { font-weight: 700; }
.resident-card dd { margin: 0; overflow-wrap: anywhere; }
.resident-card .stamp { position: absolute; right: 1rem; top: 1rem; bottom: auto; font-size: 1rem; }
html.is-joined .page-head { background: #10161a; transition: background 3s; }

/* ---------- Town map viewer ---------- */
.map-doc { position: relative; padding: 1rem; max-width: 50rem; margin-inline: auto; background: #f1ead8; box-shadow: 0 16px 36px rgba(40, 30, 10, 0.3); }
.map-doc::before { /* paper clip */
  content: ""; position: absolute; top: -1.1rem; left: 2.2rem; width: 1.1rem; height: 3.2rem; z-index: 3;
  border: 3px solid #8e949a; border-radius: 0.6rem; border-bottom-color: transparent;
  box-shadow: inset 0 0 0 3px #f1ead8, inset 0 0 0 6px #8e949a;
}
.map-doc::after { /* tape */
  content: ""; position: absolute; top: -0.8rem; right: 3rem; width: 6rem; height: 1.6rem; z-index: 3;
  background: rgba(240, 230, 190, 0.7); transform: rotate(4deg); box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.map-view {
  position: relative; overflow: hidden; aspect-ratio: 1086 / 1448; max-height: 80vh; margin-inline: auto;
  background: #efe9dc; cursor: grab; touch-action: pan-y;
}
.map-view.is-zoomed { touch-action: none; }
.map-view.is-dragging { cursor: grabbing; }
.map-view img { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; transform-origin: 0 0; will-change: transform; user-select: none; -webkit-user-drag: none; }
.map-controls { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.8rem; }
.map-controls button { min-width: 2.75rem; min-height: 2.75rem; }
.map-help { font-size: var(--fs-sm); color: var(--ink-soft); }
.map-caption { font-family: var(--font-hand); font-size: 1.4rem; text-align: center; margin-top: 0.4rem; }
.map-doc .stamp { top: auto; bottom: 4.5rem; right: 1.5rem; z-index: 2; }
.places { padding-left: 1.2rem; display: grid; gap: 0.5rem; }

/* ---------- Archives ---------- */
.arch-notice { font-size: var(--fs-sm); background: #efe3c2; border-left: 4px solid var(--gold); padding: 0.6rem 0.9rem; max-width: 44rem; }
.arch-item { display: grid; gap: 1rem; }
.arch-item__meta { font-family: var(--font-doc); font-size: 0.95rem; color: var(--ink-soft); max-width: 44rem; }

/* Ticket flip */
.ticket-flip { perspective: 1400px; background: none; border: 0; padding: 0; cursor: pointer; width: min(100%, 34rem); display: block; text-align: center; }
.ticket-flip__inner { position: relative; aspect-ratio: 1005 / 497; transform-style: preserve-3d; transition: transform 0.8s ease; }
.ticket-flip.is-flipped .ticket-flip__inner { transform: rotateY(180deg); }
.ticket-flip__face { position: absolute; inset: 0; backface-visibility: hidden; filter: drop-shadow(0 8px 12px rgba(0,0,0,.25)); }
.ticket-flip__face img { width: 100%; height: 100%; object-fit: contain; }
.ticket-flip__back { transform: rotateY(180deg); }
.ticket-flip:focus-visible { outline: 3px solid var(--gold); outline-offset: 6px; }
.lost-tag {
  justify-self: start; font-family: var(--font-doc); font-size: 0.85rem; background: #f7efd6;
  border: 1px solid #b9a97c; padding: 0.3rem 0.7rem; transform: rotate(-2deg);
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}

/* Notebook page */
.notebook { display: grid; grid-template-columns: 12rem 1fr; gap: 1.5rem; align-items: start; }
.notebook .photo { aspect-ratio: 1 / 1; box-shadow: 0 6px 14px rgba(0,0,0,.2); }
.nb-page {
  position: relative; padding: 1.2rem 1.4rem 1.4rem 3.2rem; max-width: 36rem;
  background:
    linear-gradient(90deg, transparent 2.3rem, rgba(214, 60, 60, 0.45) 2.3rem, rgba(214, 60, 60, 0.45) 2.4rem, transparent 2.4rem),
    repeating-linear-gradient(#fdfbf4 0 2.05rem, #a9c3de 2.05rem 2.1rem);
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
  font-family: var(--font-hand); font-size: 1.35rem; line-height: 2.1rem; color: #1f2c55;
  list-style: none; margin: 0;
}
.nb-page li:last-child { text-decoration: underline double; text-underline-offset: 0.2em; color: #16213f; }
@media (max-width: 40rem) { .notebook { grid-template-columns: 1fr; } .notebook .photo { max-width: 12rem; } }

/* Register */
.register-wrap { overflow-x: auto; max-width: 100%; background: #f4ecd4; box-shadow: 0 8px 18px rgba(0,0,0,.15); }
.register { border-collapse: collapse; min-width: 44rem; width: 100%; font-family: var(--font-hand); font-size: 1.15rem; }
.register th { font-family: var(--font-doc); font-size: 0.8rem; text-align: left; background: #2d4a37; color: #f4ecd8; padding: 0.5rem 0.6rem; border-right: 1px solid rgba(255,255,255,.2); }
.register td { padding: 0.55rem 0.6rem; border-bottom: 1px solid #b9c7d6; border-right: 1px solid #d9c9a0; color: #273255; height: 2.6rem; }
.register td:last-child, .register th:last-child { background-clip: padding-box; }
.register td:last-child { background: rgba(125, 20, 16, 0.04); }
.register tr.is-today td { color: #7d1410; }
.register tr.is-today td:nth-child(2)::after { content: "_"; animation: caret 1.1s steps(1) infinite; }
@keyframes caret { 50% { opacity: 0; } }

/* Redacted memo */
.memo { padding: clamp(1.2rem, 4vw, 2.4rem); max-width: 44rem; display: grid; gap: 0.9rem; font-size: 0.95rem; line-height: 1.7; transform: rotate(0.3deg); }
.memo__head { text-align: center; line-height: 1.4; border-bottom: 2px solid #2a2418; padding-bottom: 0.8rem; }
.memo__head strong { display: block; letter-spacing: 0.08em; }
.memo__class { display: inline-block; margin-top: 0.4rem; border: 2px solid #7d1410; color: #7d1410; padding: 0.1rem 0.6rem; font-weight: 700; letter-spacing: 0.2em; }
.memo__meta { display: grid; grid-template-columns: auto 1fr; gap: 0 0.8rem; }
.redact { background: #111; color: transparent; border-radius: 1px; user-select: none; box-decoration-break: clone; -webkit-box-decoration-break: clone; padding: 0 0.1em; }
.memo__sign { justify-self: end; }

/* ---------- Legal / about prose ---------- */
.prose { max-width: 44rem; display: grid; gap: 0.9rem; }
.prose h2 { font-family: var(--font-sign); font-weight: 400; font-size: var(--fs-xl); letter-spacing: 0.03em; color: var(--navy); margin-top: 1.4rem; }
.prose ul { padding-left: 1.2rem; }
.todo { background: #fff3a8; color: #7d1410; padding: 0 0.3em; font-family: var(--font-doc); }

/* ---------- Night mode for the new components ---------- */
html.is-night .listing, html.is-night .schedule li::before { background: #1f2624; border-color: #34403c; }
html.is-night .listing__name, html.is-night .schedule__time, html.is-night .prose h2 { color: #cfd6cf; }
html.is-night .useful, html.is-night .useful li { border-color: #34403c; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ticket-flip__inner { transition: none; }
  .register tr.is-today td:nth-child(2)::after { animation: none; }
}
.hero-wide { aspect-ratio: 16 / 9; }
.ticket-flip__hint {
  display: inline-flex; margin-top: 1rem; min-height: 2.75rem; align-items: center;
  padding: 0.4rem 1rem; border: 2px solid var(--navy); color: var(--navy); font-weight: 600; font-family: var(--font-body);
}
.ticket-flip:hover .ticket-flip__hint { background: rgba(29, 44, 71, 0.08); }

/* Long redaction bars must wrap on narrow screens */
.arch-item { grid-template-columns: minmax(0, 1fr); }
.memo { overflow-wrap: anywhere; }
.redact { word-break: break-all; }

/* Language and sound buttons: 44 px on small screens whatever the pointer */
@media (max-width: 36rem) {
  .lang-switch a, .sound-toggle { min-height: 2.75rem; min-width: 2.75rem; }
}
.ticket-flip__inner, .ticket-flip__face, .ticket-flip__face picture { display: block; }
.ticket-flip__face picture { width: 100%; height: 100%; }
.ticket-flip__hint { margin-top: 1rem; }
.map-controls { justify-content: center; }
.map-help { text-align: center; }


/* 1963 memo, laid out as in the novel */
.memo__head p { margin: 0.15rem 0; }
.memo__meta { display: grid; grid-template-columns: 1fr; gap: 0.1rem; }
.memo__meta p { margin: 0; }
.memo__subject { margin-top: 0.5rem !important; font-weight: 700; }
.memo__annex { font-size: 0.9rem; }
.memo__sign { justify-self: end; text-align: right; }
.memo__sign p { margin: 0; }

/* ---------- The Cedar Lane phone booth ---------- */
/* Portrait photo: a narrower, taller image column than the other listings */
.listing--booth { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.listing--booth .listing__media { min-height: 0; aspect-ratio: 2 / 3; }
.booth-photo { position: absolute; inset: 0; }
/* The fogged glass with 313, laid exactly over the photo, shown at the end of the call */
.booth__fogpic { position: absolute; inset: 0; opacity: 0; transition: opacity 2.6s ease; }
.booth__fogpic img { width: 100%; height: 100%; object-fit: cover; }
.is-fogged .booth__fogpic { opacity: 1; }
/* Ringing: the ceiling light buzzes and the booth trembles a little */
.booth__glow {
  position: absolute; left: 30%; right: 26%; top: 13%; height: 22%; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 236, 170, 0.75), transparent 70%);
  mix-blend-mode: screen;
}
.is-ringing .booth__glow { animation: lamp-buzz 1.3s steps(1, end) infinite; }
.is-ringing .booth-photo { animation: booth-tremble 0.11s linear infinite alternate; }
@keyframes lamp-buzz { 0%, 70%, 100% { opacity: 1; } 72% { opacity: 0.35; } 75% { opacity: 1; } 77% { opacity: 0.5; } }
@keyframes booth-tremble { from { transform: translate(-0.6px, 0); } to { transform: translate(0.6px, -0.4px); } }
.booth__panel { display: grid; gap: 0.6rem; justify-items: start; margin-top: 0.4rem; padding-top: 0.8rem; border-top: 1px dashed var(--paper-edge); }
.booth__status { font-family: var(--font-doc); font-size: 0.95rem; color: #7d1410; min-height: 1.4em; margin: 0; }
.booth__log { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.4rem; font-style: italic; }
.booth__log:empty { display: none; }
@media (max-width: 46rem) {
  .listing--booth { grid-template-columns: 1fr; }
  .listing--booth .listing__media { width: min(100%, 24rem); justify-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  .is-ringing .booth__glow { animation: none; opacity: 0.8; }
  .is-ringing .booth-photo { animation: none; }
  .booth__fogpic { transition-duration: 1.2s; }
}

