
:root{
  --ink:#1f2430; --ink-muted:#5a6272; --page:#f6f7fb; --surface:#ffffff;
  --brand:#3c2d4d; --brand-ink:#DDDCD7; --accent:#FFB448; --accent-ink:#3c2d4d; --firesky-ink:#CC3B40
  --border:#e7e9ef; --focus:#FFB448; --radius:14px;
  --shadow:0 1px 1px rgba(0,0,0,.04), 0 8px 24px rgba(31,36,48,.08);
  --grid-h:#edf0f6; --grid-v:#edf0f6; --grid-v-strong:rgba(31,36,48,.10);
  --thead-row1-h:34px;
  --container: clamp(320px, 92vw, 1600px);
  --rowhead-w: clamp(240px, 34vw, 320px); /* responsive first column width */
  --rowhead-w-sm: clamp(220px, 48vw, 260px); /* narrow phones */
  --thead-z-top: 7;
  --thead-z-2: 6;
  --thead-z-1: 5;

  --hl-row:  rgba(255,180,72,.16);   /* soft gold wash across row */
  --hl-col:  rgba(60,45,77,.10);     /* soft plum wash down column */
  --hl-cell: rgba(255,180,72,.32);   /* stronger highlight for the pivot cell */
  --hl-ring: #FFB448;                /* gold focus/selection ring */
}

/* ---------- Base ---------- */
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--page); color:var(--ink);
  font-family: "Open Sans", Arial, "Helvetica Neue", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height:1.45;
}
img{ max-width:100%; height:auto; display:block; }
a{color:var(--accent); text-decoration:none}
a:hover{opacity:1} /* keep colors crisp on hover */
.small{color:var(--ink-muted); font-size:13px}
.visually-hidden{position:absolute!important;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ---------- Breadcrumbs + Page header ---------- */
.breadcrumbs{max-width:var(--container); margin:14px auto 0; padding:0 20px; color:var(--ink-muted); font-size:13px}
.breadcrumbs a{color:inherit}
.breadcrumbs .sep{margin:0 6px; opacity:.6}

.pagehdr{max-width:var(--container); margin:12px auto 0; padding:0 20px 12px; display:grid; grid-template-columns:1fr auto; gap:24px; align-items:end; border-bottom:1px solid var(--border); padding-bottom:16px;}
h1{margin:4px 0 0; font-size:clamp(22px,2.8vw,34px); line-height:1.15; overflow-wrap:anywhere; word-break:break-word}
.meta{display:flex; gap:10px; flex-wrap:wrap}
.chip{display:inline-flex; align-items:center; gap:6px; padding:6px 10px; background:#f0f3f7; border:1px solid var(--border); border-radius:999px; font-size:12px; color:var(--ink-muted)}

/* ---------- Layout ---------- */
.container{
  max-width:var(--container);
  margin:18px auto 60px;
  padding:0 20px;
  display:grid;
  grid-template-columns:minmax(0,1fr) 340px;
  gap:18px;
}
.main{ display:contents; }

/* Cards */
.card{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); padding:24px 28px; width:100%; max-width:var(--container);}
.card h2{margin:0 0 12px; font-size:18px}
.card h3{margin:18px 0 8px; font-size:15px; color:var(--ink-muted)}
.muted{color:var(--ink-muted)}
.card.header, .card.full-span{ grid-column: 1 / -1; padding:24px 28px; }

/* Sidebar */
.side{ display:grid; gap:12px; align-content:start; grid-column:2; padding-right:8px;}
@media (max-width:1060px){ .side{ grid-column:1; } }

/* ---------- Legend ---------- */
.legend-card{background:var(--surface); border:1px solid var(--border); border-radius:12px; padding:10px 12px; box-shadow:var(--shadow)}
.legend-card .legend-section{display:flex; flex-wrap:wrap; gap:6px 10px; margin-bottom:6px}
.legend-card .small{font-size:13px; font-weight:600; margin-bottom:4px; color:var(--ink-muted)}

/* ---------- Grid ---------- */
.table-wrap{
  overflow:auto; border:1px solid var(--border); border-radius:12px;
  max-height:72vh; max-width:100%; -webkit-overflow-scrolling:touch;
  scrollbar-gutter: stable both-edges; /* modern browsers */
  -webkit-overflow-scrolling: touch; contain: layout paint;
}
.table-wrap::-webkit-scrollbar{ height:8px; width:8px; }
.table-wrap::-webkit-scrollbar-thumb{ background:rgba(60,45,77,.4); border-radius:4px; }

table{ width:100%; border-collapse:separate; border-spacing:0;}
th, td{
  border-bottom:1px solid var(--grid-h);
  border-right:1px solid var(--grid-v);
  white-space:normal; overflow-wrap:anywhere; word-break:break-word; hyphens:auto;
  padding:12px 10px; text-align:center; background:#fff; color:var(--ink);
}
thead th, td.course-cell.group{ border-color:rgba(255,255,255,.25); }
th:first-child, td:first-child{border-left:1px solid var(--grid-v)}

/* First column */
td.course-cell{ text-align:left; }

/* Campus dividers */
.campus-start{border-left:2px solid var(--grid-v-strong)!important}

/* Sticky header */
thead th{
  position:sticky; top:0; z-index:5;
  background:rgba(60,45,77,.96)!important;
  -webkit-backdrop-filter:saturate(120%) blur(4px); backdrop-filter:saturate(120%) blur(4px);
  color:var(--brand-ink)!important; font-weight:700;
  border-bottom:1px solid rgba(255,255,255,.25);
  white-space:nowrap;
}
thead tr:first-child th{ top:0; z-index:6; }
thead tr:nth-child(2) th{ top:var(--thead-row1-h); z-index:5; }
thead th.rowhead{ left:0; z-index:7!important; }
thead th:not(.rowhead){ min-width:56px; }

/* Course row selection highlight */
tbody tr.is-selected td {
  background: #fff3d6 !important;        /* soft accent-tinted */
}
tbody tr.is-selected td.course-cell.group {
  background: var(--brand) !important;    /* keep group header color if ever selected */
  color: var(--brand-ink) !important;
}

/* Focus ring for keyboard navigation on course rows */
tbody tr.course-row:focus-visible td {
  outline: 3px solid var(--focus);
  outline-offset: -2px; /* inside cell edges */
}


/* --- Fixed/Responsive first column (row header) --- */
th.rowhead,
td.course-cell {
  position: sticky;
  left: 0;
  z-index: var(--thead-z-1);
  background: #fff;
  width: var(--rowhead-w);
  min-width: var(--rowhead-w);
  max-width: var(--rowhead-w);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  border-right: 2px solid var(--grid-v-strong);
}

/* Top header layering */
thead tr:first-child th { top: 0; z-index: var(--thead-z-top); }
thead tr:nth-child(2) th { top: var(--thead-row1-h); z-index: var(--thead-z-2); }

/* Ensure thead rowhead stays above body cells */
thead th.rowhead { left: 0; z-index: calc(var(--thead-z-top) + 1) !important; }

/* Body first cell stickiness */
tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: var(--thead-z-1);
  background: #fff;
}

/* Group styling preserved */
tbody td.course-cell.group:first-child{
  background: var(--brand) !important;
  color: #FFFFFF !important;
  z-index: calc(var(--thead-z-1) + 1);
}

/* Group rows */
td.course-cell.group{
  background:var(--brand)!important; color:var(--brand-ink)!important; font-weight:700;
  border-top:1px solid rgba(255,255,255,.25); border-bottom:1px solid rgba(255,255,255,.25);
}
td.course-cell.group summary{ color:var(--brand-ink); }
td.course-cell.group summary .twisty::before{ color:var(--brand-ink); }

/* Pills, requisites, badges */
.pill-core, .pill,.pill-credits{ display:inline-block; padding:0 6px; margin-left:6px; font-size:11px; border-radius:999px; background:transparent; border:1px solid var(--accent); color:var(--ink); }
/* Stack of core requisites (each on its own wrapped line) */
.req-stack { display: inline-block; margin-top: 6px; max-width: 100%; }
.req-item  { display: block; margin-top: 4px; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.req{ display:block; color:var(--ink); font-size:12px; line-height:1.35; margin-top:6px; white-space:normal; overflow-wrap:anywhere; opacity:.9 }
.req .pill{ margin-right:4px; }
td.course-cell.group .pill, td.course-cell.group .pill-credits{ background:var(--accent); border-color:var(--accent); color:var(--accent-ink) }
td.course-cell.group .req{ color:#fff; opacity:1 }

.badge-on{background:var(--accent); color:#2D2D2D; border-radius:4px; padding:2px 6px; font-weight:700; display:inline-block}
.badge-ol{background:var(--brand); color:#FFFFFF; border-radius:4px; padding:2px 6px; font-weight:700; display:inline-block}
.badge-ext{background:#CC3B40; color:#FFFFFF; border-radius:4px; padding:2px 6px; font-weight:700; display:inline-block}
.badge-on, .badge-ol, .badge-ext{
  display:inline-flex; align-items:center; justify-content:center;
  line-height:1; white-space:nowrap; padding:2px 6px; font-weight:700; border-radius:4px;
}
.badge-na{background:transparent; color:var(--ink); border:1px dashed rgba(31,36,48,.35); border-radius:4px; padding:2px 6px; font-size:12px; font-weight:600; margin-left:6px; display:inline-block}
td.course-cell.group .badge-na{color:#fff; border-color:rgba(255,255,255,.6)}

.ext-link{display:inline-flex; align-items:center; margin-left:8px; color:var(--accent)}
.ext-link svg{ width:22px; height:22px; vertical-align:-2px; transition: transform .15s ease; }
.ext-link:hover svg{ transform: scale(1.2); }
.table-wrap .ext-link svg{ width:22px; height:22px; }

/* details/summary */
details summary{cursor:pointer; list-style:none}
details summary::-webkit-details-marker{display:none}
summary .twisty{display:inline-block; width:1ch}
summary .twisty::before{content:"▸"}
details[open] summary .twisty::before{content:"▾"}

.card.header, .card.full-span { grid-column: 1 / -1; }
.hidden { display: none !important; }

details[open] summary ~ * { animation: expand .18s ease-in-out; }
@keyframes expand {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ================== Filter Tile (search + dropdowns) ================== */
.btn{
  height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}

.filters-tile{
  background: var(--brand);
  color: var(--brand-ink);
  border-radius: 14px;
  padding: 16px 18px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  color-scheme: dark;
}
.filters-tile .toolbar{ display:flex; gap:12px; flex-wrap:wrap; align-items:flex-end; }
.filters-tile .field{ display:flex; flex-direction:column; gap:6px; min-width:220px; }
@media (max-width:900px){ .filters-tile .field{ min-width:100%; } }

/* Labels */
.filters-tile .field label{
  color: var(--brand-ink);
  opacity: .9;
  font-weight: 600;
  font-size: 13px;
}

/* Inputs + Selects */
.filters-tile .field input,
.filters-tile .field select{
  height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,.15) !important;
  color: var(--brand-ink) !important;
  border: 1px solid rgba(255,255,255,.30) !important;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

/* Placeholder visibility */
.filters-tile .field input::placeholder{ color: rgba(255,255,255,.75) !important; }
.filters-tile .field input::-webkit-input-placeholder{ color: rgba(255,255,255,.75) !important; }
.filters-tile .field input::-moz-placeholder{ color: rgba(255,255,255,.75) !important; opacity:1; }
.filters-tile .field input:-ms-input-placeholder{ color: rgba(255,255,255,.75) !important; }
.filters-tile .field input::-ms-input-placeholder{ color: rgba(255,255,255,.75) !important; }

/* Select arrow + padding */
.filters-tile .field select{
  -webkit-appearance: none; appearance: none;
  padding-right: 36px;
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

/* Opened dropdown options */
.filters-tile select option{
  background-color: var(--brand) !important;
  color: var(--brand-ink) !important;
}

/* Hover + Focus states */
.filters-tile .field input:hover,
.filters-tile .field select:hover{
  background: rgba(255,255,255,.20) !important;
  border-color: rgba(255,255,255,.40) !important;
}
.filters-tile .field input:focus,
.filters-tile .field select:focus{
  background: rgba(255,255,255,.25) !important;
  border-color: var(--focus) !important;
  outline: none !important;
  box-shadow: 0 0 0 3px rgba(139,185,255,.25) !important;
}

/* Clear button inside tile */
.filters-tile .btn{
  height: 44px;
  padding: 10px 14px;
  background: rgba(255,255,255,.12);
  color: #fff;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px;
  font-weight: 600;
}
.filters-tile .btn:hover{ background: rgba(255,255,255,.18); }

/* ================== Program tiles (index cards) ================== */
.mini-card{
  background: var(--brand);
  color: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  min-height: 110px;
  display: flex; flex-direction: column; justify-content: space-between;
  transition: transform .08s ease, box-shadow .08s ease;
}
.mini-card:hover, .mini-card:focus-within{ transform: translateY(-1px); box-shadow: 0 6px 24px rgba(0,0,0,.08); }
.mini-card h3{ margin:0 0 6px 0; font-size:16px; color:#fff; }
.mini-card .eyebrow{ font-size:12px; opacity:.85; margin-bottom:4px; color:#fff; }
.mini-card .meta-row{ font-size:12px; color:#fff; margin-top:6px; display:flex; gap:8px; flex-wrap:wrap; }
.mini-card .chip{ border:1px solid var(--border); border-radius:999px; padding:2px 6px; font-size:11px; color:#fff; }
.card-link{ color:inherit; text-decoration:none; }

/* ===== UniSQ Handbook Header (CourseLoop-style) ===== */
.usq-header { position: sticky; top: 0; z-index: 80; }

/* shared wrapper */
.usq-wrap{
  max-width:var(--container); margin:0 auto; padding:0 24px;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
}

/* ---- Link Bar (gold) ---- */
.usq-linkbar{ background:#FFB448; color:#000; }
.usq-linkbar .usq-quicklinks{
  display:flex; flex-wrap:wrap; gap:18px; align-items:center; padding:10px 0;
}
.usq-linkbar .usq-quicklinks a{
  color:#000; text-decoration:none; display:inline-flex; align-items:center; gap:6px; padding:4px 0;
}
.usq-linkbar .usq-quicklinks a:hover{ text-decoration:underline; }
.usq-linkbar .usq-quicklinks a:focus{ outline:2px solid #000; outline-offset:2px; }
.usq-linkbar .ext{ width:22px; height:22px; fill:#000; opacity:.9; }
.usq-linkbar__right{ display:flex; align-items:center; gap:12px; }
.usq-divider{ display:inline-block; width:1px; height:22px; background:#000; opacity:.8; }
.usq-bookmark{ appearance:none; border:none; background:none; padding:0; cursor:pointer; }
.usq-bookmark svg{ width:22px; height:22px; fill:#000; }

/* ---- Brand Bar (purple) ---- */
.usq-brandbar{ background:#3C2D4D; color:#fff; }
.usq-brandbar .usq-wrap{ padding-top:14px; padding-bottom:14px; }
.logo-section{ display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.usq-brandbar .logo{
  height: 66px !important;
  max-height: 66px !important;
  width: auto !important;
  display: block;
  object-fit: contain;
}
.usq-brandbar .handbook-title{
  font-size: 22px; font-weight: 700; color: #fff;
  white-space: nowrap; letter-spacing: .3px; flex: 0 1 auto;
  min-width: 0; /* prevent overflow */
}
/* search */
.usq-search { display:flex; align-items:center; }
.usq-search .search-box{ position:relative; display:inline-flex; }
.usq-search input{
  width:min(420px, 48vw);
  background:#fff; color:#333; border:1px solid #ddd; border-radius:8px;
  padding:10px 14px 10px 34px; outline:none;
}
.usq-search svg{
  position:absolute; left:10px; top:50%; transform:translateY(-50%); color:#6f6f6f;
}

/* ===== UniSQ Handbook Footer (CourseLoop-style) ===== */
.usq-inner{ max-width: var(--container); margin: 0 auto; padding: 0 20px; }
.usq-footer{ background:#3C2D4D; color:#fff; margin-top:40px; }
.usq-footer a{ color:#fff; text-decoration:none; }
.usq-footer a:hover{ text-decoration:underline; }

/* top band */
.usq-footer__top{ border-top:3px solid var(--accent); }
.usq-footer__wrap{
  max-width: var(--container); margin: 0 auto; padding: 1.6rem 20px;
  display: grid; gap: 16px;
  grid-template-areas: "logo" "disc" "meta";
}
@media (min-width:767px){
  .usq-footer__wrap{
    grid-template-areas: "logo disc meta";
    grid-template-columns: 0.5fr 5fr 2fr;
  }
}
.usq-footer__logo{ grid-area: logo; display: flex; align-items: center; justify-content: flex-start; }
.usq-footer__logo img{
  height: 66px !important;
  max-height: 66px !important;
  width: auto !important;
  display: block;
  object-fit: contain;
}

.usq-footer__disc{ grid-area:disc; font-size:14px; line-height:1.55; color:#E0D7EB; }
.usq-footer__disc p{ margin:0 0 0.8rem 0; }
.usq-footer__meta{
  grid-area: meta;
  display: flex;
  flex-direction: column;   /* ← forces a new line */
  align-items: flex-start;
  justify-content: flex-start;
  font-size: 14px;
  color: #E0D7EB;
}
.usq-footer__meta .meta-line { 
  display: block; 
  line-height: 1.5; 
}

.usq-footer__meta span {
  display: inline-block;
  white-space: normal !important;  /* allow wrapping */
  line-height: 1.5;
}
@media (min-width:767px){ .usq-footer__wrap{
    grid-template-areas: "logo disc meta";
    grid-template-columns: auto 1fr auto;
  } }

/* links row */
.usq-footer__links{
  border-top:1px solid rgba(255,255,255,.25);
  padding:0.9rem 0; text-align:center;
}
.usq-footer__links ul{
  list-style:none; margin:0; padding:0 1.6rem;
  display:flex; flex-wrap:wrap; justify-content:center; gap:12px 28px;
}
.usq-footer__links li{ font-size:14px; }
.usq-footer__links a{ position:relative; display:inline-flex; align-items:center; gap:6px; text-decoration: none;}
.usq-footer__links a:focus{ outline:2px solid #fff; outline-offset:2px; }
.usq-footer__links a svg.ext{
  width:14px; height:14px; fill:#fff; flex-shrink:0; opacity:.9; transition:opacity .2s ease;
}
.usq-footer__links a:hover svg.ext{ opacity:1; text-decoration: underline;}

/* powered-by bar */
.usq-footer__powered{
  background:#3C2D4D; padding:1rem; display:flex; justify-content:flex-end; gap:6px;
  font-size:14px;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

/* ===================== RESPONSIVE ENHANCEMENTS ===================== */

/* --- General container adjustment --- */
@media (max-width: 1200px) {
  .container {
    grid-template-columns: 1fr;
    padding: 0 16px;
    margin: 12px auto 40px;
  }
  .side { grid-column: 1; }
}

/* --- Program table (horizontal scroll) --- */
@media (max-width: 1024px) {
  .table-wrap {
    border-radius: 8px;
    max-height: none;
    overflow-x: auto;
  }
  thead th, td {
    font-size: 13px;
    padding: 8px 6px;
  }
}

/* --- Filters tile --- */
@media (max-width: 900px) {
  .filters-tile { padding: 14px; }
  .filters-tile .toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .filters-tile .field { min-width: 100%; }
  .filters-tile .btn { width: 100%; margin-top: 6px; }
}

/* --- Legend responsiveness --- */
@media (max-width: 800px) {
  .legend-card { padding: 14px; }
  .legend-card .legend-section { flex-direction: column; align-items: flex-start; gap: 6px; }
}

/* --- Header + breadcrumbs wrapping --- */
@media (max-width: 768px) {
  .usq-header {
    position: static; /* Disable sticky on mobile */
  }
  
  .usq-linkbar {
    display: none; /* Hide top links bar on mobile */
  }
  
  .usq-brandbar .usq-wrap {
    padding: 10px 16px;
  }
  
  
  .usq-brandbar .handbook-title {
    font-size: 16px;
  }
  .breadcrumbs { font-size: 12px; padding: 0 12px; }
  h1 { font-size: 22px; }
  h2 { font-size: 17px; }
  thead th.rowhead,
  tbody td:first-child { padding: 8px 6px; background: #fff; }
  /* Remove sticky positioning on mobile for better performance */
  thead th.rowhead,
  tbody td:first-child,
  td.course-cell {
    position: static !important;
    left: auto !important;
    z-index: auto !important;
    width: auto !important;
    min-width: 180px !important;
    max-width: none !important;
  }
  
  /* Improve table readability */
  .table-wrap {
    max-height: 70vh; /* Limit height for better mobile UX */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  
  /* Visual scroll indicator */
  .table-wrap::before {
    content: "← Scroll horizontally →";
    position: sticky;
    left: 0;
    top: 0;
    z-index: 10;
    display: block;
    width: 100%;
    padding: 8px;
    background: rgba(255, 180, 72, 0.95);
    color: #000;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
  }
  
  /* Reduce padding/font sizes */
  thead th, tbody td {
    font-size: 11px !important;
    padding: 6px 4px !important;
  }
  
  .pill, .pill-credits {
    font-size: 10px !important;
    padding: 0 4px !important;
  }
  
  .badge-on, .badge-ol, .badge-ext, .badge-na {
    font-size: 10px !important;
    padding: 1px 4px !important;
  }
    .filters-tile {
    position: sticky;
    top: 0;
    z-index: 20;
    border-radius: 0;
    margin: 0 -16px;
    width: calc(100% + 32px);
  }
  
  .filters-tile .toolbar {
    flex-direction: column;
  }
  
  .filters-tile .field {
    width: 100%;
  }
  
  .filters-tile .field input,
  .filters-tile .field select {
    width: 100%;
    font-size: 16px; /* Prevent zoom on iOS */
  }
}

/* Extra small devices */
@media (max-width: 480px) {
  table { min-width: 600px; } /* Reduce minimum width */
  
  .table-wrap {
    border-radius: 0; /* Full width on tiny screens */
    margin: 0 -16px; /* Break out of container padding */
    width: calc(100% + 32px);
  }
}
/* --- Footer wrapping --- */
@media (max-width: 767px) {
  .usq-footer__wrap {
    grid-template-areas: "logo" "disc" "meta";
    grid-template-columns: 1fr;
    gap: 16px;
    text-align: left;
  }
  .usq-footer__logo { justify-content: flex-start; }
  .usq-footer__disc p { font-size: 13px; }
  .usq-footer__links ul { flex-direction: column; align-items: flex-start; gap: 6px; }
  .usq-footer__links li { font-size: 13px; }
}

/* --- Mini-card (Index page tiles) --- */
@media (max-width: 600px) {
  .cards-row { grid-template-columns: 1fr; }
  .mini-card { min-height: 90px; }
}

@media (max-width: 640px) {
  thead th, td { font-size: 12px; padding: 8px 6px; }
}

/* Extra-narrow devices */
@media (max-width: 390px){
  h1 { font-size: 19px; }
  h2 { font-size: 15px; }
  .card { padding: 14px; }
  .filters-tile { padding: 10px; }
  .filters-tile .field input, .filters-tile .field select { height: 38px; font-size: 13px; }
  table { min-width: 660px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}



/* ===================== FINAL PRINT STYLES — NO OVERFLOW CLIPPING ===================== */
@media print {
  @page {
    size: A4 landscape;
    margin: 12mm 12mm 16mm 12mm; /* top, right, bottom, left */
    counter-reset: page 1;

    /* Footer page number (right aligned) */
    @bottom-right {
      content: "Page " counter(page) " of " counter(pages);
      font: 9pt 'Open Sans', Arial, sans-serif;
      color: #000;
      padding-right: 6mm;
    }
  }

  /* Base setup */
  html, body {
    background: #fff !important;
    font-size: 9.2pt !important;
    line-height: 1.25 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    transform: none !important;
    height: auto !important;
    width: auto !important;
  }

  /* Hide UI elements */
  .usq-header, .usq-footer, .breadcrumbs, .top-actions,
  .filters-tile, .legend-card, .card.header {
    display: none !important;
  }

  /* Fixed header/footer for all pages */
  body::before {
    content: "Set printer Margins to “Minimum” and use Landscape mode for full table visibility — " attr(data-print-date);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 14mm;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: #fff;
    border-bottom: 0.5pt solid #999;
    padding-bottom: 2mm;
    font: 9pt 'Open Sans', Arial, sans-serif;
    color: #000;
    z-index: 100;
  }

  body::after {
    content: "Printed from UniSQ Course Offerings Map — Course offerings subject to change during the year and from year to year.";
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 14mm;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: #fff;
    border-top: 0.5pt solid #999;
    padding-top: 2mm;
    font: 9pt 'Open Sans', Arial, sans-serif;
    color: #000;
    z-index: 100;
  }

  /* Reserve space so header/footer don't overlap content */
  body {
    padding-top: 18mm !important;
    padding-bottom: 20mm !important;
  }

  /* Containers */
  .container, .card, .table-wrap {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
    overflow: visible !important;
    max-height: none !important;
  }

  /* Table setup */
  table {
    width: 100% !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    table-layout: auto !important; /* allow full width flexibility */
    font-size: 9pt !important;
    page-break-after: auto !important;
  }

  thead { display: table-header-group !important; }
  tfoot { display: table-row-group !important; }
  tr { page-break-inside: avoid !important; break-inside: avoid !important; }

  th, td {
    padding: 2px 3px !important;
    border: 0.5pt solid #999 !important;
    color: #000 !important;
    background: #fff !important;
    vertical-align: top !important;
    word-break: break-word !important;
    overflow: visible !important;       /* critical: allow expansion */
  }

  th.rowhead, td.course-cell { width: 25% !important; max-width: 42% !important; }
  thead th:not(.rowhead), tbody td:not(.course-cell) {
    width: clamp(22px, 5.5vw, 64px) !important;
    max-width: 64px !important;
  }

  td.course-cell.group {
    background: #eee !important;
    font-weight: 700 !important;
    border-top: 1pt solid #000 !important;
    border-bottom: 1pt solid #000 !important;
  }

  /* Pills and badges */
  .badge-on, .badge-ol, .badge-ext, .badge-na, .pill, .pill-credits {
    font-size: 7pt !important;
    padding: 0 2px !important;
    border: 0.5pt solid #666 !important;
    background: #fff !important;
    color: #000 !important;
  }

  /* Guarantee no row is clipped at the page bottom */
  tbody tr:last-child td { border-bottom: 0.6pt solid #000 !important; }

  /* Strong overflow safeguard for Chrome */
  .table-wrap, table, tbody, tr, td {
    overflow: visible !important;
    max-height: none !important;
    clip: auto !important;
  }

  /* Disable any scaling */
  html.print-shrink body {
    transform: none !important;
    width: auto !important;
  }
}






/* ===== FINAL OVERRIDE: default-margin safe fit (must be last) ===== */
@media print {
  /* Cross-browser shrink that always runs when you DIDN'T opt in with html.print-shrink */
  html:not(.print-shrink) body {
    /* tune 0.78–0.84 if needed; 0.80 is a safe default for A4 landscape + default margins */
    --print-scale: 0.80;
    transform: scale(var(--print-scale)) !important;
    -webkit-transform: scale(var(--print-scale)) !important;
    transform-origin: top left !important;
    width: calc(100% / var(--print-scale)) !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Tighten the grid a tad more under default margins */
  html:not(.print-shrink) table         { font-size: 8.8pt !important; table-layout: fixed !important; }
  html:not(.print-shrink) thead th,
  html:not(.print-shrink) tbody td      { padding: 1px 1.5px !important; }

  /* Free up width: shave the first column + cap period columns */
  html:not(.print-shrink) th.rowhead,
  html:not(.print-shrink) td.course-cell {
    width: 21% !important;  /* ↓ from 25% */
    max-width: 38% !important;
  }
  html:not(.print-shrink) thead th:not(.rowhead),
  html:not(.print-shrink) tbody td:not(.course-cell) {
    width: clamp(18px, 4.7vw, 52px) !important;  /* ↓ caps */
    max-width: 52px !important;
  }

  /* Belt-and-braces: never clip any wrapper */
  html:not(.print-shrink) .table-wrap,
  html:not(.print-shrink) .table-wrap * { overflow: visible !important; }

  /* If you DO opt in to manual shrink, don't double-scale */
  html.print-shrink body { transform: none !important; width: auto !important; }
}



/* =================== END OPTIMIZED PRINT STYLES ==================== */



.ext-link:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ext-link:hover svg,
.ext-link:focus-visible svg { transform: scale(1.2); }

table{ min-width: 960px; }
@media (max-width: 900px){ table{ min-width: 720px; } }

@media (hover: none){
  .ext-link:hover svg{ transform:none; }
}

.btn{ cursor:pointer; }
.filters-tile .btn{ border-color: rgba(255,255,255,.35); }

@media (max-width: 768px){
  .card{ padding:18px; }
   .usq-brandbar .logo{
    height: 26px !important;
    max-height: 26px !important;
  }
  .usq-footer__logo img{
    height: 44px !important;
    max-height: 44px !important;
  }
}

/* Right-edge fade (single definition) */
.table-wrap::after {
  content: "";
  position: sticky;
  right: 0; top: 0; bottom: 0; width: 30px;
  pointer-events: none;
  background: linear-gradient(to left, var(--page), rgba(246,247,251,0));
}

/* --- Mobile fix: ensure horizontal scroll works inside table cards --- */
@media (max-width: 900px) {
  main.container { display: block; overflow-x: hidden; }
  .card.full-span { overflow-x: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x; }
  .table-wrap {
    overflow-x: auto !important;
    width: 100%;
    max-width: none;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
  }
  table { width: max-content; min-width: 720px; }
  thead th, tbody td:first-child { touch-action: pan-x; }
}

.card.header { display: flex; align-items: center; gap: 12px; }
.card.header .topnav { display: flex; align-items: center; gap: 10px; }
.card.header .top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }


/* Row highlight */
tbody tr.is-row-hot td{ background: var(--hl-row); }
tbody tr.is-row-hot td.course-cell.group{
  /* keep group header styling intact */
  background: var(--brand) !important; color: var(--brand-ink) !important;
}

/* Column highlight */
table td.is-col-hot, table th.is-col-hot{ background: var(--hl-col); }

/* Pivot/highlighted cell */
table td.is-pivot{
  background: var(--hl-cell);
  outline: 2px solid var(--hl-ring);
  outline-offset: -2px;
}

/* Keyboard focus support */
table td[tabindex="0"]:focus{
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* Keep badges readable on highlights */
.badge-on, .badge-ol, .badge-ext, .badge-na { position: relative; z-index: 1; }

/* ===== Requisites accordion ===== */
.req-acc { margin-top: 8px; text-align: left; }
.req-acc > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f7f8fb;
  font-weight: 600;
  font-size: 12px;
  color: var(--ink);
}
.req-acc > summary .chev { display:inline-block; width:1ch; transform: rotate(0deg); transition: transform .15s ease; }
.req-acc[open] > summary .chev { transform: rotate(90deg); }

.req-acc .req-body {
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

.req-stack .req-item { display:block; margin: 6px 0; }
.pill-core { background: #fff; border-color: var(--accent); color: var(--ink); }

/* Long text wrapping */
.req-acc, .req-acc * {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

/* ===================== ENVIRONMENT BANNER ===================== */
.env-banner {
  position: sticky;
  top: 0;
  z-index: 3000;
  width: 100%;
  text-align: center;
  font-family: 'Open Sans', Arial, sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.2px;
  padding: 10px 0;
  color: #ffffff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.15);
}

/* Specific color for Test Web Server */
.env-banner-test {
  background-color: #f5a623; /* UniSQ amber (matches screenshot) */
}

/* Hide banner completely in print */
@media print {
  .env-banner { display: none !important; }
}

.title-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.pagehdr h2, .pagehdr h1 {
  margin: 0;
  font-size: 1.6rem;
}

/* Title and layout for index page */
.pagehdr h1 {
  font-size: 2rem;          /* increased from ~1.6rem */
  font-weight: 700;
  color: #1f2430;           /* deep ink */
  margin: 0;
}

.subtitle {
  margin-top: 4px;
  font-size: 0.95rem;
  color: #555;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}

.title-block h2, .title-block h1 {
  font-size: 1.8rem;
  margin: 0;
  color: #3c2d4d;
}                            
.subtitle {
                  
  font-size: 0.9rem;
  color: #555;
  margin-top: 3px;
}

.year-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.year-switcher label {
  font-weight: 600;
  font-size: 0.9rem;
              
}

.year-switcher select {
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #ccc;
                   
  font-size: 0.95rem;
  cursor: pointer;
}
