/* Puzzle Porch — hamburger, modals, sign-in pitch, and feed theme overrides.
   Uses the porch palette variables defined in thepuzzleporch.html:
   --sand, --sand-2, --sky, --sky-deep, --navy, --rope, --ink, --ink-soft,
   --border, --white, --green. Also uses per-game accents.
*/

/* ==========================================================================
   Hamburger button (fixed top-right)
   ========================================================================== */
.porch-menu-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--navy);
  border-radius: 12px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 60;
  box-shadow: 0 2px 8px rgba(37, 78, 107, 0.08);
  transition: transform 0.1s, box-shadow 0.1s;
}
.porch-menu-btn:hover { box-shadow: 0 4px 12px rgba(37, 78, 107, 0.12); }
.porch-menu-btn:active { transform: scale(0.96); }

/* ==========================================================================
   Dropdown menu
   ========================================================================== */
.porch-menu-dropdown {
  position: fixed;
  top: 64px;
  right: 12px;
  min-width: 240px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(37, 78, 107, 0.18);
  padding: 6px;
  z-index: 59;
  display: none;
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
.porch-menu-dropdown.open { display: block; }

.porch-menu-item {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: transparent;
  text-align: left;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
  min-height: 44px;
  box-sizing: border-box;
}
.porch-menu-item:hover { background: var(--sand); }
.porch-menu-item:focus-visible { outline: 2px solid var(--sky-deep); outline-offset: -2px; }
.porch-menu-item[data-primary="true"] {
  background: linear-gradient(135deg, var(--navy), var(--sky-deep));
  color: var(--white);
  font-weight: 600;
}
.porch-menu-item[data-primary="true"]:hover { opacity: 0.92; background: linear-gradient(135deg, var(--navy), var(--sky-deep)); }
.porch-menu-item[data-greeting="true"] {
  font-family: 'Caveat', cursive;
  font-size: 20px;
  color: var(--sky-deep);
  pointer-events: none;
  padding-bottom: 4px;
}
.porch-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}
.porch-menu-item[data-danger="true"] { color: #b14a3a; }

@media (max-width: 560px) {
  .porch-menu-dropdown { left: 12px; right: 12px; min-width: 0; }
}

/* ==========================================================================
   Sign-in pitch banner (hero)
   ========================================================================== */
.signin-pitch {
  width: 100%;
  max-width: 520px;
  margin: 10px 20px 0;
  padding: 14px 44px 14px 18px;
  background: linear-gradient(135deg, var(--navy), var(--sky-deep));
  color: var(--white);
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(37, 78, 107, 0.18);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
}
.signin-pitch strong { font-family: 'Lora', serif; font-weight: 600; font-size: 16px; }
.signin-pitch__copy { flex: 1 1 200px; }
.signin-pitch__cta {
  background: var(--rope);
  color: var(--navy);
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 38px;
  font-family: inherit;
}
.signin-pitch__cta:hover { opacity: 0.92; }
.signin-pitch__dismiss {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--white);
  opacity: 0.7;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}
.signin-pitch__dismiss:hover { opacity: 1; background: rgba(255,255,255,0.12); }
.signin-pitch[hidden] { display: none; }

/* ==========================================================================
   Modals (shared)
   ========================================================================== */
.porch-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(29, 53, 67, 0.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
  animation: porchFadeIn 0.15s ease;
}
@keyframes porchFadeIn { from { opacity: 0; } to { opacity: 1; } }

.porch-modal {
  background: var(--sand);
  color: var(--ink);
  width: 100%;
  max-width: 480px;
  border-radius: 18px;
  padding: 24px 22px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  animation: porchSlideUp 0.2s ease;
}
@keyframes porchSlideUp { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.porch-modal h2 {
  font-family: 'Lora', serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 6px;
}
.porch-modal h3 {
  font-family: 'Lora', serif;
  font-size: 18px;
  color: var(--navy);
  margin: 14px 0 6px;
}
.porch-modal p { font-size: 14px; line-height: 1.5; color: var(--ink-soft); }
.porch-modal__subtitle { margin-bottom: 16px; }

.porch-modal__close {
  background: var(--white);
  color: var(--navy);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  font-size: 14px;
}
.porch-modal__close:hover { background: var(--sand-2); }

.porch-modal__actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

@media (max-width: 560px) {
  .porch-modal-overlay { padding: 0; align-items: stretch; }
  .porch-modal { border-radius: 0; max-height: 100dvh; max-width: none; }
}

/* ==========================================================================
   Sign-in form
   ========================================================================== */
.porch-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--white);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--ink);
  margin-top: 8px;
  box-sizing: border-box;
  min-height: 44px;
}
.porch-field:focus { outline: 2px solid var(--sky-deep); outline-offset: -1px; }

.porch-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.porch-consent input { margin-top: 3px; }
.porch-consent a { color: var(--sky-deep); }

.porch-btn-primary {
  width: 100%;
  margin-top: 14px;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--navy), var(--sky-deep));
  color: var(--white);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  min-height: 48px;
  font-family: inherit;
}
.porch-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.porch-btn-primary:not(:disabled):hover { opacity: 0.94; }

.porch-btn-secondary {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--navy);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  font-size: 14px;
}
.porch-btn-secondary:hover { background: var(--sand-2); }

.porch-error { color: #b14a3a; font-size: 13px; margin-top: 8px; min-height: 18px; }

.porch-code-input {
  text-align: center;
  font-size: 26px;
  letter-spacing: 10px;
  font-weight: 700;
  padding: 14px;
}

/* ==========================================================================
   Stats modal
   ========================================================================== */
.porch-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.porch-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}
.porch-stat__value {
  font-family: 'Lora', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1;
}
.porch-stat__label {
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 4px;
}

.porch-pergame {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.porch-pergame__cell {
  background: var(--white);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}
.porch-pergame__cell b { color: var(--navy); display: block; font-size: 15px; }

/* ==========================================================================
   Trophy case
   ========================================================================== */
.porch-trophy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.porch-trophy {
  text-align: center;
  cursor: pointer;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 8px;
  transition: transform 0.1s;
}
.porch-trophy:hover { transform: translateY(-2px); }
.porch-trophy__visual {
  width: 56px;
  height: 56px;
  margin: 0 auto 8px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  position: relative;
  box-shadow: 0 3px 8px rgba(0,0,0,0.18);
}
.porch-trophy--maximizer .porch-trophy__visual { background: linear-gradient(135deg, #d4a843, #f5e6a3, #c9953c); color: #5c3f0f; font-family: 'Lora', serif; }
.porch-trophy--streak_7 .porch-trophy__visual { background: linear-gradient(135deg, #d4764a, #f5a862); color: var(--white); font-family: 'Lora', serif; }
.porch-trophy--puzzle_builder .porch-trophy__visual { background: linear-gradient(135deg, #d4a843, #f5e6a3); color: #5c3f0f; }
.porch-trophy--speed_demon .porch-trophy__visual { background: linear-gradient(135deg, #0ea5e9, #7c3aed); }
.porch-trophy--locked .porch-trophy__visual { background: var(--sand-2); color: var(--ink-soft); box-shadow: none; filter: grayscale(1); }
.porch-trophy__label { font-size: 12px; color: var(--ink); font-weight: 600; }
.porch-trophy__count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--rope);
  color: var(--navy);
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.porch-trophy-empty {
  padding: 24px 16px;
  text-align: center;
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: 14px;
  color: var(--ink-soft);
  font-size: 13px;
}

/* ==========================================================================
   Leaderboard
   ========================================================================== */
.porch-tabs {
  display: flex;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-top: 14px;
}
.porch-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink-soft);
  cursor: pointer;
  min-height: 44px;
  font-size: 14px;
}
.porch-tab[aria-selected="true"] { background: var(--navy); color: var(--white); }

.porch-lb {
  margin-top: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.porch-lb__row {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  padding: 10px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.porch-lb__row:last-child { border-bottom: none; }
.porch-lb__row--me { background: var(--sand); font-weight: 600; }
.porch-lb__rank { color: var(--ink-soft); font-weight: 600; font-size: 13px; }
.porch-lb__name { color: var(--navy); }
.porch-lb__score { color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; }
.porch-lb__empty { padding: 20px; text-align: center; color: var(--ink-soft); font-size: 13px; }
.porch-lb__foot {
  padding: 10px 14px;
  background: var(--sand);
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

/* ==========================================================================
   "From the archive" section heading
   ========================================================================== */
.from-archive {
  width: 100%;
  max-width: 520px;
  padding: 20px 20px 10px;
  margin-top: 6px;
}
.from-archive__title {
  font-family: 'Lora', serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 2px;
}
.from-archive__subtitle {
  font-family: 'Lora', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 12px;
}

/* Tune the shared puzzle-feed appearance for the porch */
#puzzleFeed .feed-section__title { display: none; }
#puzzleFeed .feed-section > .feed-list { padding: 0; }

/* Responsive widths for the archive section — matches porch hub breakpoints */
@media (min-width: 768px) {
  .from-archive { max-width: 960px; padding: 28px 28px 14px; }
  .from-archive__title { font-size: 28px; }
  .from-archive__subtitle { font-size: 15px; margin-bottom: 16px; }
}
@media (min-width: 1024px) {
  .from-archive { max-width: 1100px; padding: 32px 32px 16px; }
  .from-archive__title { font-size: 30px; }
  .from-archive__subtitle { font-size: 16px; margin-bottom: 20px; }
  /* 2-column feed grid on desktop */
  #puzzleFeed .feed-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }
  /* Sign-in promo card spans both columns so it stays prominent */
  #puzzleFeed .porch-feed-signin {
    grid-column: 1 / -1;
  }
}
@media (min-width: 1400px) {
  .from-archive { max-width: 1200px; }
}

/* Porch sign-in feed card (injected by porch-menu.js) */
.porch-feed-signin {
  background: linear-gradient(135deg, var(--navy), var(--sky-deep));
  color: var(--white);
  border-radius: 16px;
  padding: 18px 20px;
  margin: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(37, 78, 107, 0.14);
}
.porch-feed-signin h4 {
  font-family: 'Lora', serif;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}
.porch-feed-signin p {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;
  color: var(--white);
}
.porch-feed-signin .porch-feed-signin__cta {
  background: var(--rope);
  color: var(--navy);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
