/*1. GLOBAL VARIABLES & RESETS*/
:root {
  --top-height: 56px;
  --bottom-height: 65px; 
  --filter-bar-height: 30px;

  /* Z-Index Management */
  --z-index-pull-to-refresh: 998;
  --z-index-header: 999;
  --z-index-tab-nav: 999;
  --z-index-suggestions: 9999;
  --z-index-story-viewer: 10000; /* --- NEW: z-index for story viewer --- */
  --z-index-drawer-overlay: 9998;
  --z-index-drawer: 9999;
  --z-index-page-loader: 9997;
  --z-index-splash-screen: 99999;
  --z-index-pwa-toast: 10005;
}

html {
  box-sizing: border-box;
  height: 100%;
  background: var(--bg-primary);
  overscroll-behavior-y: none; /* Prevent pull-to-refresh and rubber-band scrolling */
}

*, *::before, *::after {
  box-sizing: inherit;
}

body {
  font-family: 'Noto Sans', sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Top Navigation */
nav.top-navigation {
  height: var(--top-height);
  background-color: var(--bg-primary);
  z-index: var(--z-index-header);
}

/* banners etc */
header.header-view-area {
  margin-top: var(--top-height);
/*background-color: white;
  padding: var(--filter-bar-height);*/
}

/* Individual Page Views (multi-page support) */
.page-view-area {
  flex: 1 0 auto;
  flex-direction: column;
  margin-bottom: var(--bottom-height);
  position: relative;
  left: 0;
  right: 0;
  min-height: calc(100vh - var(--top-height) - var(--bottom-height));
  display: none; /* Hidden by default */
  pointer-events: none; /* Disable interactions for inactive views */
  transition:
    opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.page-view-area.view-active {
  display: flex; /* Show when active */
  background: var(--bg-primary);
  pointer-events: auto; /* Enable interactions for the active view */
}

/* Footer */
footer.footer-view-area {
  margin-bottom: var(--bottom-height);
/*background-color: #e0e0e0;
  padding: var(--footer-height);*/
}

/* Bottom Navigation */
nav.bottom-navigation {
  height: var(--bottom-height);
  background-color: var(--bg-primary);
  z-index: var(--z-index-tab-nav);
}


/* 3. VIEW LOADER */
.view-loading {
  position: fixed;
  top: var(--top-height);
  bottom: var(--bottom-height);
  left: 0;
  width: 100%;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-index-page-loader);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.3s ease, visibility 0s linear 0s;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(var(--accent-primary-rgb), 0.2);
  border-top: 4px solid var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 4. PULL TO REFRESH */
#pullToRefresh {
  position: fixed;
  left: 0;
  right: 0;
  top: -60px;
  height: var(--top-height);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: top 0.3s ease;
  z-index: var(--z-index-pull-to-refresh);
}

#pullToRefresh .material-icons {
  font-size: 36px;
  color: #2563eb;
  transition: transform 0.25s ease-out;
  transform: rotate(0deg); /* Initial state for arrow */
}

.spinning {
  animation: spin 1s linear infinite;
}

/* 5. SEARCH SUGGESTIONS */
.search-suggestions {
  position: absolute; 
  top: 100%; 
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  box-shadow: 0 0 8px var(--shadow-color);
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  max-height: 60vh;
  overflow-y: auto;
  display: none;
  z-index: var(--z-index-suggestions);
  list-style: none;
  padding: 0;
  margin: 0;
}

.suggestion-item {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out;
  font-size: 0.95rem;
  color: var(--text-secondary);
  border: none;
}

.suggestion-item:hover,
.suggestion-item.active-suggestion {
  background-color: var(--bg-tertiary);
}

.suggestion-item > span:first-child {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
}

ul#search-suggestions .suggestion-item .suggestion-icon {
  margin-right: 16px;
  color: var(--text-tertiary);
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  display: inline-block;
}

.highlight {
  font-weight: 700;
  color: var(--accent-primary);
}

.suggestion-item .fa-arrow-up {
  transform: rotate(-90deg);
  transition: transform 0.2s ease-in-out, color 0.2s ease-in-out;
  color: var(--text-tertiary);
}

.suggestion-item:hover .fa-arrow-up,
.suggestion-item.active-suggestion .fa-arrow-up {
  transform: rotate(-90deg) scale(1.15);
  color: var(--accent-primary);
}

.suggestion-item .fa-arrow-up::before {
  font-family: "Font Awesome 6 Free";
  content: "\f124"; /* fa-location-arrow */
  font-weight: 900;
}

/* 6. PWA INSTALL PROMPT TOAST */
.install-prompt-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(150%); /* Start off-screen */
  width: 90%;
  max-width: 380px;
  background-color: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: var(--z-index-pwa-toast);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  gap: 12px;
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
.install-prompt-toast.visible {
  transform: translateX(-50%) translateY(0); /* Slide into view */
}
.install-toast-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
  min-width: 0;
}
.install-toast-logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
}
.install-toast-text {
  display: flex;
  flex-direction: column;
}
.install-toast-text strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}
.install-toast-text span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.install-toast-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.install-toast-btn {
  padding: 6px 12px;
  border-radius: 6px;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.install-toast-btn.later {
  background-color: transparent;
  color: var(--text-secondary);
}
.install-toast-btn.later:hover {
  background-color: var(--bg-hover);
}
.install-toast-btn.install {
  background-color: var(--accent-primary);
  color: var(--accent-text);
}
.install-toast-btn.install:hover {
  background-color: var(--accent-primary-hover);
}

/* 7. SPLASH SCREEN */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-primary);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: var(--z-index-splash-screen);
  opacity: 1;
  transition: opacity 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.splash-content {
  text-align: center;
  transform: translateY(0);
  transition: transform 0.8s cubic-bezier(0.65, 0, 0.35, 1);
}

.splash-logo {
  width: min(30vw, 150px);
  height: min(30vw, 150px);
  margin-bottom: 20px;
  animation: 
    float var(--animation-duration) ease-in-out infinite,
    pulse calc(var(--animation-duration) * 1.5) ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.2));
}

.progress-container {
  width: min(80vw, 300px);
  height: 6px;
  background: rgba(255,255,255,0.2);
  border-radius: 3px;
  margin-top: 30px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width 0.3s ease;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.9; }
}

.splash-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Prevent zooming in standalone PWA mode */
html.standalone-no-zoom, 
html.standalone-no-zoom body, 
html.standalone-no-zoom * {
  touch-action: manipulation;
  text-size-adjust: 100%;
  user-select: none;
  -webkit-text-size-adjust: 100%; 
  -ms-text-size-adjust: 100%;
  -moz-text-size-adjust: 100%;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
 
}

/* 8. LAYOUT SWITCHING */
#default-layout {
  display: block;
  position: relative;
}

#fullscreen-layout {
    display: none;
    position: relative;
}

body.fullscreen-active #default-layout {
    display: none;
    position: relative;
}

body.fullscreen-active #fullscreen-layout {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: var(--bg-primary);
}

/* 9. GENERIC FULLSCREEN PAGE STRUCTURE */
.fullscreen-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.fullscreen-view-header {
    flex-shrink: 0;
}

.fullscreen-view-content {
    flex-grow: 1;
    overflow-y: auto;
}

.fullscreen-view-footer {
    flex-shrink: 0;
}
/* --- NEW: Global Clickable Link Style --- */
/* This class can be used anywhere to make text look like a clickable link. */
/* It uses global CSS variables for consistency. */
.clickable-link {
  color: var(--accent-primary);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
  transition: text-decoration 0.2s ease;
}

/* ==========================================================================
   Custom Alert Popup Styles
   ========================================================================== */

.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(30, 30, 30, 0.5); /* Semi-transparent dark overlay */
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.alert-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.alert-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    width: calc(100% - 40px);
    max-width: 320px;
    padding: 20px;
    text-align: center;
    border-top: 4px solid var(--accent-primary);
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.alert-overlay.visible .alert-box {
    transform: scale(1);
}

.alert-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 10px 0;
}

.alert-message {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0 0 20px 0;
}

.alert-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.alert-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
}

.alert-btn.primary {
    background: var(--accent-primary);
    color: var(--accent-text);
}

.alert-btn:active {
    transform: scale(0.96);
}