/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Comfortaa:wght@400;700&display=swap');

/* ==========================================================================
   1. CSS VARIABLES (The Kinced "Calm" Design System)
   ========================================================================== */
:root {
  /* Colors */
  --bg-canvas: #F9F8F6;       /* Warm, paper-like off-white for the body */
  --bg-surface: #FFFFFF;      /* Pure white for cards/modals */
  --text-ink: #2C2C2C;        /* Soft black for readability */
  --text-muted: #737373;      /* Grey for secondary text/timestamps */
  --accent-navy: #1B365D;     /* Premium textbook navy for primary accents */
  --accent-blue: #4A90E2;     /* Technical light blue for secondary links */
  --border-light: #EBEBEB;    /* Very subtle dividers */
  
  /* Random Avatar Base Colors (Low saturation) */
  --avatar-1: #E2E8F0;
  --avatar-2: #FDE68A;
  --avatar-3: #FED7AA;
  --avatar-4: #A7F3D0;
  --avatar-5: #FECACA;

  /* Typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-editorial: "Georgia", "Times New Roman", serif;
  --font-fun: 'Comfortaa', sans-serif;

  /* Safe Area Insets (for iPhone notches/home indicators) */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Three-pane shell sizing */
  --app-header-height: 64px;
  --center-pane-width: 100%;
  --center-pane-min-width: 0px;
  --side-pane-width: 100vw;
  --side-pane-min-width: 0px;
}

/* ==========================================================================
   2. NATIVE APP RESET & DEFAULTS
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-ui);
  color: var(--text-ink);
  background-color: var(--bg-canvas);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  
  /* Crucial for native feel: removes the blue flash on iOS taps */
  -webkit-tap-highlight-color: transparent; 
}

body {
  margin: 0;
  padding: 0;
  /* Prevent pull-to-refresh bounce on the whole body (we will allow scroll in the container) */
  overscroll-behavior-y: none; 
  
  /* Global Background Image Integration */
  /* 
  background-image: linear-gradient(rgba(249, 248, 246, 0.75), rgba(249, 248, 246, 0.75)), url('/kinced_social_background.webp');
  background-position: top left;
  background-attachment: fixed;
  background-repeat: repeat;
  */
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-fun);
  font-weight: 700; /* Comfortaa looks great bold for headings */
  margin: 0 0 0.5rem 0;
  color: var(--text-ink);
}

p {
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

a {
  color: var(--accent-navy);
  text-decoration: none;
}

/* Utility class for upcoming chat bubbles */
.chat-text {
  font-family: var(--font-fun);
  font-weight: 400;
}

/* Prevent highlighting UI elements like native apps */
button, .unselectable {
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

/* ==========================================================================
   3. LAYOUT (Desktop Scaling Strategy: 3-Pane 33% Split)
   ========================================================================== */

/* Global Layout Manager (Gesture & Flex Wrapper) */
.layout-manager {
  position: relative;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 
  The center feed. 100% on mobile, exactly 33.33% on desktop.
*/
.app-container {
  width: var(--center-pane-width);
  min-width: var(--center-pane-min-width);
  min-height: 100vh;
  padding-top: var(--app-header-height);
  background-color: var(--bg-surface);
  display: flex;
  flex-direction: column;
  margin: 0 auto;
}

/* Side Panels (Drawers) */
.side-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  width: var(--side-pane-width);
  min-width: var(--side-pane-min-width);
  background: var(--bg-surface);
  z-index: 40;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 20px rgba(0,0,0,0.1);
  padding-top: var(--app-header-height);
  overscroll-behavior: none;
}

.side-panel.left {
  left: 0;
  transform: translateX(-100%);
}

.side-panel.right {
  right: 0;
  transform: translateX(100%);
}

.side-panel.open {
  transform: translateX(0);
}

.panel-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-ink);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.side-panel-content {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior-y: none;
  padding: 1rem;
}

@media (min-width: 1024px) {
  :root {
    --center-pane-width: 40vw;
    --center-pane-min-width: 400px;
    --side-pane-width: 30vw;
    --side-pane-min-width: 300px;
  }

  .app-container {
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.03);
  }

  .side-panel {
    box-shadow: none;
    border-left: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
  }
}

/* App Content Area */
.app-main {
  flex: 1;
  padding: 1rem;
  padding-top: calc(var(--safe-top) + 1rem); /* Push down below notches */
  padding-bottom: calc(var(--safe-bottom) + 2rem); /* Push up above home bar */
  overflow-y: auto;
}

/* Modifiers for static pages */
.page-content {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  padding-top: calc(var(--safe-top) + 2rem);
}

.text-center {
  text-align: center;
}

/* ==========================================================================
   4. HEADER & FOOTER
   ========================================================================== */
.app-header {
  position: fixed;
  top: 0;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  margin: 0 auto;
  width: var(--center-pane-width);
  min-width: var(--center-pane-min-width);
  z-index: 50;
  background-color: var(--bg-surface);
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--app-header-height);
}

.header-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 40px; /* Balances the right side */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.header-center {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.header-right {
  width: 40px; /* Balances the left side */
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.header-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.header-logo {
  width: 30px;
  height: 30px;
}

.header-title {
  font-size: 1.4rem;
  margin: 0;
  font-weight: bold;
  font-family: var(--font-fun);
  letter-spacing: -0.5px;
  line-height: 1;
}

.text-navy { color: var(--accent-navy); }
.text-blue { color: var(--accent-blue); }

.app-footer {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-links {
  margin-bottom: 1rem;
}

.copyright {
  font-size: 0.75rem;
  opacity: 0.7;
  display: block;
}

/* ==========================================================================
   5. BASE UI COMPONENTS & APP.JSX STYLES
   ========================================================================== */

/* Editorial Button */
.btn-primary {
  background-color: var(--text-ink);
  color: var(--bg-surface);
  border: none;
  border-radius: 4px; /* Very subtle rounding, not pill-shaped */
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-family: var(--font-ui);
  transition: opacity 0.2s ease;
}

.btn-primary:active {
  opacity: 0.7; /* Native mobile touch feedback */
}

/* The Circular Avatar */
.avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: var(--text-ink);
  border: 2px solid var(--text-ink);
}

.avatar-circle.unauthenticated {
  background-color: var(--border-light);
}

/* Search Row */
.search-location-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 1.5rem;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background-color: #F0F0F0;
  border-radius: 8px;
  padding: 10px 14px;
}

.search-input {
  border: none;
  background: transparent;
  flex: 1;
  outline: none;
  font-size: 1rem;
  color: var(--text-ink);
}

.search-icon {
  color: var(--text-muted);
  cursor: pointer;
}

.location-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 70px;
}

.pin-icon {
  width: 30px;
  height: 30px;
}

.location-text {
  font-size: 0.75rem;
  color: var(--accent-blue);
  margin-top: 4px;
  text-decoration: underline;
  cursor: pointer;
}

/* Date Carousel */
.date-carousel {
  display: flex;
  overflow-x: auto;
  gap: 10px;
  padding-bottom: 15px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 1.5rem;
  -ms-overflow-style: none;  /* IE and Edge */
  scrollbar-width: none;  /* Firefox */
}

.date-carousel::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

.date-tab {
  padding: 8px 18px;
  background-color: transparent;
  color: var(--text-ink);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  white-space: nowrap;
  scroll-snap-align: center;
  cursor: pointer;
}

.date-tab.active {
  background-color: var(--text-ink);
  color: var(--bg-surface);
  border-color: var(--text-ink);
  font-weight: bold;
}

/* Event Feed */
.event-feed {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.event-card {
  padding: 1.25rem;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background-color: var(--bg-surface);
  box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.event-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  font-weight: bold;
}

.event-meta {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.event-location {
  margin: 0 0 0.75rem 0;
  font-size: 0.95rem;
}

.event-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.event-attendees {
  font-size: 0.85rem;
  color: var(--accent-blue);
  font-weight: bold;
}
