:root {
  --navy:          #004990;
  --navy-dark:     #002f66;
  --pink:          #E20778;
  --orange:        #FCAF17;
  --cyan:          #41C3DC;
  --black:         #000000;
  --gray-100:      #f8f9fa;
  --gray-200:      #e9ecef;
  --gray-600:      #6c757d;
  --white:         #ffffff;
  --sidebar-width: 200px;
  --topbar-height: 52px;
  --font: "Avenir Next LT", "Avenir Next", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--black);
  font-size: 1rem;
  line-height: 1.5;
}

/* ── Password gate ─────────────────────────── */
#password-gate {
  position: fixed;
  inset: 0;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.gate-card {
  background: var(--white);
  padding: 2.5rem;
  border-radius: 8px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.gate-logo    { font-size: 1.2rem; font-weight: 700; color: var(--navy); margin-bottom: 0.25rem; }
.gate-subtitle { font-size: 0.85rem; color: var(--gray-600); margin-bottom: 1.5rem; }
.gate-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 4px;
  font-family: var(--font);
  font-size: 1rem;
  margin-bottom: 0.75rem;
  outline: none;
  transition: border-color 0.2s;
}
.gate-input:focus { border-color: var(--navy); }
.gate-button {
  width: 100%;
  padding: 0.75rem;
  background: var(--navy);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.gate-button:hover { background: var(--navy-dark); }
.gate-error { color: var(--pink); font-size: 0.85rem; margin-top: 0.75rem; }

/* ── Site shell ────────────────────────────── */
.site-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ───────────────────────────────── */
.top-bar {
  background: var(--navy);
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}
.top-bar .site-title   { color: var(--white); font-weight: 700; font-size: 1rem; }
.top-bar .academic-year { color: rgba(255,255,255,0.6); font-size: 0.85rem; }

/* ── Layout ────────────────────────────────── */
.layout {
  display: flex;
  margin-top: var(--topbar-height);
  min-height: calc(100vh - var(--topbar-height));
}

/* ── Sidebar ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  overflow-y: auto;
  padding: 1rem 0;
}
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.25rem;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.07); color: var(--white); }
.nav-item.active {
  color: var(--orange);
  border-left-color: var(--orange);
  background: rgba(255,255,255,0.07);
  font-weight: 600;
}
.sidebar-footer {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 0.5rem;
  margin-top: auto;
}

/* ── Main content ──────────────────────────── */
.content {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  flex: 1;
}

/* ── Cards ─────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card-header {
  font-size: 0.7rem;
  color: var(--navy);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
}

/* ── Dashboard ─────────────────────────────── */
.welcome-banner {
  background: var(--navy);
  color: var(--white);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.welcome-banner h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
.welcome-banner p  { opacity: 0.8; font-size: 0.9rem; }

.notice-alert {
  background: var(--white);
  border-left: 4px solid var(--pink);
  border-radius: 0 8px 8px 0;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 1.25rem;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.notice-alert:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.notice-alert .notice-label {
  font-size: 0.7rem;
  color: var(--pink);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}
.notice-alert .notice-title { font-size: 0.95rem; font-weight: 600; }

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.resource-link {
  display: block;
  color: var(--cyan);
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.2rem 0;
}
.resource-link:hover { text-decoration: underline; }

.event-item { display: flex; gap: 0.75rem; align-items: flex-start; margin-bottom: 0.75rem; cursor: pointer; border-radius: 4px; transition: background 0.15s; }
.event-item:hover { background: var(--gray-100); }
.date-badge {
  background: var(--navy);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  min-width: 40px;
  text-align: center;
  line-height: 1.3;
  flex-shrink: 0;
}
.date-badge.deadline { background: var(--pink); }
.event-title { font-size: 0.9rem; }
.event-title.deadline { color: var(--pink); font-weight: 600; }

/* ── Page headers ──────────────────────────── */
.page-header { margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--navy); }
.page-header h1 { font-size: 1.6rem; color: var(--navy); font-weight: 700; }

/* ── Resources page ────────────────────────── */
.resource-category { margin-bottom: 1.5rem; }
.category-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.resource-item {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.resource-item a { color: var(--cyan); font-weight: 600; text-decoration: none; }
.resource-item a:hover { text-decoration: underline; }
.resource-desc { font-size: 0.85rem; color: var(--gray-600); }

/* ── Notices page ──────────────────────────── */
.notice-item {
  background: var(--white);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.notice-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.notice-item.pinned { border-left-color: var(--pink); }
.notice-date  { font-size: 0.8rem; color: var(--gray-600); margin-bottom: 0.2rem; }
.notice-title { font-weight: 600; margin-bottom: 0.25rem; }
.notice-body  { font-size: 0.9rem; color: var(--gray-600); }

/* ── Notice dialog ─────────────────────────── */
.notice-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}
.notice-dialog-overlay.is-open {
  opacity: 1;
  visibility: visible;
}
.notice-dialog-box {
  background: var(--white);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
}
.notice-dialog-overlay.is-open .notice-dialog-box {
  transform: scale(1);
  opacity: 1;
}
.notice-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.notice-dialog-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0.2rem 0 0;
  color: var(--navy);
}
.notice-dialog-close {
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  color: var(--gray-600);
  padding: 0;
  flex-shrink: 0;
}
.notice-dialog-close:hover { color: var(--navy); }
.notice-dialog-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #374151;
}
.notice-dialog-body a { color: var(--cyan); word-break: break-all; }
.notice-dialog-body p { margin-bottom: 0.75rem; }
.event-dialog-entry { margin-bottom: 0.5rem; }
.event-dialog-entry strong { display: block; margin-bottom: 0.25rem; }
.event-dialog-sep { border: none; border-top: 1px solid var(--gray-200); margin: 0.75rem 0; }

/* ── Events page ───────────────────────────── */
.event-full-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: var(--white);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
}
.event-full-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.event-full-badge {
  background: var(--navy);
  color: var(--white);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  text-align: center;
  min-width: 55px;
  flex-shrink: 0;
}
.event-full-badge.deadline { background: var(--pink); }
.badge-day   { font-size: 1.2rem; font-weight: 700; line-height: 1; }
.badge-month { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.5px; }
.event-info h3       { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; }
.event-location { font-size: 0.85rem; color: var(--gray-600); }
.event-time     { font-size: 0.85rem; color: var(--gray-600); }

/* ── Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: static;
    flex-direction: row;
    padding: 0.25rem 0;
  }
  .sidebar nav     { flex-direction: row; flex-wrap: wrap; }
  .sidebar-footer  { border-top: none; padding: 0; margin: 0; }
  .nav-item        { padding: 0.5rem 0.75rem; border-left: none; border-bottom: 3px solid transparent; font-size: 0.8rem; }
  .nav-item.active { border-bottom-color: var(--orange); border-left-color: transparent; }
  .layout          { flex-direction: column; }
  .content         { margin-left: 0; padding: 1rem; }
  .dashboard-grid  { grid-template-columns: 1fr; }
}

/* ── View toggle tabs ──────────────────────────── */
.view-tabs {
  display: flex;
  margin-bottom: 1.25rem;
  border: 2px solid var(--navy);
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
}
.view-tab {
  padding: 0.45rem 1.1rem;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  background: var(--white);
  color: var(--navy);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-tab + .view-tab { border-left: 2px solid var(--navy); }
.view-tab.active { background: var(--navy); color: var(--white); }
.view-tab:hover:not(.active) { background: var(--gray-200); }

/* ── Calendar subscribe button ───────────────── */
.cal-subscribe-btn {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cyan);
  text-decoration: none;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  padding: 0.25rem 0.7rem;
  margin-bottom: 1rem;
  transition: background 0.15s, color 0.15s;
}
.cal-subscribe-btn:hover {
  background: var(--cyan);
  color: var(--white);
}

/* ── Calendar nav ──────────────────────────────── */
.cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.cal-prev, .cal-next {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--navy);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  transition: background 0.15s;
}
.cal-prev:hover, .cal-next:hover { background: var(--gray-200); }
.cal-month-label { font-weight: 700; color: var(--navy); font-size: 1rem; transition: opacity 100ms ease; }

/* ── Calendar grid ─────────────────────────── */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 0.75rem;
  transition: opacity 100ms ease;
}
.cal-day-header {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-600);
  text-align: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--gray-200);
}
.cal-cell {
  min-height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border-radius: 4px;
  border: 1px solid var(--gray-200);
  position: relative;
  cursor: default;
  transition: background 0.1s;
}
.cal-cell.other-month { color: var(--gray-600); }
.cal-cell.has-event { cursor: pointer; font-weight: 600; }
.cal-cell.has-event::after {
  content: '';
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--navy);
}
.cal-cell.has-event.deadline::after { background: var(--pink); }
.cal-cell.selected {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  background: var(--gray-200);
}
.cal-cell.has-event:hover:not(.selected) { background: var(--gray-100); }

/* ── Calendar detail panel ─────────────────────── */
.cal-detail { display: none; margin-top: 0.75rem; }
.cal-detail.visible { display: block; }
.cal-detail-card {
  background: var(--white);
  border-left: 3px solid var(--navy);
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.cal-detail-card.deadline { border-left-color: var(--pink); }
.cal-detail-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  display: block;
  margin-bottom: 0.2rem;
}
.cal-detail-card.deadline .cal-detail-badge { color: var(--pink); }
.cal-detail-title { font-weight: 600; font-size: 0.95rem; }
.cal-detail-location { font-size: 0.85rem; color: var(--gray-600); margin-top: 0.2rem; }

/* ── JS utility ────────────────────────────── */
.js-hidden { display: none !important; }

/* ── View transition ────────────────────────── */
#calendar-view,
#list-view {
  transition: opacity 120ms ease;
}

@media (prefers-reduced-motion: reduce) {
  #calendar-view,
  #list-view { transition: none; }
  .notice-dialog-overlay,
  .notice-dialog-box { transition: none; }
}

/* ── Search page ─────────────────────────────── */
.search-container { max-width: 640px; }
.search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  font-size: 1rem;
  font-family: var(--font);
  border: 2px solid var(--gray-200);
  border-radius: 6px;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.search-input:focus { border-color: var(--navy); }
.search-results { margin-top: 0.5rem; }
.search-result {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  margin-bottom: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, transform 0.1s;
}
.search-result:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}
.search-result-type {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-right: 0.5rem;
  vertical-align: middle;
}
.search-result-type--notice   { background: #fce7f3; color: var(--pink); }
.search-result-type--event    { background: #e0f2fe; color: var(--navy); }
.search-result-type--resource { background: #ecfdf5; color: #065f46; }
.search-result-title {
  font-weight: 600;
  color: var(--navy);
  vertical-align: middle;
}
.search-result-excerpt {
  display: block;
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-top: 0.25rem;
}
.search-no-results { color: var(--gray-600); font-size: 0.95rem; margin-top: 0.5rem; }

/* ── Focus states ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
:focus:not(:focus-visible) {
  outline: none;
}
