/* ==========================================================================
   Tanner Eastmond — personal site
   Design system built on BYU brand colors (https://brand.byu.edu/colors)
   Navy is the dominant color; royal blue is the accent.
   Mobile-first, fluid typography, accessible contrast.
   ========================================================================== */

:root {
  /* BYU brand palette */
  --byu-navy:       #002E5D;  /* dominant */
  --byu-navy-deep:  #00224a;  /* slightly darker for gradients/hover */
  --byu-royal:      #0047BA;  /* accent / links */
  --byu-blue:       #0072CE;  /* bright accent / link hover */
  --byu-light-blue: #BDD6E6;
  --byu-slate:      #7C878E;
  --byu-light-gray: #C7C9C7;
  --white:          #FFFFFF;

  /* Semantic tokens */
  --bg:          var(--white);
  --bg-alt:      #f4f6f9;              /* very light blue-gray for panels */
  --ink:         #16213a;              /* near-navy body text on light bg */
  --ink-muted:   #4a5568;
  --on-navy:     rgba(255, 255, 255, 0.92);
  --on-navy-dim: rgba(255, 255, 255, 0.70);
  --link:        var(--byu-royal);
  --link-hover:  var(--byu-blue);
  --rule:        rgba(0, 46, 93, 0.12);

  /* Typography */
  --font-serif: Georgia, "Times New Roman", Cambria, serif;
  --font-sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                Helvetica, Arial, sans-serif;

  /* Fluid type scale */
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --step-1: clamp(1.15rem, 1.05rem + 0.5vw, 1.4rem);
  --step-2: clamp(1.4rem, 1.2rem + 1vw, 1.9rem);
  --step-3: clamp(1.75rem, 1.4rem + 1.75vw, 2.6rem);
  --step-4: clamp(2.1rem, 1.6rem + 2.75vw, 3.4rem);

  /* Spacing / layout */
  --space:      clamp(1rem, 0.8rem + 1vw, 1.75rem);
  --measure:    68ch;             /* readable line length for prose */
  --container:  1080px;
  --radius:     14px;
  --shadow:     0 10px 30px rgba(0, 46, 93, 0.10);
  --shadow-sm:  0 2px 10px rgba(0, 46, 93, 0.08);
}

/* ---------- Reset / base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: 1.2;
  color: var(--byu-navy);
  margin: 0 0 0.5em;
  font-weight: 700;
}

p { margin: 0 0 1.1em; }

a {
  color: var(--link);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover,
a:focus-visible { color: var(--link-hover); text-decoration: underline; }

:focus-visible {
  outline: 3px solid var(--byu-blue);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ==========================================================================
   Header + navigation
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--byu-navy);
  box-shadow: var(--shadow-sm);
}

.wrapper-header {
  max-width: none;
  margin: 0 auto;
  padding: 0.85rem clamp(1.5rem, 6vw, 6rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.9rem);
  font-weight: 700;
  color: var(--white);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.site-title:hover,
.site-title:focus-visible { color: var(--white); text-decoration: none; opacity: 0.9; }

.site-nav { display: flex; align-items: center; }

.trigger {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2.25rem);
}

.page-link {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--on-navy);
  padding: 0.25rem 0;
  position: relative;
}
.page-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--byu-light-blue);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}
.page-link:hover,
.page-link:focus-visible { color: var(--white); text-decoration: none; }
.page-link:hover::after,
.page-link:focus-visible::after { transform: scaleX(1); }

/* Hamburger toggle — hidden on desktop, shown on mobile */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.menu-toggle .bar {
  display: block;
  width: 26px;
  height: 3px;
  border-radius: 3px;
  background: var(--white);
  transition: transform 0.25s ease, opacity 0.2s ease;
}
.menu-toggle[aria-expanded="true"] .bar:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ==========================================================================
   Main / page content
   ========================================================================== */
.page-content {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ---------- Home hero ---------- */
.hero {
  flex: 1 0 auto;                 /* fill the space between header and footer */
  display: flex;
  align-items: center;
  background: var(--bg);
  color: var(--ink);
  padding: clamp(2.5rem, 5vw, 5rem) clamp(1rem, 4vw, 2rem);
}
.hero__inner {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(1.75rem, 4vw, 3.5rem);
  align-items: center;
  justify-items: center;
  text-align: center;
}

.hero__photo {
  width: clamp(200px, 55vw, 320px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  border: 5px solid var(--byu-navy);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.clipped-image { width: 100%; height: 100%; object-fit: cover; object-position: center top; }

.hero__bio { max-width: 60ch; }
.hero__bio .home > *:first-child { margin-top: 0; }
.hero__bio p {
  color: var(--ink);
  font-size: var(--step-1);
  line-height: 1.7;
}
.hero__bio p:last-child { margin-bottom: 0; }
.hero__bio a { color: var(--link); text-decoration: underline; }
.hero__bio a:hover,
.hero__bio a:focus-visible { color: var(--link-hover); }
.hero__bio h1 { color: var(--byu-navy); font-size: var(--step-3); }

/* Home layout wrapper (from home.html) */
.home { width: 100%; }
.post-list { list-style: none; padding: 0; }

/* ---------- Standard page (Research, etc.) ---------- */
.page-shell {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 3.5rem) clamp(1rem, 4vw, 2rem);
}
.post-content,
.page-body {
  max-width: var(--measure);
  margin: 0 auto;
  font-size: var(--step-0);
}
.post-content h1 { font-size: var(--step-3); margin-bottom: 0.75em; }
.post-content h2,
.post-content h3 { font-size: var(--step-2); margin-top: 1.5em; }

/* Research entries: turn each bold-title + abstract block into a readable card.
   Structure is driven by content, so we style generic prose elements. */
.post-content p { margin-bottom: 1.25em; color: var(--ink); }
.post-content strong { color: var(--byu-navy); }
.post-content em { color: var(--ink-muted); }

/* Links inside prose */
.research-link,
.post-content a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
.research-link:hover,
.post-content a:hover,
.research-link:focus-visible,
.post-content a:focus-visible { color: var(--link-hover); }

/* Post header (blog) */
.post-header { margin-bottom: 1.5rem; }
.post-title { font-size: var(--step-4); }
.post-meta { color: var(--ink-muted); font-size: 0.95rem; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  flex-shrink: 0;
  background: var(--byu-navy);
  color: var(--on-navy);
  margin-top: 0;
}
.site-footer .wrapper {
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(1.75rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2rem);
}
.footer-col-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 3rem;
  justify-content: space-between;
  align-items: center;
}
.site-footer .contact-list { list-style: none; margin: 0; padding: 0; }
.site-footer .contact-list li { margin-bottom: 0.35rem; }
.site-footer .p-name { font-family: var(--font-serif); font-size: 1.15rem; color: var(--white); }
.site-footer a { color: var(--byu-light-blue); }
.site-footer a:hover,
.site-footer a:focus-visible { color: var(--white); }
.site-footer p { color: var(--on-navy-dim); margin: 0; }

/* ==========================================================================
   Larger screens
   ========================================================================== */
@media (min-width: 768px) {
  .hero__inner {
    grid-template-columns: auto 1fr;
    text-align: left;
    justify-items: start;
  }
  .hero__bio { max-width: var(--measure); }
}

/* ==========================================================================
   Mobile navigation
   ========================================================================== */
@media (max-width: 767px) {
  .menu-toggle { display: flex; }

  .site-nav {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--byu-navy-deep);
    box-shadow: var(--shadow);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }
  .site-nav.is-open { max-height: 70vh; }

  .trigger {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0;
  }
  .page-link {
    padding: 0.9rem clamp(1rem, 4vw, 2rem);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 1.15rem;
  }
  .page-link::after { display: none; }
  .page-link:hover,
  .page-link:focus-visible { background: rgba(255, 255, 255, 0.06); }

  .wrapper-header { position: relative; }
}

/* ==========================================================================
   Motion / accessibility preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   Research page — two-column paper entries
   ========================================================================== */
.page-shell:has(.post-content--wide) { max-width: 1440px; }
.post-content--wide { max-width: 1440px; }

.research-section {
  font-size: var(--step-1);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  margin: 2em 0 0;
  padding-bottom: 0.35em;
  border-bottom: 2px solid var(--byu-navy);
}
.research-section:first-of-type { margin-top: 0; }

.paper {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem 2.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--rule);
}
.paper:last-child { border-bottom: 0; }
.paper__text { min-width: 0; max-width: var(--measure); }
.paper:has(.paper__figure) .paper__text { max-width: none; }
.paper__title { font-size: var(--step-1); line-height: 1.3; margin: 0 0 0.3em; color: var(--byu-navy); }
.paper__title a { color: inherit; }
.paper__authors { margin: 0 0 0.35em; color: var(--ink-muted); font-size: 0.95em; }
.paper__status { margin: 0 0 0.75em; color: var(--ink-muted); font-size: 0.95em; }
.paper__abstract { margin: 0; font-size: 0.95em; line-height: 1.55; }
.paper__presentations { margin: 0.75em 0 0; color: var(--ink-muted); font-size: 0.9em; line-height: 1.5; }
.paper__figure { margin: 0; align-self: center; }
.paper__figure img { width: 100%; height: auto; }
.paper__caption {
  font-family: var(--font-serif);
  font-size: 0.95em;
  font-weight: 600;
  color: var(--byu-navy);
  text-align: center;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}
.paper__panel + .paper__panel { margin-top: 0.75rem; }
.paper__subcaption {
  font-family: var(--font-serif);
  font-size: 0.9em;
  color: var(--ink-muted);
  text-align: center;
  margin: 0.25rem 0 0;
  line-height: 1.3;
}

@media (min-width: 768px) {
  .paper { grid-template-columns: minmax(0, 1.15fr) minmax(300px, 1fr); gap: 1rem 3rem; align-items: center; }
  .paper:not(:has(.paper__figure)) { grid-template-columns: 1fr; }
  .paper:not(:has(.paper__figure)) .paper__text { max-width: 92ch; }
}

/* ==========================================================================
   Code modal — "view + download source" popups on the research page
   ========================================================================== */
.paper__tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.9em 0 0;
}

.code-button {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--byu-navy);
  background: var(--bg-alt);
  border: 1px solid var(--byu-navy);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease;
}
.code-button:hover,
.code-button:focus-visible {
  background: var(--byu-navy);
  color: var(--white);
  text-decoration: none;
}
.code-button--primary {
  background: var(--byu-royal);
  border-color: var(--byu-royal);
  color: var(--white);
}
.code-button--primary:hover,
.code-button--primary:focus-visible {
  background: var(--byu-navy-deep);
  border-color: var(--byu-navy-deep);
  color: var(--white);
}

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

.code-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 3vw, 2rem);
}
.code-modal[hidden] { display: none; }

.code-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 34, 74, 0.6);
}

.code-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.code-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 1.75rem);
  background: var(--byu-navy);
}
.code-modal__title {
  margin: 0;
  color: var(--white);
  font-size: var(--step-1);
}
.code-modal__close {
  flex-shrink: 0;
  background: transparent;
  border: 0;
  color: var(--on-navy);
  font-size: 1.75rem;
  line-height: 1;
  padding: 0 0.25rem;
  cursor: pointer;
}
.code-modal__close:hover,
.code-modal__close:focus-visible { color: var(--white); }

.code-modal__body {
  overflow-y: auto;
  padding: clamp(1rem, 3vw, 1.75rem);
}
.code-modal__note {
  margin: 0 0 1rem;
  font-size: 0.95em;
  color: var(--ink-muted);
}
.code-modal__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.5rem 0 0.75rem;
}
.code-tab {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.code-tab:hover { color: var(--byu-navy); border-color: var(--byu-navy); }
.code-tab.is-active {
  background: var(--byu-navy);
  border-color: var(--byu-navy);
  color: var(--white);
}
.code-modal__demo {
  display: block;
  width: 100%;
  height: 360px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--white);
}
.code-modal__demo--tall { height: 520px; }
.code-modal__code {
  margin: 0;
  padding: 1rem;
  max-height: 45vh;
  overflow: auto;
  background: var(--bg-alt);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  font-size: 0.8rem;
  line-height: 1.5;
  tab-size: 4;
}
.code-modal__code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  white-space: pre;
  color: var(--ink);
}

.code-modal__foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem clamp(1rem, 3vw, 1.75rem);
  border-top: 1px solid var(--rule);
  background: var(--bg-alt);
}

/* The modal lives inside .post-content, whose generic prose rules are more
   specific than the component classes above. Re-assert the ones that matter. */
.post-content .code-modal__title { font-size: var(--step-1); margin: 0; color: var(--white); }
.post-content .code-modal__note { margin: 0 0 1rem; color: var(--ink-muted); }
.post-content a.code-button {
  color: var(--byu-navy);
  text-decoration: none;
}
.post-content a.code-button:hover,
.post-content a.code-button:focus-visible { color: var(--white); text-decoration: none; }
.post-content a.code-button--primary,
.post-content a.code-button--primary:hover,
.post-content a.code-button--primary:focus-visible { color: var(--white); }
