/* ============================================================
   Due Diligence — Base Styles
   Layer discipline: filter ONLY on layer-environment children.
   NEVER on #layer-document, #layer-ui, or body.
   ============================================================ */

@font-face {
  font-family: 'HelvetiPixel';
  src: url('../HelvetiPixel.ttf') format('truetype');
  font-display: swap;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a1a;
  font-family: 'IM Fell English', Georgia, serif;
}

/* ── Dissolve canvas ── */
#dissolve-canvas {
  display: none; /* shown only during transitions */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none; /* never blocks interaction */
}

/* ── Three layers — all fixed, full viewport ── */
/* z-index map: environment=1, document=2, ui=3 */
/* RULE: no transform/opacity/will-change/filter on any element
         inside a layer without explicit review — these create
         implicit stacking contexts that break layer ordering. */

#layer-environment {
  position: fixed;
  inset: 0;
  z-index: 1;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-image: url('../assets/renders/Office_Wide.png');
}

/* Crossfade overlay used by setBackground({ fade: true }) — stacked above the
   current scene, faded to opacity 1, then the base layer is swapped underneath
   and this is removed. Avoids the hard-cut "flash" between scenes. */
.env-fade-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

/* Hover glows — transparent PNGs that highlight a hotspot's target object,
   composited above the scene background. They share the same `cover`/`center`
   sizing as #layer-environment so they line up pixel-for-pixel with the scene. */
.env-glow-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

#office-glow-cabinet {
  background-image: url('../assets/renders/CabinetGlowWide.png');
}

#shredder-glow-box {
  background-image: url('../assets/renders/Box_Glow_Shredder.png');
}

/* Hotspots live in #layer-ui (z=3), glows live in #layer-environment (z=1) —
   :has() lets the hover state on one drive visibility on the other without JS. */
body:has(#office-hotspot-shredder:hover) #office-glow-cabinet {
  opacity: 1;
}

body:has(#hotspot-box:hover) #shredder-glow-box {
  opacity: 1;
}

#layer-document {
  position: fixed;
  inset: 0;
  z-index: 2;
  /* NO filter property here — ever */
  pointer-events: none; /* children override as needed */
}

#layer-ui {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none; /* children override as needed */
}

/* ── Title screen ── */
#title-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

#title-wrap {
  text-align: center;
  user-select: none;
}

#title-text {
  font-family: 'Dancing Script', cursive;
  font-weight: 700;
  font-size: clamp(3.5rem, 10vw, 9rem);
  color: #f0ebe0;
  letter-spacing: 0.02em;
  line-height: 1;
  text-shadow:
    0 2px 8px rgba(0,0,0,0.9),
    0 0 40px rgba(0,0,0,0.6),
    2px 2px 0 rgba(0,0,0,0.4);
  margin-bottom: 1.2rem;
}

#title-text .cap {
  font-size: 1.35em;
  line-height: 0.8;
}

#begin-btn {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: #c8bfa8;
  cursor: pointer;
  transition: color 0.2s;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

#begin-btn:hover {
  color: #f0ebe0;
}

#title-screen.fade-out {
  animation: fadeOut 0.4s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; pointer-events: none; }
}

/* ── Intake overlay ── */
#intake-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.55);
  pointer-events: all;
}

/* ── Shredder hotspot ── */
#shredder-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hotspot-box {
  position: absolute;
  /* Positioned over the white archive box in Shredder_Static.png */
  right: 10%;
  top: 32%;
  width: 22%;
  height: 38%;
  cursor: url('../assets/cursors/pixel-hand.svg') 14 4, pointer;
  pointer-events: all;
}

/* ── A4 Paper ── */
#paper-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#paper {
  position: relative;
  background: #f8f5ef;
  /* A4 ratio 1:√2 ≈ 1:1.414 */
  width: 680px;
  max-width: 58vw;
  max-height: 82vh;
  aspect-ratio: 1 / 1.414;
  box-shadow:
    0 4px 24px rgba(0,0,0,0.55),
    0 1px 4px rgba(0,0,0,0.3);
  overflow: hidden;
  pointer-events: all;
  cursor: url('../assets/cursors/magnify.svg') 12 12, zoom-in;
}

#paper-content {
  padding: 8% 9%;
  font-size: clamp(0.55rem, 1.1vw, 0.85rem);
  line-height: 1.6;
  color: #1a1a1a;
  height: 100%;
  overflow: hidden; /* zoomed-out: no scroll */
}

/* Corner mark — typographic, not a button */
#paper-corner-mark {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  font-size: 1.1rem;
  color: #999;
  cursor: pointer;
  pointer-events: all;
  line-height: 1;
  font-family: monospace;
  user-select: none;
  opacity: 0.6;
  transition: opacity 0.15s;
}
#paper-corner-mark:hover { opacity: 1; }

/* ── DOC_ZOOM state ── */
#paper.zoomed {
  /* A4 is the largest the page ever gets — fixed page proportions, same
     as the un-zoomed paper, just bigger. At this size the page is taller
     than the viewport and bleeds off the bottom edge (intentional — it
     reads as a real sheet of paper, not a content-shrunk box). Anything
     that doesn't fit on one A4 page is truncated rather than growing the
     page further (overflow: hidden, no max-height cap). */
  width: 1180px;
  max-width: 96vw;
  max-height: none;
  aspect-ratio: 1 / 1.414;
  overflow: hidden;
  /* Do NOT use position:fixed or inset:0 — stays in normal flow */
  cursor: url('../assets/cursors/magnify-out.svg') 12 12, zoom-out;
}

#paper.zoomed #paper-content {
  overflow: visible;
  height: auto;
  padding: 7% 9%;
  font-size: clamp(1.05rem, 2.3vw, 1.55rem);
}

/* Zoomed paper sits at the top of its (possibly taller-than-viewport) container.
   Scrolling is OFF by default — the page bleeding off the bottom is fine, but we
   don't want to let the user scroll down into blank paper when there's no more
   text. JS (enterZoom) adds .zoom-scrollable only when the text actually runs
   past the bottom of the viewport. */
#paper-container:has(#paper.zoomed) {
  overflow-y: hidden;
  overflow-x: hidden;
  align-items: flex-start;
  padding: 3vh 0;
}

#paper-container.zoom-scrollable:has(#paper.zoomed) {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Zoom-out cursor label */
#zoom-label {
  position: fixed;
  background: rgba(0,0,0,0.65);
  color: #f0ebe0;
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 2px;
  pointer-events: none;
  z-index: 200;
  transform: translate(18px, 18px);
  display: none;
}

/* ── Decision buttons ── */
#doc-ui {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5vh;
  pointer-events: none;
}

#decision-btns {
  display: flex;
  gap: 3rem;
  pointer-events: all;
}

.decision-btn {
  background: none;
  border: 1px solid rgba(240, 235, 224, 0.5);
  color: #f0ebe0;
  font-family: 'IM Fell English', Georgia, serif;
  font-size: clamp(0.8rem, 1.5vw, 1rem);
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.5rem 1.8rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.decision-btn:hover {
  background: rgba(240, 235, 224, 0.12);
  border-color: rgba(240, 235, 224, 0.9);
}

.decision-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Briefing overlay ── */
#briefing-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 10, 10, 0.55);
  pointer-events: all;
}

#briefing-wrap {
  background: #f8f5ef;
  width: 560px;
  max-width: 82vw;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2.6rem 3rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.3);
  font-family: 'HelvetiPixel', 'IM Fell English', Georgia, serif;
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.75;
  color: #1a1a1a;
}

/* ── Office-view shredder hotspot ── */
#office-hotspot-shredder {
  position: absolute;
  /* Shredder + archive box sit on the cabinet top, centred horizontally, just below the vertical middle */
  left: 41%;
  top: 49%;
  width: 18%;
  height: 18%;
  cursor: pointer;
  pointer-events: all;
}

#office-hotspot-shredder:hover {
  background: rgba(255, 255, 255, 0.06);
}

/* ── End screens ── */
#end-pass, #end-fail {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
  background: rgba(10,10,10,0.4);
}

/* ── Kept pile indicator ── */
#kept-pile {
  position: absolute;
  bottom: 3vh;
  left: 3vw;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  pointer-events: none;
}

.kept-doc-stub {
  width: 48px;
  height: 62px;
  background: #f8f5ef;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.4);
  border: 1px solid rgba(0,0,0,0.1);
}

/* ── Utility ── */
.hidden {
  display: none !important;
}

/* ── Shred video (fullscreen, behind UI) ── */
#shred-video {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 10;
}

#shred-video.playing {
  display: block;
}

/* ── Document template base styles ── */
.doc-body {
  font-family: 'HelvetiPixel', 'IM Fell English', Georgia, serif;
}

.doc-header {
  text-align: center;
  border-bottom: 1px solid #333;
  padding-bottom: 0.6em;
  margin-bottom: 1em;
}

.doc-company {
  font-size: 0.9em;
  font-weight: bold;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.doc-tagline {
  font-size: 0.65em;
  font-style: italic;
  color: #555;
  letter-spacing: 0.05em;
}

.doc-meta {
  font-size: 0.75em;
  color: #444;
  margin-bottom: 1em;
}

.doc-body p {
  margin-bottom: 0.8em;
}

.doc-signature {
  margin-top: 1.5em;
  font-style: italic;
}

/* Correction fluid — Doc 2 */
.correction-fluid {
  display: inline-block;
  background: #e8e0d0;
  color: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 1px;
  padding: 0 4px;
  user-select: none;
  min-width: 5em;
  height: 1.1em;
  vertical-align: middle;
}

/* Redaction — Doc 7 */
.redacted {
  background: #111;
  color: transparent;
  user-select: none;
  display: inline;
}

.readable {
  /* unstyled — just the text */
}

/* Expense table — Doc 6 */
.expense-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
  margin: 0.8em 0;
}

.expense-table th {
  text-align: left;
  border-bottom: 1px solid #333;
  padding: 0.2em 0.4em;
  font-weight: normal;
  text-transform: uppercase;
  font-size: 0.8em;
  letter-spacing: 0.06em;
}

.expense-table td {
  padding: 0.2em 0.4em;
  vertical-align: top;
}

.expense-table tr.total-row td {
  border-top: 1px solid #333;
  font-weight: bold;
}

.expense-table tr.discrepancy-row td {
  color: #333;
}

/* Email chain — Doc 5 */
.email-separator {
  border: none;
  border-top: 1px solid #ccc;
  margin: 0.8em 0;
}

.email-block {
  margin-bottom: 0.6em;
}

.email-meta {
  font-size: 0.75em;
  color: #555;
  margin-bottom: 0.4em;
}

/* Checkbox grid — Doc 2 */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3em 1em;
  font-size: 0.8em;
  margin: 0.6em 0;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.checkbox-item input[type="checkbox"] {
  pointer-events: none;
}

/* ── Intake form paper ── */
#intake-form-wrap {
  background: #f8f5ef;
  width: 600px;
  max-width: 88vw;
  max-height: 88vh;
  overflow-y: auto;
  padding: 2.8rem 3.2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.3);
  font-family: 'IM Fell English', Georgia, serif;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.65;
  color: #1a1a1a;
}

.intake-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.8em;
}

.intake-table td {
  padding: 0.35em 0;
  vertical-align: top;
}

.intake-label {
  width: 42%;
}

.intake-input {
  width: 100%;
  border: none;
  border-bottom: 1px solid #888;
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
  padding: 0.15em 2px;
}

.intake-input:focus {
  border-bottom-color: #222;
}

.intake-radio {
  display: flex;
  gap: 1.5em;
  align-items: center;
}

.radio-opt {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35em;
}

.intake-footer {
  margin-top: 1em;
  padding-top: 0.8em;
  border-top: 1px solid #ccc;
}

.intake-submit {
  font-family: 'IM Fell English', Georgia, serif;
  font-size: 0.9em;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: none;
  border: 1px solid #555;
  padding: 0.4em 1.6em;
  cursor: pointer;
  margin-top: 0.6em;
  transition: background 0.15s, border-color 0.15s;
}

.intake-submit:hover {
  background: rgba(0,0,0,0.07);
  border-color: #222;
}

.intake-received {
  margin-top: 0.8em;
  padding-top: 0.6em;
  border-top: 1px dotted #bbb;
  font-style: italic;
  font-size: 0.78em;
  color: #666;
}

/* ── End screen paper ── */
.end-paper-wrap {
  background: #f8f5ef;
  width: 600px;
  max-width: 88vw;
  max-height: 88vh;
  overflow-y: auto;
  padding: 2.8rem 3.2rem;
  box-shadow: 0 4px 24px rgba(0,0,0,0.55), 0 1px 4px rgba(0,0,0,0.3);
  font-family: 'IM Fell English', Georgia, serif;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  line-height: 1.65;
  color: #1a1a1a;
}

.end-paper-note {
  font-style: italic;
}
