/* ============================================================
   The Blue Post — Calgary Events Hub
   Western Modern Design System
   ============================================================ */

/* --- Design Tokens --- */
:root {
  --sky-blue: #40C2F3;
  --sky-blue-light: #a8e4fa;
  --sky-blue-dark: #1a8abf;
  --bold-red: #EF3340;
  --bold-red-light: #f78c94;
  --bold-red-dark: #b8202b;

  --bg-primary: #faf9f7;
  --bg-card: #ffffff;
  --bg-card-hover: #f0f7fb;
  --bg-header: #1a1a2e;
  --bg-filter: #ffffff;
  --bg-modal: #ffffff;
  --bg-footer: #1a1a2e;

  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5a;
  --text-muted: #7a7a8a;
  --text-on-dark: #f0f0f5;
  --text-on-accent: #ffffff;

  --border-color: #e0ddd8;
  --border-strong: #c5c0b8;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.15);
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06), 0 0 0 1px rgba(0,0,0,0.04);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --font-heading: 'Roboto Slab', Georgia, serif;
  --font-body: 'Open Sans', system-ui, sans-serif;
  --font-dyslexia: 'OpenDyslexic', 'Comic Sans MS', sans-serif;

  --header-height: 72px;
  --card-texture: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M0 20h40M20 0v40' stroke='%23000' stroke-opacity='0.02' stroke-width='0.5'/%3E%3C/svg%3E");
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
  :root:not(.high-contrast):not(.force-light) {
    --bg-primary: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #22223a;
    --bg-header: #0a0a18;
    --bg-filter: #151528;
    --bg-modal: #1a1a2e;
    --bg-footer: #0a0a18;

    --text-primary: #e8e8f0;
    --text-secondary: #b0b0c0;
    --text-muted: #808098;
    --text-on-dark: #e8e8f0;

    --border-color: #2a2a40;
    --border-strong: #3a3a55;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-card: 0 2px 8px rgba(0,0,0,0.2), 0 0 0 1px rgba(255,255,255,0.04);

    --card-texture: url("data:image/svg+xml,%3Csvg width='40' height='40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h40v40H0z' fill='none'/%3E%3Cpath d='M0 20h40M20 0v40' stroke='%23fff' stroke-opacity='0.02' stroke-width='0.5'/%3E%3C/svg%3E");
  }
}

/* --- High Contrast Override --- */
.high-contrast {
  --bg-primary: #000000;
  --bg-card: #0a0a0a;
  --bg-card-hover: #1a1a1a;
  --bg-header: #000000;
  --bg-filter: #0a0a0a;
  --bg-modal: #0a0a0a;
  --bg-footer: #000000;

  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #c0c0c0;
  --text-on-dark: #ffffff;

  --border-color: #ffffff;
  --border-strong: #ffffff;
  --sky-blue: #5ad4ff;
  --bold-red: #ff4d5a;

  --shadow-card: 0 0 0 2px #ffffff;
}

/* --- Dyslexia Font --- */
.dyslexia-font,
.dyslexia-font * {
  font-family: var(--font-dyslexia) !important;
  letter-spacing: 0.05em;
  word-spacing: 0.12em;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- Skip Link --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--bold-red);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  z-index: 9999;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 1rem;
}

/* --- Header --- */
.site-header {
  background: var(--bg-header);
  border-bottom: 4px solid var(--bold-red);
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo h1 {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.75rem;
  color: var(--sky-blue);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.logo .tagline {
  font-size: 0.75rem;
  color: var(--text-on-dark);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
}

.header-controls {
  display: flex;
  gap: 0.5rem;
}

.a11y-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--text-on-dark);
  border: 1.5px solid rgba(255,255,255,0.25);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-family: var(--font-body);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.a11y-btn:hover,
.a11y-btn:focus-visible {
  border-color: var(--sky-blue);
  color: var(--sky-blue);
  background: rgba(64,194,243,0.08);
}

.a11y-btn[aria-pressed="true"] {
  background: var(--sky-blue);
  color: var(--bg-header);
  border-color: var(--sky-blue);
}

/* --- Filter Bar --- */
.filter-bar {
  background: var(--bg-filter);
  border-bottom: 2px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: var(--header-height);
  z-index: 90;
}

.filter-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-group label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.filter-group select,
.filter-group input {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-width: 160px;
  transition: border-color 0.2s;
}

.filter-group select:focus,
.filter-group input:focus {
  outline: none;
  border-color: var(--sky-blue);
  box-shadow: 0 0 0 3px rgba(64,194,243,0.15);
}

.filter-count {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* --- Events Grid --- */
.events-grid {
  max-width: 1280px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}

/* --- Event Card --- */
.event-card {
  background: var(--bg-card);
  background-image: var(--card-texture);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.event-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--sky-blue), var(--bold-red));
  opacity: 0;
  transition: opacity 0.25s;
}

.event-card:hover,
.event-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--sky-blue);
  background-color: var(--bg-card-hover);
}

.event-card:hover::before,
.event-card:focus-visible::before {
  opacity: 1;
}

.event-card:focus-visible {
  outline: 3px solid var(--sky-blue);
  outline-offset: 2px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--text-primary);
}

.card-category {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  white-space: nowrap;
}

.cat-family { background: #e8f5e9; color: #2e7d32; }
.cat-free { background: #e3f2fd; color: #1565c0; }
.cat-couple { background: #fce4ec; color: #c62828; }
.cat-outdoor { background: #fff3e0; color: #e65100; }

@media (prefers-color-scheme: dark) {
  :root:not(.high-contrast):not(.force-light) .cat-family { background: #1b3a1e; color: #81c784; }
  :root:not(.high-contrast):not(.force-light) .cat-free { background: #0d2940; color: #64b5f6; }
  :root:not(.high-contrast):not(.force-light) .cat-couple { background: #3c1520; color: #ef9a9a; }
  :root:not(.high-contrast):not(.force-light) .cat-outdoor { background: #3e2010; color: #ffb74d; }
}

.high-contrast .cat-family,
.high-contrast .cat-free,
.high-contrast .cat-couple,
.high-contrast .cat-outdoor {
  background: transparent;
  border: 2px solid currentColor;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.card-meta svg {
  flex-shrink: 0;
}

.card-date {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 600;
}

.card-time {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.card-location {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
}

.card-location svg {
  flex-shrink: 0;
  margin-top: 2px;
}

.card-bottom {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-color);
  gap: 0.5rem;
}

/* Sensory Rating */
.sensory-badge {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.sensory-dots {
  display: flex;
  gap: 3px;
}

.sensory-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--sky-blue);
  background: transparent;
  transition: background 0.2s;
}

.sensory-dot.filled {
  background: var(--sky-blue);
}

/* Access Icons */
.access-icons {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.access-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(64,194,243,0.1);
  color: var(--sky-blue);
  position: relative;
}

.access-icon.inactive {
  opacity: 0.3;
  color: var(--text-muted);
  background: rgba(128,128,128,0.08);
}

.access-icon svg {
  width: 16px;
  height: 16px;
}

.transit-score {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-on-accent);
  background: var(--sky-blue);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.featured-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--bold-red);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-content {
  background: var(--bg-modal);
  background-image: var(--card-texture);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
}

.modal-close:hover {
  background: var(--bold-red);
  color: #fff;
  border-color: var(--bold-red);
}

.modal-category {
  display: inline-block;
  margin-bottom: 0.75rem;
}

.modal-title {
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  padding-right: 2.5rem;
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modal-description {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

/* Modal Section Rows */
.modal-section {
  padding: 1rem 0;
  border-top: 1px solid var(--border-color);
}

.modal-section-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Sensory in Modal */
.modal-sensory {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-sensory-rating {
  display: flex;
  gap: 5px;
}

.modal-sensory-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--sky-blue);
  background: transparent;
}

.modal-sensory-dot.filled {
  background: var(--sky-blue);
}

.modal-sensory-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Access in Modal */
.modal-access-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.modal-access-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.modal-access-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-access-icon.yes {
  background: rgba(64,194,243,0.15);
  color: var(--sky-blue-dark);
}

.modal-access-icon.no {
  background: rgba(128,128,128,0.1);
  color: var(--text-muted);
}

/* Direction Buttons */
.modal-directions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dir-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border: 2px solid;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.dir-btn-drive {
  background: var(--bold-red);
  color: #fff;
  border-color: var(--bold-red);
}

.dir-btn-drive:hover {
  background: var(--bold-red-dark);
  border-color: var(--bold-red-dark);
}

.dir-btn-bus {
  background: var(--sky-blue);
  color: #fff;
  border-color: var(--sky-blue);
}

.dir-btn-bus:hover {
  background: var(--sky-blue-dark);
  border-color: var(--sky-blue-dark);
}

/* Website Link */
.modal-website {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--sky-blue);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.modal-website:hover {
  color: var(--sky-blue-dark);
  text-decoration: underline;
}

/* --- No Results --- */
.no-results {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}

.no-results svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.no-results p {
  font-size: 1.1rem;
}

/* --- Back to Top --- */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid var(--bold-red);
  background: var(--bold-red);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.25s;
  z-index: 80;
  opacity: 0;
  transform: translateY(10px);
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.back-to-top[hidden] {
  display: flex;
}

.back-to-top:hover {
  background: var(--bold-red-dark);
  border-color: var(--bold-red-dark);
  transform: translateY(-2px);
}

/* --- Footer --- */
.site-footer {
  background: var(--bg-footer);
  color: var(--text-on-dark);
  text-align: center;
  padding: 1.5rem;
  font-size: 0.85rem;
  border-top: 4px solid var(--bold-red);
  margin-top: 3rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
  }

  :root {
    --header-height: auto;
  }

  .filter-bar {
    position: relative;
    top: 0;
  }

  .filter-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filter-group select,
  .filter-group input {
    min-width: unset;
    width: 100%;
  }

  .filter-count {
    margin-left: 0;
  }

  .events-grid {
    grid-template-columns: 1fr;
    padding: 0 1rem;
    gap: 1rem;
    margin: 1rem auto;
  }

  .modal-content {
    padding: 1.5rem;
    max-height: 90vh;
  }

  .a11y-btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  .logo h1 {
    font-size: 1.35rem;
  }

  .modal-title {
    font-size: 1.25rem;
  }

  .modal-directions {
    flex-direction: column;
  }
}

/* --- Focus Visible --- */
:focus-visible {
  outline: 3px solid var(--sky-blue);
  outline-offset: 2px;
}

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--sky-blue);
}
