/* ============================================================
   HAPPY DUCK INVESTIGATION — STYLES
   ------------------------------------------------------------
   Organised top-to-bottom:
   1. Design tokens (colors, fonts) as CSS variables
   2. Base / reset
   3. Reusable pieces (buttons, cards, inputs)
   4. Layout helpers
   5. Page-specific sections
   ============================================================ */

/* ---- 1. Design tokens ------------------------------------- */
:root {
  --bg: #f8f4ec;
  --card: #fffcf8;
  --primary: #5e7a67;
  --primary-dark: #4e6857;
  --secondary: #91a88c;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e7e0d2;
  --accent: #e8a54b;
  --danger: #c05b4d;

  --font-display: "Fraunces", Georgia, serif;
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --radius: 18px;
  --radius-lg: 26px;
  --shadow-card: 0 1px 2px rgba(31, 41, 51, 0.03), 0 12px 32px rgba(31, 41, 51, 0.06);
  --shadow-lift: 0 20px 50px rgba(31, 41, 51, 0.12);
}

/* ---- 2. Base / reset -------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Ensure the hidden attribute always wins, even over our
   display:flex rules on .modal / .menu. Without this, a hidden
   overlay would still capture clicks across the page. */
[hidden] {
  display: none !important;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* Visible focus ring for keyboard users */
:where(a, button, input, [tabindex]):focus-visible {
  outline: 2.5px solid var(--primary);
  outline-offset: 2px;
  border-radius: 10px;
}

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- 3. Reusable pieces ----------------------------------- */

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  padding: 0 24px;
  border: none;
  border-radius: 16px;
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.99); }
.btn--block { width: 100%; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--primary:disabled { opacity: 0.5; cursor: default; }
.btn--ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn--ghost:hover { background: rgba(0, 0, 0, 0.03); }
.btn--danger { background: transparent; color: var(--danger); border: 1px solid rgba(192, 91, 77, 0.3); }
.btn--danger:hover { background: rgba(192, 91, 77, 0.05); }
.btn__arrow { font-size: 16px; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.pad { padding: 18px; }

/* Inputs */
.field-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  text-align: center;
}
.input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--bg);
  overflow: hidden;
}
.input-wrap__icon { color: var(--muted); }
.input-wrap__toggle {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  flex-shrink: 0;
}
.input {
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  outline: none;
  font-size: 16px;
  color: var(--ink);
}
.input::placeholder { color: rgba(107, 114, 128, 0.45); }
.input.mono,
.mono { font-family: var(--font-mono); letter-spacing: 0.15em; }

/* Small text helpers */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; color: var(--ink); }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.error-text { margin-top: 8px; font-size: 14px; font-weight: 500; color: var(--danger); text-align: center; }
.hint { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---- 4. Layout helpers ------------------------------------ */
.page-centered {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Ambient blurred blobs */
.blob {
  position: absolute;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.blob--green { background: rgba(145, 168, 140, 0.25); top: -60px; right: -50px; }
.blob--olive { background: rgba(94, 122, 103, 0.14); bottom: -70px; left: -60px; }

/* Logo sizing */
.logo { width: 64px; height: 64px; }
.logo svg { width: 100%; height: 100%; display: block; }
.logo--sm { width: 26px; height: 26px; }
.logo--xs { width: 22px; height: 22px; }
.logo--float { animation: float 3s ease-in-out infinite; }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Wordmark */
.wordmark { text-align: center; margin-top: 12px; }
.wordmark--left { text-align: left; margin-top: 0; }
.wordmark__title {
  display: block;
  font-family: var(--font-sans);
  letter-spacing: 0.18em;
  font-weight: 600;
  font-size: 19px;
  color: var(--ink);
}
.wordmark__sub {
  display: block;
  font-size: 10px;
  letter-spacing: 0.42em;
  color: var(--muted);
  margin-top: 3px;
}

/* ---- 5. Page: Login --------------------------------------- */
.login-card { width: 100%; max-width: 380px; padding: 32px; position: relative; }
.logo-block { display: flex; flex-direction: column; align-items: center; }
.login-form { margin-top: 30px; }
.login-form .input-wrap { margin-top: 8px; }
.login-form .btn { margin-top: 20px; }
.footer-tag {
  position: absolute;
  bottom: 22px;
  font-size: 11px;
  letter-spacing: 0.3em;
  color: rgba(107, 114, 128, 0.7);
}

/* ---- 5. Page: Intro --------------------------------------- */
.case-tag {
  position: absolute;
  top: 24px; left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.35em;
  color: var(--muted);
}
.footprints { position: absolute; inset: 0; pointer-events: none; }
.footprint {
  position: absolute;
  width: 15px; height: 15px;
  opacity: 0.2;
  background-color: var(--primary);
  /* duck footprint drawn with a mask so we can recolor via bg */
  -webkit-mask: var(--foot) center / contain no-repeat;
  mask: var(--foot) center / contain no-repeat;
}
.intro { position: relative; max-width: 340px; text-align: center; }
.intro__title {
  margin-top: 28px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 26px;
  line-height: 1.35;
  color: var(--ink);
}
.intro__text {
  margin: 16px auto 0;
  max-width: 280px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
}
.intro__cta { margin-top: 30px; }

/* ---- 5. Page: Dashboard — header -------------------------- */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 244, 236, 0.85);
  backdrop-filter: blur(8px);
}
.header__inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header__left { display: flex; align-items: center; gap: 8px; }
.header__right { display: flex; align-items: center; gap: 10px; }
.header__title {
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: 0.14em;
  font-weight: 600;
}
.header__case { font-size: 10px; letter-spacing: 0.2em; color: var(--muted); }
.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: none;
  background: none;
  border-radius: 12px;
  font-size: 20px;
  color: var(--ink);
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.04); }

/* ---- Dashboard — slide-out menu --------------------------- */
.menu { position: fixed; inset: 0; z-index: 50; }
.menu__backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 41, 51, 0.3);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}
.menu__panel {
  position: absolute;
  left: 0; top: 0;
  height: 100%;
  width: 82%;
  max-width: 360px;
  background: var(--card);
  box-shadow: var(--shadow-lift);
  padding: 24px;
  display: flex;
  flex-direction: column;
  animation: slide-in 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.menu__head { display: flex; align-items: center; justify-content: space-between; }
.menu__nav { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border: none;
  background: none;
  border-radius: 12px;
  text-align: left;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
}
.menu__item span { color: var(--primary); }
.menu__item:hover { background: rgba(0, 0, 0, 0.03); }
.menu__item--danger { color: var(--danger); }
.menu__item--danger span { color: var(--danger); }
.menu__nav:first-of-type { margin-top: 32px; }
.menu__divider { height: 1px; background: var(--line); margin: 16px 0; }
.menu__foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 24px;
  color: var(--muted);
  font-size: 14px;
}
.menu__h2 { margin-top: 40px; font-family: var(--font-sans); font-size: 20px; font-weight: 600; }
.menu__p { margin-top: 8px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.menu__p--small { margin-top: 12px; font-size: 13px; }
.menu__actions { margin-top: 24px; display: flex; gap: 12px; }
.menu__actions .btn { flex: 1; }

/* ---- Dashboard — content ---------------------------------- */
.dashboard {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 96px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.progress {
  margin-top: 12px;
  height: 10px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
}
.progress__bar {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.progress__pct { margin-top: 6px; text-align: right; font-size: 12px; color: var(--muted); }

.coord-card { display: block; border-color: rgba(94, 122, 103, 0.3); transition: border-color 0.15s; }
.coord-card:hover { border-color: var(--primary); }
.coord {
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 29px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.coord--sm { font-size: 20px; }
.coord__sep { color: var(--muted); margin: 0 6px; }
.chevron { color: var(--muted); font-size: 20px; }

/* Locations grid */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
/* 3 columns on wider screens (tablet / desktop) */
@media (min-width: 560px) {
  .grid { grid-template-columns: 1fr 1fr 1fr; }
}
.room {
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-card);
  text-align: left;
  padding: 0;
}
.room__img { position: relative; height: 80px; }
.room__check {
  position: absolute;
  right: 8px; top: 8px;
  width: 24px; height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 252, 248, 0.9);
  color: var(--primary);
  font-size: 14px;
}
.room__body { padding: 9px 12px; }
.room__name { font-size: 13px; font-weight: 600; color: var(--ink); }
.room__status { font-size: 11px; }
.room__status.is-done { color: var(--primary); }
.room__status.is-todo { color: var(--muted); }

/* ---- Dashboard — bottom nav ------------------------------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 248, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-around;
  padding: 10px 24px;
}
.tabbar__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}
.tabbar__item span { font-size: 18px; }
.tabbar__item.is-active { color: var(--primary); }

/* ---- Dashboard — room modal ------------------------------- */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 560px) { .modal { align-items: center; } }
.modal__backdrop {
  position: absolute; inset: 0;
  background: rgba(31, 41, 51, 0.4);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}
.modal__panel {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 26px 26px 0 0;
  padding: 24px;
  box-shadow: var(--shadow-lift);
  animation: slide-up 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@media (min-width: 560px) { .modal__panel { border-radius: 26px; } }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal__image {
  position: relative;
  height: 128px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #dce4d2, #c4d2b4);
}
.modal__pin { font-size: 24px; opacity: 0.5; }
.modal__close {
  position: absolute;
  right: 12px; top: 12px;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: none;
  border-radius: 10px;
  background: rgba(255, 252, 248, 0.8);
  color: var(--muted);
}
.modal__head { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.modal__pin-inline { color: var(--primary); }
.modal__title { font-family: var(--font-sans); font-size: 20px; font-weight: 600; }
.modal__status { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.modal__status.is-done { color: var(--primary); }
.modal__desc { margin-top: 12px; font-size: 15px; line-height: 1.55; color: var(--muted); }
.modal .field-label { margin-top: 20px; }
.modal__code-row { display: flex; gap: 8px; margin-top: 8px; }
.modal__code-row .input-wrap { flex: 1; }
.modal__note { margin-top: 16px; text-align: center; font-size: 12px; color: var(--muted); }

/* Feedback boxes inside modal */
.feedback { margin-top: 16px; padding: 16px; border-radius: var(--radius); font-size: 14px; }
.feedback.is-ok {
  border: 1px solid rgba(94, 122, 103, 0.3);
  background: rgba(94, 122, 103, 0.08);
  color: var(--ink);
}
.feedback.is-ok strong { color: var(--primary); }
.feedback.is-bad {
  border: 1px solid rgba(192, 91, 77, 0.3);
  background: rgba(192, 91, 77, 0.05);
  color: var(--ink);
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ---- 5. Page: Final --------------------------------------- */
.final-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  text-align: center;
  position: relative;
}
.final__title {
  margin-top: 22px;
  font-family: var(--font-sans);
  font-size: 30px;
  letter-spacing: 0.04em;
  color: var(--ink);
}
.final__subtitle { margin-top: 8px; font-size: 15px; color: var(--muted); }
.final__coord { margin-top: 18px; font-size: 23px; }
.final__reveal { margin-top: 28px; }
.destination { margin-top: 28px; animation: pop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2); }
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.destination__box {
  border: 1px solid rgba(94, 122, 103, 0.3);
  background: rgba(94, 122, 103, 0.08);
  border-radius: var(--radius);
  padding: 22px;
}
.destination__name { margin-top: 8px; font-family: var(--font-sans); font-size: 24px; color: var(--ink); }
.destination__coord { margin-top: 4px; font-size: 14px; color: var(--muted); }
.final__maps { margin-top: 16px; }
.final__home { display: inline-block; margin-top: 22px; font-size: 14px; color: var(--muted); }
.final__home:hover { color: var(--ink); }

/* Final — locked view */
.final-locked { text-align: center; max-width: 340px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding: 6px 16px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 99px;
  font-size: 14px;
  color: var(--muted);
}
.final-locked__title { margin-top: 16px; font-family: var(--font-sans); font-size: 24px; }
.final-locked__text { margin-top: 8px; font-size: 15px; color: var(--muted); }
.final-locked .coord { margin-top: 16px; }
.final-locked__back { margin-top: 32px; }
