/* =========================================================================
   Beth Chen — Personal Academic Website
   Stage 2 static shell styles. Follows DESIGN.md.
   Mobile-first; breakpoints at ~640px and ~960px.
   ========================================================================= */

/* ---- Design tokens ---------------------------------------------------- */
:root {
  --canvas: #FAFAF7;
  --surface: #FFFFFF;
  --ink: #1F2933;
  --secondary: #5B6470;
  --accent: #2C6E7F;
  --accent-hover: #22525E;
  --clay: #C9836B;
  --clay-tint: #F4E6DF;
  --heart: #C1465E;
  --border: #E4E6E1;
  --mint: #E7F1EE;

  --maxw: 1080px;
  --radius-card: 12px;
  --radius-btn: 8px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { line-height: 1.25; margin: 0; }

p { margin: 0; }

a { color: var(--accent); }

.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* Offset for sticky header when jumping to sections */
section[id] { scroll-margin-top: 72px; }

/* ---- Header / navigation --------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 250, 247, 0.92);
  backdrop-filter: saturate(1.1) blur(6px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.nav__brand {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--ink);
  text-decoration: none;
}

.nav__toggle {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  cursor: pointer;
}
.nav__toggle-bar {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--ink);
  border-radius: 2px;
}

.nav__menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Mobile: menu collapses under the bar, toggled open */
@media (max-width: 639px) {
  .nav__menu {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 8px 20px rgba(31, 41, 51, 0.06);
  }
  .nav__menu.is-open { display: flex; }
  .nav__menu li { border-top: 1px solid var(--border); }
  .nav__link {
    display: block;
    padding: var(--space-4);
  }
}

/* Desktop / tablet: inline menu, hide toggle */
@media (min-width: 640px) {
  .nav__toggle { display: none; }
  .nav__menu {
    display: flex;
    gap: var(--space-6);
  }
}

.nav__link {
  color: var(--ink);
  text-decoration: none;
  font-size: 0.98rem;
  padding: var(--space-2) 0;
}
.nav__link:hover { color: var(--accent); }
.nav__link.is-active { color: var(--accent); font-weight: 600; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-btn);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.btn--secondary:hover { background: var(--mint); }

.btn--interest {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.btn--interest:hover { background: var(--mint); }
.btn--interest__icon { font-size: 1.05rem; line-height: 1; }

/* Saving… state: temporarily disabled while the request is in flight */
.btn--interest:disabled:not(.is-interested) {
  opacity: 0.75;
  cursor: progress;
}

/* Settled "Interested" state: clearly chosen, readable — NOT greyed-out.
   Rendered in warm rose with a filled heart; stays visually confident. */
.btn--interest.is-interested {
  background: #FBEEF0;              /* pale rose tint */
  color: var(--heart);
  border-color: var(--heart);
  cursor: default;
  opacity: 1;                       /* override the default disabled look */
}
.btn--interest.is-interested .btn--interest__icon { color: var(--heart); }

/* Inline error shown near the interest button if a save fails */
.idea-card__error {
  color: var(--heart);
  font-size: 0.85rem;
  margin-top: var(--space-1);
}

/* Visible keyboard focus for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Hero ------------------------------------------------------------- */
.hero {
  padding-block: var(--space-12) var(--space-16);
}
.hero__inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}
.hero__eyebrow {
  color: var(--accent);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  margin-bottom: var(--space-2);
}
.hero__name {
  font-size: clamp(2.2rem, 6vw, 3rem);
  font-weight: 700;
}
.hero__affiliation {
  color: var(--secondary);
  margin-top: var(--space-2);
  font-size: 1.05rem;
}
.hero__positioning {
  margin-top: var(--space-4);
  font-size: 1.15rem;
  max-width: 38ch;
}
.hero__actions {
  margin-top: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* Portrait: flexible fixed-shape container, aspect-tolerant via object-fit */
.hero__portrait { display: flex; justify-content: center; }
.portrait-frame {
  width: 100%;
  max-width: 240px;         /* mobile: portrait stays modest, does not dominate */
  aspect-ratio: 4 / 5;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(31, 41, 51, 0.08);
  background: var(--surface);
}
.portrait-frame__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
}

/* Tablet+: two-column hero, text left / portrait right */
@media (min-width: 640px) {
  .hero__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
  .hero__text { flex: 1 1 55%; }
  .hero__portrait { flex: 0 0 40%; }
  .portrait-frame { max-width: 300px; }
}
@media (min-width: 960px) {
  .portrait-frame { max-width: 340px; }
}

/* ---- Generic section -------------------------------------------------- */
.section { padding-block: var(--space-12); }
.section--tint { background: var(--mint); }
.section__narrow { max-width: 720px; }
.section__heading {
  font-size: clamp(1.5rem, 3.5vw, 1.9rem);
  font-weight: 600;
  margin-bottom: var(--space-6);
}
.section__intro {
  color: var(--secondary);
  max-width: 60ch;
  margin-bottom: var(--space-8);
}

.about__text { font-size: 1.05rem; max-width: 65ch; }

/* ---- Research interests grid ----------------------------------------- */
.interest-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .interest-grid { grid-template-columns: repeat(2, 1fr); }
}
.interest-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
}
.interest-card__title { font-size: 1.2rem; margin-bottom: var(--space-2); }
.interest-card__text { color: var(--secondary); }

/* ---- Developing research ideas --------------------------------------- */
.idea-grid {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr;
}
@media (min-width: 640px) { .idea-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .idea-grid { grid-template-columns: repeat(3, 1fr); } }

.idea-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--space-6);
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.04);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.idea-card__body { display: flex; flex-direction: column; gap: var(--space-3); }
.idea-card__title { font-size: 1.2rem; }
.idea-card__desc { color: var(--secondary); }

.status-pill {
  align-self: flex-start;
  background: var(--clay-tint);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
}

.chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip {
  background: var(--canvas);
  border: 1px solid var(--border);
  color: var(--secondary);
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

.idea-card__interest {
  margin-top: auto;
  padding-top: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
}
.idea-card__count { color: var(--secondary); font-size: 0.9rem; }

.ideas__note {
  margin-top: var(--space-8);
  color: var(--secondary);
  font-size: 0.9rem;
  max-width: 60ch;
}

/* Loading / error message shown inside the ideas grid before cards load */
.ideas__status {
  grid-column: 1 / -1;
  color: var(--secondary);
  padding: var(--space-4) 0;
}
.ideas__status--error { color: var(--heart); }

/* ---- Stay in touch form ---------------------------------------------- */
.stay__prompt { color: var(--secondary); max-width: 55ch; margin-bottom: var(--space-6); }

.stay-form { display: flex; flex-direction: column; gap: var(--space-4); max-width: 480px; }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label { font-weight: 600; font-size: 0.95rem; }
.field__input {
  width: 100%;
  padding: 0.65rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
}
.field__input::placeholder { color: #9aa1aa; }

.field--checkbox {
  flex-direction: row;
  align-items: flex-start;
  gap: var(--space-3);
}
.field__checkbox {
  margin-top: 0.2rem;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--accent);
}
.field__consent-label { color: var(--secondary); font-size: 0.95rem; }

/* Inline status message under the form (validation error / success). */
.stay-form__status {
  margin-top: var(--space-1);
  font-size: 0.95rem;
  min-height: 1.2em;            /* reserve space so layout doesn't jump */
}
.stay-form__status.is-error { color: var(--heart); }
.stay-form__status.is-success { color: var(--accent-hover); font-weight: 600; }
.stay-form__status:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Quiet privacy note near the form. */
.stay__privacy {
  color: var(--secondary);
  font-size: 0.85rem;
  margin-top: var(--space-3);
  max-width: 55ch;
}

/* ---- Footer ----------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: var(--space-8);
  margin-top: var(--space-8);
}
.site-footer__text { color: var(--secondary); font-size: 0.9rem; }

/* ---- Reduced motion --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
