/* jhacal-path-layout.css — 042026.1.67 */
/* [g67 Session 63 — Batch 7 Part C] L11-3 §6 closure: `.path-selector-title`
   swapped from `color: var(--accent)` → `color: var(--accent-text)` so
   heading text consumes the AA-compliant 7.29:1 link-text token instead
   of the 3:1-UI fill token. No fills/strokes changed. */
/* =====================================================
   JHACAL PATH LAYOUT SYSTEM
   Single authoritative source for all Path-Lite visual CSS.
   Merged from jhacal-path-layout.css + HTML <style> block.
   All conflicts resolved — no rule is overridden elsewhere.
   ===================================================== */


/* =====================================================
   BASE LAYOUT — LAUNCH OVERLAY
   ===================================================== */

.pl-launch-facade {
  position: fixed;
  inset: 0;
  background: #1a1d21;
  background: linear-gradient(135deg, #1a1d21 0%, #272b31 50%, #1a1d21 100%);
  display: flex;
  z-index: 10000;
  justify-content: center;
  align-items: center;
  padding: 24px;
}
.pl-launch-facade.hidden { display: none; }

.pl-launch-card {
  background: #1f2328;
  backdrop-filter: blur(20px);
  border: 2px solid #ff9800;
  border-radius: 24px;
  padding: 48px;
  max-width: 700px;
  width: 100%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7), 0 0 60px rgba(255, 152, 0, 0.15);
  animation: plLaunchFadeIn 0.4s ease-out;
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@supports not (backdrop-filter: blur(20px)) {
  .pl-launch-card { background: #1f2328; }
}

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

.pl-launch-logo {
  height: 80px;
  margin-bottom: 24px;
  border-radius: 12px;
}

.pl-launch-title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #f6c177, #ff9800);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 12px 0;
}

.pl-launch-subtitle {
  font-size: 1.1rem;
  color: #9ca3af;
  margin: 0 0 32px 0;
  font-style: italic;
}


/* =====================================================
   LAUNCH TILE GRID
   ===================================================== */

.pl-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 6px;
}

.pl-tile {
  background: linear-gradient(135deg, rgba(91, 141, 87, 0.15), rgba(91, 141, 87, 0.05));
  border: 2px solid rgba(91, 141, 87, 0.3);
  border-radius: 16px;
  padding: 24px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 140px;
  position: relative;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

/* CRITICAL: pointer-events:none prevents pseudo-element overlay from
   intercepting touch events on iOS Safari. */
.pl-tile::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  transition: left 0.5s ease;
  pointer-events: none;
}
.pl-tile:hover::before { left: 100%; }

.pl-tile:hover {
  background: linear-gradient(135deg, rgba(91, 141, 87, 0.25), rgba(91, 141, 87, 0.15));
  border-color: #5B8D57;
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(91, 141, 87, 0.3);
}

.pl-tile.tutorial-tile {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05));
  border-color: rgba(59, 130, 246, 0.3);
}
.pl-tile.tutorial-tile:hover {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(59, 130, 246, 0.15));
  border-color: #3b82f6;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.3);
}

.pl-tile.why-tile {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 152, 0, 0.05));
  border-color: rgba(255, 152, 0, 0.3);
}
.pl-tile.why-tile:hover {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.25), rgba(255, 152, 0, 0.15));
  border-color: #ff9800;
  box-shadow: 0 8px 24px rgba(255, 152, 0, 0.3);
}

.pl-tile-icon {
  font-size: 2.5rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}
.pl-tile-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #e5e7eb;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.pl-tile-desc {
  font-size: 0.9rem;
  color: #9ca3af;
  line-height: 1.4;
}


/* =====================================================
   PATH SELECTOR MODAL
   ===================================================== */

.path-selector-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10002;
  padding: 24px;
}
.path-selector-modal.active { display: flex; }

.path-selector-content {
  background: var(--bg-1);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 32px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.path-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.path-selector-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-text); /* [g67 L11-3 §6] link/heading TEXT uses --accent-text (AAA 7.29 on dark bg-1); --accent stays for fills/strokes only */
  margin: 0;
}

.path-selector-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s;
}
.path-selector-close:hover {
  background: var(--bg-3);
  color: var(--text-1);
}

.path-list-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.path-list-item {
  background: var(--bg-2);
  border: 2px solid var(--bg-3);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.path-list-item:hover {
  background: var(--bg-3);
  border-color: var(--accent);
  transform: translateX(4px);
}
.path-list-item.active {
  border-color: var(--gold);
  background: rgba(255, 152, 0, 0.1);
}

.path-list-icon { font-size: 2rem; flex-shrink: 0; }
.path-list-info { flex: 1; }
.path-list-name { font-size: 1.1rem; font-weight: 600; color: var(--text-1); margin: 0 0 4px 0; }
.path-list-desc { font-size: 0.9rem; color: var(--text-2); margin: 0; }
.path-list-empty { text-align: center; padding: 48px 24px; color: var(--text-2); }


/* =====================================================
   UTILITY BUTTONS
   ===================================================== */

.utility-buttons {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
  padding: 16px 16px 12px 16px;
  max-width: 1200px;
  margin: 0 auto;
  border-top: 1px solid rgba(91, 141, 87, 0.15);
  position: relative;
}

.utility-buttons::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(91, 141, 87, 0.3), transparent);
}

.utility-btn {
  flex: 1;
  background: linear-gradient(135deg, rgba(31, 35, 40, 0.6), rgba(31, 35, 40, 0.4));
  border: 1.5px solid rgba(91, 141, 87, 0.2);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  color: var(--text-1);
  min-height: 100px;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.utility-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 50%, rgba(91, 141, 87, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 50%, rgba(59, 130, 246, 0.02) 0%, transparent 50%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.utility-btn:hover::before { opacity: 1; }

.utility-btn:hover {
  background: linear-gradient(135deg, rgba(91, 141, 87, 0.15), rgba(91, 141, 87, 0.08));
  border-color: rgba(91, 141, 87, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(91, 141, 87, 0.1);
}
.utility-btn:active { transform: translateY(0); }

.utility-btn-icon {
  font-size: 2rem;
  line-height: 1;
  opacity: 0.85;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
  transition: all 0.25s ease;
}
.utility-btn:hover .utility-btn-icon { opacity: 1; transform: scale(1.05); }

.utility-btn-name {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  color: rgba(229, 231, 235, 0.9);
}
.utility-btn-desc {
  font-size: 0.8rem;
  color: var(--text-2);
  text-align: center;
  opacity: 0.7;
}


/* =====================================================
   MAIN STAGE — AUTHORITATIVE LAYOUT
   Single definition. Replaces both the old layout CSS
   .path-stage and the HTML <style> override.
   ===================================================== */

.path-stage {
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 40px);
  overflow-y: auto;           /* was hidden — clipped toolbar on short viewports */
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, #1a1d21 0%, #272b31 100%);
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  /* Respect device safe areas (iOS notch, Android navigation) */
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}


/* =====================================================
   HEADER
   ===================================================== */

.path-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  padding-top: calc(16px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--bg-2), #242830);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(91, 141, 87, 0.15);
}

.path-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.path-logo {
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}
.path-logo:hover { transform: scale(1.05); }

.path-title {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f6c177, #ff9800);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.path-tools {
  display: flex;
  gap: 4px;
}

.tool-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(245, 166, 35, 0.50);
  background: rgba(49, 55, 64, 0.4);
  color: var(--text-1);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.tool-btn:hover { background: var(--bg-3); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,.25); }
.tool-btn.active {
  background: #ffc107;
  border-color: #ffc107;
  color: #000;
}

.tool-btn:focus,
.toolbar-btn:focus,
.path-tile:focus {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* D-P-1: Tooltip appears below button to prevent overflow off top of viewport */
.tool-btn::after {
  bottom: auto;
  top: calc(100% + 8px);
}


/* =====================================================
   EDIT MODE BANNER
   ===================================================== */

.edit-mode-banner {
  flex-shrink: 0;
  display: none;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1));
  border: 2px solid rgba(59, 130, 246, 0.5);
  border-left: none;
  border-right: none;
  padding: 12px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: #60a5fa;
  animation: pulseGlow 2s ease-in-out infinite;
}
.edit-mode-banner.visible { display: block; }


/* =====================================================
   SCAN MODE INDICATOR
   ===================================================== */

.scan-mode-indicator {
  flex-shrink: 0;
  display: none;
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.25), rgba(255, 152, 0, 0.15));
  border: 2px solid #ff9800;
  border-left: none;
  border-right: none;
  padding: 12px 16px;
  text-align: center;
  font-weight: 700;
  font-size: 1rem;
  color: #ff9800;
  animation: pulseGlow 2s ease-in-out infinite;
  box-shadow: 0 4px 12px rgba(255, 152, 0, 0.3);
}
.scan-mode-indicator.visible { display: block; }

@keyframes pulseGlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}


/* =====================================================
   BREADCRUMB
   ===================================================== */

.path-breadcrumb {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--text-2);
  min-height: 32px;
  flex-shrink: 0;
}

.path-crumb {
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  transition: all 0.2s;
}
.path-crumb:hover { background: var(--bg-3); color: var(--gold); }
.path-crumb:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.path-crumb.current { color: var(--gold); font-weight: 700; }
.path-sep { color: var(--border); }


/* =====================================================
   TILE GRID
   ===================================================== */

.path-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 160px;
  gap: 10px;
  padding: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-content: center;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  padding-bottom: 16px;
}

/* Flexbox fallback for browsers without CSS Grid */
@supports not (display: grid) {
  .path-grid {
    display: flex !important;
    flex-wrap: wrap;
    margin: -8px;
  }
  .path-grid > * {
    flex: 1 1 200px;
    margin: 8px;
    min-width: 150px;
  }
}


/* =====================================================
   TILES
   ===================================================== */

.path-tile {
  background: var(--bg-3);
  border: 2px solid var(--gold);
  border-radius: 16px;
  height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 600;
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.3;
  position: relative;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}

.path-tile:hover,
.path-tile:focus {
  transform: scale(1.02);
  box-shadow: 0 4px 16px var(--gold-glow);
  outline: none;
}

.path-tile.has-children::after {
  content: '▼';
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-size: 0.75rem;
  color: var(--gold);
  opacity: 0.8;
}

.path-tile .icon  { font-size: 2rem; }
.path-tile .label { font-size: 1.3rem; padding: 0 4px; }
.path-tile .detail {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: 600;
  margin-top: 2px;
}

.path-tile.editing {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 12px var(--gold-glow);
}

/* Ensure ALL pseudo-element overlays pass through touch events */
.pl-tile::before,
.pl-tile::after,
.tile::before,
.tile::after,
.path-tile::before,
.path-tile::after,
button::before,
button::after {
  pointer-events: none;
}


/* =====================================================
   FOOTER TOOLBAR
   ===================================================== */

.path-toolbar {
  display: flex;
  flex-wrap: wrap;             /* wrap buttons instead of overflowing */
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding-top: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  padding-left: 14px;
  padding-right: 14px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  flex-shrink: 0;
}

.toolbar-btn {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid rgba(255, 152, 0, 0.4);
  background: rgba(255, 152, 0, 0.1);
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
  min-height: 48px; /* WCAG minimum touch target */
}
.toolbar-btn:hover { background: rgba(255, 152, 0, 0.2); }

.toolbar-btn.primary {
  background: var(--gold);
  color: #111;
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(91, 141, 87, 0.2);
}
.toolbar-btn.primary:hover { background: var(--gold-light); }

.toolbar-btn, .utility-btn {
  min-height: 48px; /* WCAG minimum touch target */
}


/* =====================================================
   MODAL OVERLAY Z-INDEX (ensures modals clear launch screen)
   ===================================================== */

.modal-overlay { z-index: 10001; }


/* =====================================================
   PLATFORM-SPECIFIC CSS
   Classes applied to <body> by platform-detection.js
   ===================================================== */

/* iOS-SPECIFIC: Prevent callout on long-press */
.platform-ios .path-grid .tile {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
}

/* iOS-SPECIFIC: Fix momentum scrolling */
.platform-ios .path-grid {
  -webkit-overflow-scrolling: touch;
}

/* iOS-SPECIFIC: Remove 300ms tap delay and prevent double-tap-to-zoom.
   touch-action:manipulation is the single most important CSS property
   for making buttons responsive on iPad. */
.platform-ios button,
.platform-ios .pl-tile,
.platform-ios .toolbar-btn,
.platform-ios .nav-btn,
.platform-ios .utility-btn,
.platform-ios .tile {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 152, 0, 0.2);
}

/* Grid tiles also need touch-action for iPad responsiveness */
.path-tile {
  touch-action: manipulation;
}

/* ANDROID-SPECIFIC: Reduce tap highlight */
.platform-android .path-grid .tile {
  -webkit-tap-highlight-color: transparent;
}

/* CROSS-PLATFORM: Minimum touch target 44x44px (WCAG) */
.has-touch .tile,
.has-touch .toolbar-btn,
.has-touch .btn,
.has-touch button {
  min-width: 44px;
  min-height: 44px;
}


/* =====================================================
   SAFE AREA — iOS NOTCHED DEVICES
   Requires <meta viewport-fit=cover> (already present in HTML)
   ===================================================== */

.has-safe-area .path-stage,
.has-safe-area .pl-launch-facade {
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.has-safe-area .path-toolbar {
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
}

/* Fallback for browsers without safe-area support */
@supports not (padding: env(safe-area-inset-top)) {
  .has-safe-area .path-stage,
  .has-safe-area .pl-launch-facade {
    padding-top: 0;
  }
  .has-safe-area .path-toolbar {
    padding-bottom: 32px;
  }
}


/* =====================================================
   RESPONSIVE BREAKPOINTS
   ===================================================== */

@media (max-width: 768px) {
  .pl-launch-card { padding: 32px 24px; }
  .pl-launch-title { font-size: 1.8rem; }
  .pl-tile-grid { grid-template-columns: 1fr; }

  .utility-btn-desc { font-size: 0.75rem; }
  .utility-btn { min-height: 90px; padding: 12px; }
  .toolbar-btn { padding: 12px 16px; font-size: 0.95rem; }
}

@media (max-width: 600px) {
  .pl-launch-card { padding: 24px 16px; }
  .pl-tile-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pl-tile { min-height: 100px; padding: 16px 10px; }
  /* ── Keep utility buttons side-by-side on mobile — column layout made them too tall ── */
  .utility-buttons { flex-direction: row; padding: 10px 12px 8px 12px; gap: 8px; }
  .utility-btn {
    min-height: 56px;
    padding: 10px 8px;
    /* Increase scroll-to-tap threshold to reduce missed taps on iPhone */
    touch-action: manipulation;
  }
  .utility-btn-icon { font-size: 1.4rem; }
  .utility-btn-name { font-size: 0.85rem; }
  .utility-btn-desc { display: none; } /* hide description on small screens */
  .path-grid { grid-template-columns: 1fr; }
  .path-tile { height: 120px; }
  .toolbar-btn { padding: 8px 10px; font-size: 0.9rem; min-height: 44px; }
}

/* Tablet portrait & short viewports — compact vertical spacing */
@media (max-height: 800px) {
  .path-header { padding: 6px 14px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .path-breadcrumb { padding: 4px 14px; font-size: 0.8rem; }
  .utility-buttons { padding: 8px 14px 6px 14px; }
  .utility-btn { min-height: 60px; padding: 8px; }
  .utility-btn-icon { font-size: 1.3rem; }
  .utility-btn-desc { font-size: 0.7rem; }
  .path-toolbar {
    padding: 10px 14px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  .toolbar-btn { padding: 8px 14px; font-size: 0.85rem; }
}

/* Tablet landscape — prevent content cutoff */
@media (max-height: 600px) and (orientation: landscape) {
  .path-header {
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: 8px;
  }
  .utility-buttons { padding: 8px 16px 4px 16px; }
  .utility-btn { min-height: 56px; padding: 8px; }
  .utility-btn-icon { font-size: 1.3rem; }
  .path-toolbar {
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
  .toolbar-btn { padding: 8px 12px; font-size: 0.85rem; }
}
