/*
 * site.css
 * Layout, header/nav, components, and responsive rules.
 * Depends on theme.css for tokens.
 */

/* Skip link ---------------------------------------------------------------- */
.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.6em 1em;
  z-index: 1000;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

/* Header ------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Brand (logo + wordmark) */
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}
.brand__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand__name {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--heading);
  white-space: nowrap;
}
.brand__name:hover { color: var(--primary); text-decoration: none; }

/* Primary nav */
.nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav__link,
.nav__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--text);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0.5em 0.8em;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav__link:hover,
.nav__trigger:hover {
  background: var(--accent-wash);
  color: var(--primary);
  text-decoration: none;
}
.nav__link.is-active {
  color: var(--primary);
  font-weight: 600;
}
.nav__link.is-active::after {
  content: "";
  display: block;
}

/* Dropdown */
.nav__item { position: relative; }
.nav__trigger::after {
  content: "";
  width: 0.4em;
  height: 0.4em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 0.15s ease;
}
.nav__item.is-open .nav__trigger::after { transform: translateY(1px) rotate(225deg); }

.nav__menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 250px;
  max-height: min(70vh, 520px);
  overflow-y: auto;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 0.4rem;
  display: none;
}
.nav__item.is-open .nav__menu { display: block; }

.nav__menu a {
  display: block;
  padding: 0.5em 0.7em;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav__menu a:hover { background: var(--accent-wash); color: var(--primary); text-decoration: none; }
.nav__menu .nav__group-label {
  display: block;
  padding: 0.6em 0.7em 0.2em;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.nav__menu hr { margin: 0.35rem 0.5rem; }

/* Icon buttons (theme toggle, hamburger) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { color: var(--primary); border-color: var(--border-strong); background: var(--accent-wash); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Theme toggle: show sun in dark, moon in light */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.nav__hamburger { display: none; }

/* Mobile nav backdrop */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 90;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
}
.nav-backdrop.is-active { opacity: 1; visibility: visible; }

/* Layout ------------------------------------------------------------------- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Two-column content grid: readable main column + sticky sidebar */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 2.25rem;
  align-items: start;
  padding: 1.75rem 0 3rem;
}
.layout__main { min-width: 0; max-width: var(--content-maxw); }

.sidebar {
  position: sticky;
  top: calc(var(--header-h) + 1.5rem);
  font-size: 0.92rem;
}
.sidebar__card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin-bottom: 1.25rem;
}
.sidebar h2 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 700;
  margin-bottom: 0.6rem;
}
.sidebar ul { list-style: none; padding: 0; }
.sidebar li { margin: 0.45em 0; }
.sidebar a { color: var(--text); font-weight: 500; }
.sidebar a:hover { color: var(--primary); }

/* Hero / identity ---------------------------------------------------------- */
.hero {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2.25rem;
  align-items: center;
  padding: 2.25rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
}
.hero__photo {
  width: 210px;
  height: 210px;
  object-fit: cover;
  border-radius: 18px;
  box-shadow: var(--shadow-md);
}
.hero__eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.hero__title { margin-bottom: 0.35rem; }
.hero__role {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
}
.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.4rem;
  font-size: 0.95rem;
  list-style: none;
  padding: 0;
  margin: 0 0 0.9rem;
}
.hero__meta li { display: flex; align-items: center; gap: 0.45em; margin: 0; color: var(--text-muted); }
.hero__meta b { color: var(--text); font-weight: 600; }
.hero__meta svg { width: 16px; height: 16px; stroke: var(--primary); fill: none; stroke-width: 1.8; flex-shrink: 0; }

.hero__actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

/* Buttons / chips */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 0.55em 1.05em;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: all 0.13s ease;
}
.btn:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }

/* Section cards ------------------------------------------------------------ */
.section { margin-top: 1.6rem; }
.section:first-child { margin-top: 0; }
.section > h2 {
  position: relative;
  padding-bottom: 0.35rem;
  margin-bottom: 0.7rem;
}
.section > h2::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.5rem;
  height: 3px;
  background: var(--primary);
  border-radius: 2px;
}
.section ul { padding-left: 1.2em; }
.section li { margin: 0.32em 0; }

.callout {
  border-left: 3px solid var(--primary);
  background: var(--accent-wash);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  margin: 1rem 0;
}

/* Week-one bio-form callout; safe to delete after Wed 8/26. */
#week1-callout {
  font-size: 0.9em;
  margin-top: 0.75rem;
}

/* Page header (non-home pages) -------------------------------------------- */
.eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.page-head {
  padding: 2.25rem 0 1.5rem;
  border-bottom: 1px solid var(--border);
}
.page-head h1 { margin-bottom: 0.3rem; }
.page-head__sub {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-family: var(--font-head);
  margin-bottom: 0.5rem;
}
.page-head__ids {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}
.page-head__ids code { background: var(--bg-subtle); }
.page-head__note { margin-top: 0.9rem; font-size: 0.98rem; color: var(--text-muted); }

/* Toolbar of quick-link chips */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

/* Tables ------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; margin: 1rem 0 1.5rem; }
.section table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.section caption { text-align: left; color: var(--text-muted); padding-bottom: 0.5rem; }
.section th {
  text-align: left;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  padding: 0.55em 0.7em;
  white-space: nowrap;
}
.section td {
  padding: 0.6em 0.7em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.section tbody tr:hover { background: var(--bg-subtle); }
.section td ul { margin: 0; padding-left: 1.1em; }
.section td li { margin: 0.2em 0; }
.week-num, .day-num {
  text-align: center;
  font-weight: 700;
  color: var(--primary);
  font-family: var(--font-head);
  width: 3.5rem;
}
.others {
  min-width: 14em;
  vertical-align: top;
}
.row-span td { text-align: center; font-weight: 600; color: var(--text-muted); background: var(--bg-subtle); }

/* Weekly timetable (schedule page) ---------------------------------------- */
.timetable {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin: 1.5rem 0 2rem;
}
.tt-day { display: flex; flex-direction: column; gap: 0.4rem; }
.tt-day__name {
  text-align: center;
  font-family: var(--font-head);
  font-weight: 600;
  color: var(--primary);
  padding: 0.45rem;
  border-bottom: 2px solid var(--primary);
}
.tt-slot {
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.5rem;
  font-size: 0.85rem;
  line-height: 1.35;
  text-align: center;
  border: 1px solid var(--border);
}
.tt-slot small { display: block; color: var(--text-muted); font-size: 0.82em; }
.tt-slot__time { font-weight: 600; }
.tt-slot.is-empty { background: transparent; border-style: dashed; opacity: 0.5; min-height: 2.5rem; }
/* Slot categories (theme-aware tints) */
.tt-slot.cat-class    { background: color-mix(in srgb, #2bb3c0 18%, var(--surface)); border-color: color-mix(in srgb, #2bb3c0 40%, var(--border)); }
.tt-slot.cat-office   { background: color-mix(in srgb, #57a05a 18%, var(--surface)); border-color: color-mix(in srgb, #57a05a 40%, var(--border)); }
.tt-slot.cat-seminar  { background: color-mix(in srgb, #b65bbf 18%, var(--surface)); border-color: color-mix(in srgb, #b65bbf 40%, var(--border)); }
.tt-slot.cat-meeting  { background: color-mix(in srgb, var(--ut-orange) 16%, var(--surface)); border-color: color-mix(in srgb, var(--ut-orange) 40%, var(--border)); }

.tt-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.tt-legend span { display: inline-flex; align-items: center; gap: 0.4em; }
.tt-legend i { width: 0.9em; height: 0.9em; border-radius: 3px; display: inline-block; }

@media (max-width: 760px) {
  .timetable { grid-template-columns: 1fr; gap: 1rem; }
  .tt-day { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.7rem; }
  .tt-slot.is-empty { display: none; }
}

/* Grade calculator --------------------------------------------------------- */
.gradecalc { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin: 1.5rem 0; align-items: start; }
.grade-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
}
.grade-card h3 { font-size: 1.05rem; margin-bottom: 0.4rem; }
.grade-card .hint { font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.9rem; }
.grade-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border);
}
.grade-row:last-child { border-bottom: 0; }
.grade-row label { font-weight: 500; }
input[type="number"] {
  width: 5.5rem; padding: 0.4em 0.55em; font: inherit; text-align: right;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 7px;
}
input[type="number"]:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.grade-result { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1rem; }
.result-tile {
  flex: 1 1 140px; text-align: center; padding: 1.1rem 1rem;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
.result-tile .label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.result-tile output { display: block; font-family: var(--font-head); font-size: 2rem; font-weight: 600; color: var(--heading); margin-top: 0.2rem; }
.result-tile.is-letter { background: var(--accent-wash); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.result-tile.is-letter output { color: var(--primary); }
@media (max-width: 620px) { .gradecalc { grid-template-columns: 1fr; } }

/* Footer ------------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  margin-top: 2rem;
}
.footer-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.8rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--primary); }

/* CS dept lockup on an always-light chip so its dark artwork stays legible. */
.footer__logo {
  display: inline-flex;
  background: #fff;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.footer__logo img { height: 38px; width: auto; display: block; }
.footer__meta { display: flex; flex-direction: column; gap: 0.2rem; text-align: right; }

@media (max-width: 560px) {
  .footer-inner { justify-content: center; text-align: center; }
  .footer__meta { text-align: center; }
}

/* Scroll-to-top ------------------------------------------------------------ */
.to-top {
  position: fixed;
  bottom: 1.4rem;
  right: 1.4rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, background-color 0.13s ease;
  z-index: 80;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { background: var(--primary-hover); }
.to-top svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* Responsive --------------------------------------------------------------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 1.5rem; padding-top: 1.75rem; }
  .sidebar { position: static; }
  .sidebar__card { background: var(--bg-subtle); }
}

@media (max-width: 720px) {
  .nav { display: none; }
  .nav__hamburger { display: inline-flex; }

  /* Slide-in mobile panel */
  .nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.1rem;
    position: fixed;
    top: 0;
    right: 0;
    height: 100dvh;
    width: min(82vw, 320px);
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 4.5rem 1rem 2rem;
    overflow-y: auto;
    z-index: 95;
    margin-left: 0;
  }
  .nav.is-open .nav__link,
  .nav.is-open .nav__trigger { width: 100%; justify-content: space-between; font-size: 1.05rem; padding: 0.7em 0.8em; }
  .nav.is-open .nav__item { width: 100%; }
  .nav.is-open .nav__menu {
    position: static;
    display: block;
    box-shadow: none;
    border: 0;
    background: var(--bg-subtle);
    max-height: none;
    margin: 0.2rem 0 0.4rem;
  }

  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 1.25rem;
    padding-top: 2rem;
  }
  .hero__photo { width: 168px; height: 168px; margin: 0 auto; }
  .hero__meta { justify-content: center; }
  .hero__actions { justify-content: center; }
}

@media (max-width: 420px) {
  .header-inner { padding: 0 0.85rem; gap: 0.5rem; }
  .brand__name { font-size: 0.95rem; }
}
