/*
 * EITA PD Catalog — Stylesheet
 * Enqueue in Sage: app/setup.php → wp_enqueue_scripts
 * File: resources/assets/styles/pd-catalog.css
 * Only loaded on the PD Catalog page template
 */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;0,9..144,700&display=swap');

/* ── Variables ── */
:root {
  --teal:       rgb(34, 98, 95);
  --teal-dark:  rgb(24, 72, 70);
  --teal-light: #e3efee;
  --sand:       #e8dbc9;
  --sand-light: #f5f0e8;
  --sand-dark:  #d4c4ad;
  --bg:         #f4f6f8;
  --text-dark:  #1a2332;
  --text-mid:   #4b5563;
  --text-light: #4a4f59;
  --border:     #e5e7eb;
  --white:      #ffffff;

  --f2f-bg:  #e8dbc9; --f2f-col: #5a4a38;
  --lo-bg:   #e3efee; --lo-col:  rgb(24,72,70);
  --sp-bg:   #e0e7ff; --sp-col:  #3730a3;

  --act48-bg:  #fef9c3; --act48-col:  #854d0e;
  --clock-bg:  #ede9fe; --clock-col:  #6d28d9;
  --cat-bg:    #dcfce7; --cat-col:    #166534;
  --none-bg:   #f3f4f6; --none-col:   #374151;
}

/* ── Layout ── */
.pd-catalog-wrap {
  display: flex;
  max-width: 1380px;
  margin: 0 auto;
  gap: 1.5rem;
  padding: 1.5rem 1rem 2.5rem;
  font-family: 'DM Sans', sans-serif;
}

.pd-catalog-wrap .btn-secondary:hover {
  background: var(--border) !important;
  color: var(--text-dark) !important;
}

.pd-catalog-wrap .btn-secondary {
  color: var(--text-dark) !important;
}

/* ── Sidebar ── */
.pd-sidebar { width: 265px; flex-shrink: 0; }

.pd-sidebar-card {
  background: white;
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.pd-sidebar-card-title {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif;
}

/* S&F Pro form inside sidebar */
.pd-sidebar .searchandfilter > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.pd-sidebar .searchandfilter > ul > li {
  list-style: none;
  padding: 0;
  margin-bottom: 1.25rem;
}
.pd-sidebar .searchandfilter > ul > li:last-child { margin-bottom: 0; }

.pd-sidebar .searchandfilter > ul > li > h4 {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dark);
  margin-bottom: 0.6rem;
  display: block;
  font-family: 'DM Sans', sans-serif;
}

.pd-sidebar .searchandfilter > ul > li > ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pd-sidebar .searchandfilter > ul > li > ul > li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
  list-style: none;
}

.pd-sidebar .sf-input-checkbox {
  width: 15px;
  height: 15px;
  min-width: 15px;
  accent-color: var(--teal);
  flex-shrink: 0;
  cursor: pointer;
  margin: 0;
}

.pd-sidebar .sf-label-checkbox {
  font-size: 0.82rem;
  color: var(--text-mid);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-weight: 400;
  line-height: 1.4;
}

.pd-sidebar .sf-input-text {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 7px;
  font-size: 0.875rem;
  font-family: 'DM Sans', sans-serif;
  transition: border-color 0.2s;
}
.pd-sidebar .sf-input-text:focus { outline: none; border-color: var(--teal); }

.pd-sidebar .sf-field-submit input[type="submit"] {
  background: var(--teal);
  color: white;
  border: none;
  padding: 0.6rem 1rem;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  margin-top: 0.75rem;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s;
}
.pd-sidebar .sf-field-submit input[type="submit"]:hover { background: var(--teal-dark); }

/* Legend */
.pd-legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-mid);
  margin-bottom: 0.6rem;
  font-family: 'DM Sans', sans-serif;
}
.pd-legend-item:last-child { margin-bottom: 0; }

.pd-legend-icon {
  width: 36px; height: 36px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.pd-legend-f2f { background: var(--f2f-bg); }
.pd-legend-lo  { background: var(--lo-bg); }
.pd-legend-sp  { background: var(--sp-bg); }

/* ── Main content ── */
.pd-main { flex: 1; min-width: 0; }

.pd-results-bar {
  background: white;
  border-radius: 10px;
  padding: 0.85rem 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}
.pd-results-count {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text-mid);
  font-family: 'DM Sans', sans-serif;
}
.pd-results-count span { color: var(--text-dark); }

/* ── Course list ── */
.pd-course-list { display: flex; flex-direction: column; gap: 0.65rem; }

.course-row {
  background: white;
  border-radius: 10px;
  border: 2px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.course-row:hover { border-color: var(--teal); box-shadow: 0 2px 10px rgba(34,98,95,0.1); }
.course-row.open  { border-color: var(--teal); }

/* ── Course summary ── */
.course-summary {
  padding: 1rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fafafa;
  user-select: none;
}
.course-row.open .course-summary {
  background: white;
  border-bottom: 2px solid var(--teal-light);
}

/* Delivery icon */
.d-icon {
  width: 44px; height: 44px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.d-icon.f2f { background: var(--f2f-bg); }
.d-icon.lo  { background: var(--lo-bg); }
.d-icon.sp  { background: var(--sp-bg); }

.course-body { flex: 1; min-width: 0; }

.course-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.4rem;
}
.course-title {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.35;
  font-family: 'DM Sans', sans-serif;
  margin: 0;
}
.chevron {
  color: var(--text-light);
  font-size: 0.9rem;
  transition: transform 0.25s;
  flex-shrink: 0;
  margin-top: 3px;
  display: inline-block;
}
.course-row.open .chevron { transform: rotate(180deg); }

.course-meta {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.78rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
  font-family: 'DM Sans', sans-serif;
}
.meta-item { display: flex; align-items: center; gap: 0.25rem; }
.meta-item.zero-hours { color: #9ca3af; font-style: italic; }
.meta-item.zero-hours svg { stroke: #9ca3af; }

.badges { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge {
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.4;
  font-family: 'DM Sans', sans-serif;
}
.badge.act48  { background: var(--act48-bg); color: var(--act48-col); }
.badge.clock  { background: var(--clock-bg); color: var(--clock-col); }
.badge.cat    { background: var(--cat-bg);   color: var(--cat-col); }
.badge.none   { background: var(--none-bg);  color: var(--none-col); }
.badge.topic  { background: var(--sand);     color: #5a4a38; }

/* ── Expanded panel ── */
.course-panel { max-height: 0; overflow: hidden; transition: max-height 0.35s ease; }
.course-row.open .course-panel { max-height: 1400px; }

.panel-inner {
  padding: 1.25rem 1.5rem;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  font-family: 'DM Sans', sans-serif;
}

.reg-note {
  background: var(--sand-light);
  border: 1px solid var(--sand-dark);
  border-radius: 7px;
  padding: 0.65rem 0.9rem;
  font-size: 0.78rem;
  color: #5a4a38;
  line-height: 1.5;
}
.reg-note strong { font-weight: 600; }

.panel-desc { font-size: 0.875rem; color: var(--text-mid); line-height: 1.65; }
.panel-note { font-size: 0.78rem; color: var(--text-light); font-style: italic; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}
.panel-cell {
  background: var(--bg);
  border-radius: 7px;
  padding: 0.65rem 0.85rem;
  border-left: 3px solid var(--teal);
}
.panel-cell-label { font-size: 0.7rem; color: var(--text-light); margin-bottom: 0.2rem; }
.panel-cell-value { font-size: 0.875rem; font-weight: 600; color: var(--text-dark); }

.panel-cell.delivery-f2f { border-left-color: var(--f2f-col); background: #faf7f4; }
.panel-cell.delivery-lo  { border-left-color: var(--lo-col);  background: #f2f8f7; }
.panel-cell.delivery-sp  { border-left-color: var(--sp-col);  background: #f5f3ff; }
.panel-cell.delivery-f2f .panel-cell-value { color: var(--f2f-col); }
.panel-cell.delivery-lo  .panel-cell-value { color: var(--lo-col); }
.panel-cell.delivery-sp  .panel-cell-value { color: var(--sp-col); }

.panel-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.btn {
  padding: 0.6rem 1.25rem;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--bg); color: var(--text-dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.pd-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
}

/* WCAG 2.2 */
:focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; border-radius: 4px; }
:focus:not(:focus-visible) { outline: none; }

@media (max-width: 900px) {
  .pd-catalog-wrap { flex-direction: column; }
  .pd-sidebar { width: 100%; }
}

/* ══════════════════════════════════════════════════════
   WCAG 2.2 ADDITIONS
   ══════════════════════════════════════════════════════ */

/* Skip link (2.4.1) */
.pd-skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--teal);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0 0 7px 7px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  z-index: 9999;
  transition: top 0.2s;
}
.pd-skip-link:focus {
  top: 0;
}

/* Focus appearance — 2px minimum offset outline (2.4.11) */
:focus-visible {
  outline: 3px solid var(--teal) !important;
  outline-offset: 3px !important;
  border-radius: 4px !important;
}
:focus:not(:focus-visible) { outline: none; }

/* Course summary focus — needs to be visible on the row */
.course-summary:focus-visible {
  outline: 3px solid var(--teal) !important;
  outline-offset: -3px !important;
}

/* Minimum target size 24x24px (2.5.8) */
.btn {
  min-height: 44px;
  min-width: 44px;
}
.course-summary {
  min-height: 44px;
}

/* Legend as definition list */
.pd-legend {
  list-style: none;
  padding: 0;
  margin: 0;
}
.pd-legend .pd-legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.pd-legend .pd-legend-item:last-child { margin-bottom: 0; }

/* Panel grid as definition list */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 0;
}
.panel-grid dt { font-size: 0.7rem; color: var(--text-light); margin-bottom: 0.2rem; }
.panel-grid dd { font-size: 0.875rem; font-weight: 600; color: var(--text-dark); margin: 0; }

/* High contrast mode support */
@media (forced-colors: active) {
  .course-row { border: 2px solid ButtonText; }
  .badge { border: 1px solid ButtonText; }
  .btn { border: 2px solid ButtonText; }
}

/* ══════════════════════════════════════════════════════
   BASE FONT — applies to entire catalog page
   ══════════════════════════════════════════════════════ */
.pd-catalog-wrap,
.pd-catalog-wrap * {
  font-family: 'DM Sans', sans-serif;
}

.pd-catalog-wrap h1,
.pd-catalog-wrap h2,
.pd-catalog-wrap h3,
.pd-catalog-wrap h4,
.pd-catalog-wrap .course-title,
.pd-catalog-wrap .pd-sidebar-card-title {
  font-family: p22-mackinac-pro, sans-serif;
}

/* ══════════════════════════════════════════════════════
   BUTTON FIXES
   ══════════════════════════════════════════════════════ */
.btn-primary {
  color: white !important;
}
.btn-secondary:hover {
  background: var(--border);
  color: var(--text-dark) !important;
}

.panel-dates {
  background: var(--pd-bg);
  border-radius: 7px;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
}
.panel-dates-label {
  font-weight: 600;
  color: var(--pd-text-dark);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}
.panel-dates-row {
  color: var(--pd-text-mid);
  padding: 0.2rem 0;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* ══════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════ */
.pd-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.pd-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.pd-modal {
  background: var(--white);
  border-radius: 12px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: translateY(10px);
  transition: transform 0.2s ease;
  font-family: 'DM Sans', sans-serif;
}
.pd-modal-overlay.is-open .pd-modal {
  transform: translateY(0);
}

.pd-modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.pd-modal-title {
  font-family: p22-mackinac-pro, sans-serif !important;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.35;
  margin: 0;
}

.pd-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  color: var(--text-light);
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.pd-modal-close:hover {
  background: var(--bg);
  color: var(--text-dark);
}
.pd-modal-close:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.pd-modal-body {
  padding: 1.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.pd-modal-desc {
  font-size: 0.9rem;
  color: var(--text-mid);
  line-height: 1.65;
}

.pd-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.pd-modal-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

body.pd-modal-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .pd-modal {
    max-height: 95vh;
    border-radius: 12px 12px 0 0;
  }
  .pd-modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
}