/* ==========================================================================
   ArgosMob — Hand-Drawn 3D Paper & Ink Design System
   ========================================================================== */

:root {
  --paper: #fffdf8;
  --paper-warm: #f9f4ea;
  --ink: #1e2430;
  --ink-soft: #4b5563;
  --ink-muted: #7c8594;
  --accent: #e85b35;
  --accent-teal: #0ea5a4;
  --accent-amber: #f59e0b;
  --dashed: #d4c9b8;
  --shadow: rgba(30, 36, 48, 0.16);
  --font-hand: 'Patrick Hand', 'Caveat', cursive;
  --font-sketch: 'Gloria Hallelujah', 'Patrick Hand', cursive;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --paper-grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.04' numOctaves='5' stitchTiles='stitch'/%3E%3CfeDiffuseLighting lighting-color='%23fffdf8' surfaceScale='1.6'%3E%3CfeDistantLight azimuth='45' elevation='62'/%3E%3C/feDiffuseLighting%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.28'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #ffffff;
  color: var(--ink);
  font-family: var(--font-body);
  user-select: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Paper Tear Preloader
   ========================================================================== */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: all;
  overflow: hidden;
}

.preloader__half {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 54%;
  background-color: #ffffff;
  background-image: var(--paper-grain);
  transition: transform 0.95s cubic-bezier(0.76, 0, 0.24, 1), opacity 0.6s ease 0.4s;
  filter: drop-shadow(0 0 18px rgba(0, 0, 0, 0.14));
}

.preloader__half--left {
  left: 0;
  clip-path: polygon(
    0 0, 94% 0, 98% 9%, 91% 18%, 97% 28%, 90% 38%, 98% 49%,
    92% 60%, 97% 72%, 91% 83%, 96% 93%, 92% 100%, 0 100%
  );
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12%;
}

.preloader__half--right {
  right: 0;
  clip-path: polygon(
    6% 0, 100% 0, 100% 100%, 8% 100%, 4% 91%, 10% 80%, 3% 69%,
    9% 57%, 3% 46%, 10% 35%, 4% 24%, 9% 13%
  );
}

.preloader__label {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.preloader__title {
  font-family: var(--font-sketch);
  font-size: clamp(26px, 4vw, 42px);
  letter-spacing: 0.08em;
  color: var(--ink);
}

.preloader__sub {
  font-family: var(--font-hand);
  font-size: 16px;
  color: var(--ink-soft);
}

.preloader.torn .preloader__half--left {
  transform: translateX(-115%) rotate(-2deg);
}

.preloader.torn .preloader__half--right {
  transform: translateX(115%) rotate(2deg);
}

.preloader.torn {
  pointer-events: none;
}

/* Soft paper flash veil on room transitions */
.transition-veil {
  position: fixed;
  inset: 0;
  z-index: 60;
  background-color: #ffffff;
  background-image: var(--paper-grain);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.34s ease;
}

.transition-veil.active {
  opacity: 1;
}

/* ==========================================================================
   Torn-Paper Top Navigation Tabs
   ========================================================================== */
.hud-top-right {
  position: fixed;
  top: 0;
  right: 22px;
  z-index: 40;
  display: flex;
  gap: 11px;
}

.nav-btn {
  position: relative;
  width: 50px;
  height: 55px;
  padding: 0;
  border: none;
  background-color: var(--paper);
  background-image: var(--paper-grain);
  cursor: pointer;
  display: grid;
  place-items: center;
  clip-path: polygon(
    0 0, 100% 0, 100% 94%, 89% 99%, 76% 93%, 63% 99%, 50% 94%, 37% 99%, 24% 94%, 12% 99%, 0 94%
  );
  filter: drop-shadow(0 4px 10px var(--shadow));
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.nav-btn:hover {
  transform: translateY(4px);
}

.nav-btn:active {
  transform: translateY(7px);
}

.nav-btn--back {
  position: fixed;
  top: 0;
  left: 22px;
  z-index: 40;
}

.nav-btn__border {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.nav-btn__icon {
  width: 22px;
  height: 22px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Torn-Paper Dropdown Panels (Map & Achievements)
   ========================================================================== */
.paper-panel {
  position: fixed;
  top: 0;
  z-index: 45;
  background-color: var(--paper);
  background-image: var(--paper-grain);
  filter: drop-shadow(0 12px 28px rgba(0, 0, 0, 0.18));
  border-left: 1.5px solid var(--ink);
  border-right: 1.5px solid var(--ink);
  animation: paperDrop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes paperDrop {
  from {
    opacity: 0;
    transform: translateY(-28px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.paper-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 11px;
  border-bottom: 1.4px dashed var(--dashed);
}

.paper-panel__title {
  font-family: var(--font-sketch);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.paper-panel__close {
  border: none;
  background: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
  padding: 2px 6px;
  transition: transform 0.15s ease;
}

.paper-panel__close:hover {
  transform: scale(1.2) rotate(8deg);
}

/* Map Panel (Top-Center — Torn Left, Right & Bottom Edges + Watercolor Hover) */
.map-panel {
  left: 50%;
  transform: translateX(-50%);
  width: min(375px, 94vw);
  padding: 0 6px 26px;
  border-left: none;
  border-right: none;
  clip-path: polygon(
    1.5% 0, 98.5% 0,
    99.5% 8%, 97.8% 16%, 99.2% 26%, 97.6% 36%, 99.5% 46%, 97.8% 56%,
    99.2% 67%, 97.6% 77%, 99.4% 87%, 98% 97.4%,
    90.5% 99.2%, 83% 97%, 76% 99.4%, 69% 97.2%, 61.5% 99.4%,
    54% 97.2%, 47% 99.4%, 39.5% 97.2%, 32.5% 99.4%, 25.5% 97.2%,
    18.5% 99.4%, 12% 97%, 6.5% 99.2%, 1.8% 97.4%,
    1% 87%, 2.4% 77%, 0.8% 67%, 2.2% 56%, 0.6% 46%, 2.4% 36%,
    0.8% 26%, 2.2% 16%, 0.6% 8%
  );
  animation: mapDrop 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-panel__edge {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

@keyframes mapDrop {
  from {
    opacity: 0;
    transform: translate(-50%, -28px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.map-canvas {
  position: relative;
  padding: 8px 14px 4px;
}

.map-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.map-room,
.map-node,
.map-door-sq {
  cursor: pointer;
}

.map-room .map-paint {
  opacity: 0;
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-room:hover .map-paint,
.map-room.visited .map-paint,
.map-room.active .map-paint {
  opacity: 1;
}

.map-room__label {
  transition: fill 0.2s ease;
}

.map-room:hover .map-room__label,
.map-room.active .map-room__label {
  fill: var(--accent);
}

.map-door-sq {
  transition: stroke 0.2s ease, fill 0.2s ease, filter 0.2s ease;
}

.map-door-sq.highlighted,
.map-door-sq:hover {
  stroke: var(--accent);
  fill: #fff1eb;
  filter: url(#pinGlow);
}

.map-pin {
  position: absolute;
  left: 50%;
  top: 86%;
  transform: translate(-50%, -88%);
  pointer-events: none;
  transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1), top 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 5;
}

.map-footer {
  text-align: center;
  font-family: var(--font-hand);
  font-size: 14px;
  color: var(--ink-soft);
  padding: 2px 14px 0;
  min-height: 22px;
  transition: color 0.2s ease;
}

/* Achievements Panel (Top-Right) */
.achievements-panel {
  right: 18px;
  width: min(295px, 90vw);
  padding-bottom: 24px;
  clip-path: polygon(
    0 0, 100% 0, 100% 96.5%,
    93% 99.5%, 84% 96%, 75% 99.5%, 66% 96%, 57% 99.5%,
    48% 96%, 39% 99.5%, 30% 96%, 21% 99.5%, 12% 96%, 4% 99%, 0 96.5%
  );
}

.ach-list {
  list-style: none;
  margin: 0;
  padding: 12px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.ach-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ach-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 2px;
  display: grid;
  place-items: center;
}

.ach-item__name {
  font-family: var(--font-sketch);
  font-size: 13px;
  line-height: 1.25;
  color: var(--ink);
}

.ach-item__desc {
  font-family: var(--font-body);
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.ach-item.locked .ach-item__name,
.ach-item.locked .ach-item__desc {
  color: #a6a6a6;
}

.ach-footer {
  margin: 10px 18px 0;
  padding-top: 10px;
  border-top: 1.4px dashed var(--dashed);
  text-align: center;
  font-family: var(--font-sketch);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink);
}

/* ==========================================================================
   Bottom-Center Torn-Paper Toast Banner
   ========================================================================== */
.toast-banner {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 38;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 26px;
  min-width: 240px;
  max-width: 92vw;
  background-color: var(--paper);
  background-image: var(--paper-grain);
  filter: drop-shadow(0 5px 16px rgba(0, 0, 0, 0.16));
  clip-path: polygon(
    2% 4%, 98% 2%, 100% 18%, 97% 34%, 100% 52%, 98% 72%, 100% 92%,
    97% 98%, 3% 99%, 0% 85%, 2% 66%, 0% 48%, 2% 28%, 0% 12%
  );
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast-banner.toast-hidden {
  opacity: 0;
  transform: translate(-50%, 26px);
  pointer-events: none;
}

.toast-banner__text {
  text-align: center;
}

.toast-banner__title {
  font-family: var(--font-sketch);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--ink);
  line-height: 1.25;
}

.toast-banner__desc {
  font-family: var(--font-body);
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-top: 2px;
}

.inline-audio-btn {
  border: none;
  background: none;
  padding: 0 2px;
  font-family: var(--font-sketch);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  border-bottom: 1.5px dashed var(--ink);
}

.toast-checkmark {
  stroke-dasharray: 28;
  stroke-dashoffset: 28;
  transition: stroke-dashoffset 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.toast-banner.checked .toast-checkmark {
  stroke-dashoffset: 0;
}

/* ==========================================================================
   Hand-Drawn Paper Modals (Projects / Studio / Contact)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-paper {
  position: relative;
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  padding: 30px 32px 28px;
  background-color: var(--paper);
  background-image: var(--paper-grain);
  border: 2px solid var(--ink);
  box-shadow: 7px 7px 0 rgba(26, 26, 26, 0.14);
  animation: modalPop 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalPop {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: 1.5px solid var(--ink);
  background: #fff;
  width: 32px;
  height: 32px;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.15s ease;
}

.modal-close:hover {
  background: var(--ink);
  color: #fff;
  transform: rotate(6deg);
}

.modal-eyebrow {
  font-family: var(--font-hand);
  font-size: 14px;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.modal-title {
  font-family: var(--font-sketch);
  font-size: clamp(22px, 3vw, 30px);
  margin: 4px 0 14px;
  line-height: 1.2;
  color: var(--ink);
}

.modal-preview {
  width: 100%;
  height: 190px;
  border: 1.5px solid var(--ink);
  background: #fff;
  margin-bottom: 16px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.modal-preview canvas,
.modal-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-desc {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.65;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.modal-highlights {
  margin: 0 0 18px;
  padding: 12px 16px 12px 30px;
  background: rgba(255, 255, 255, 0.78);
  border: 1.4px dashed var(--dashed);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.modal-highlights li {
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
}

.modal-highlights li::marker {
  color: var(--accent);
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-tag {
  font-family: var(--font-hand);
  font-size: 13px;
  padding: 3px 11px;
  border: 1.4px solid var(--ink);
  background: #fff3e6;
  color: var(--ink);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.sketch-btn {
  font-family: var(--font-sketch);
  font-size: 13px;
  letter-spacing: 0.05em;
  padding: 10px 20px;
  border: 1.8px solid var(--ink);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.sketch-btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 var(--ink);
}

.sketch-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.sketch-btn--primary {
  background: var(--accent);
  color: #fff;
}

/* Contact Form */
.sketch-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sketch-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.sketch-form label span {
  font-family: var(--font-hand);
  font-size: 15px;
  color: var(--ink);
}

.sketch-form input,
.sketch-form textarea {
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 12px;
  border: 1.6px solid var(--ink);
  background: #fff;
  color: var(--ink);
  outline: none;
  resize: vertical;
}

.sketch-form input:focus,
.sketch-form textarea:focus {
  box-shadow: 3px 3px 0 rgba(26, 26, 26, 0.2);
}

.form-note {
  margin: 4px 0 0;
  font-size: 11.5px;
  color: var(--ink-muted);
  text-align: right;
}

@media (max-width: 640px) {
  .hud-top-right {
    right: 10px;
    gap: 7px;
  }
  .nav-btn--back {
    left: 10px;
  }
  .nav-btn {
    width: 44px;
    height: 48px;
  }
  .modal-paper {
    padding: 22px 20px;
  }
}
