/* ============================================
   ICE Group — Interfacial Chemical Engineering
   University of Sydney
   Shared Stylesheet
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,600;1,400&family=DM+Sans:wght@300;400;500&display=swap');

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

:root {
  --ice-deep:   #0a1628;
  --ice-mid:    #1a3a5c;
  --ice-blue:   #2d6fa8;
  --ice-bright: #5bb8e8;
  --ice-pale:   #d4eaf7;
  --ice-frost:  #f0f7fc;
  --ice-white:  #ffffff;
  --ice-muted:  #6b8fa8;
  --ice-accent: #7ec8e3;
  --ice-gold:   #c4a35a;
  --text-body:  #2c3e50;
  --text-muted: #567a96;
  --border:     rgba(45, 111, 168, 0.15);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--ice-frost);
  color: var(--text-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ---- NAV ---- */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 22, 40, 0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(91, 184, 232, 0.15);
  padding: 0 3rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-logo { display: flex; align-items: center; gap: 14px; }

.nav-emblem {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--ice-bright) 0%, var(--ice-blue) 60%, var(--ice-mid) 100%);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif;
  font-size: 16px; font-weight: 600; color: white; letter-spacing: -1px;
}

.nav-name { font-size: 14px; font-weight: 500; color: var(--ice-bright); letter-spacing: 0.3px; }

.nav-links { display: flex; gap: 2rem; list-style: none; }
.nav-links a {
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px; font-weight: 400;
  letter-spacing: 0.5px;
  transition: color 0.2s;
  text-transform: uppercase;
}
.nav-links a:hover,
.nav-links a.active { color: var(--ice-bright); }

/* ---- SECTION COMMON ---- */
section { padding: 5rem 3rem; max-width: 1100px; margin: 0 auto; }

.section-tag {
  font-size: 11px; font-weight: 500;
  letter-spacing: 2.5px; text-transform: uppercase;
  color: var(--ice-blue);
  margin-bottom: 0.75rem; display: block;
}

.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 2rem; font-weight: 400;
  color: var(--ice-deep);
  margin-bottom: 0.5rem; line-height: 1.25;
}

.section-lead {
  color: var(--text-muted);
  font-size: 15px; max-width: 520px;
  margin-bottom: 3rem; line-height: 1.75;
}

/* ---- UNIFY STATS STRIP (DESKTOP) ---- */
.stats-strip, .pub-stats {
  display: flex !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 0.85rem 1.5rem !important;
  box-sizing: border-box !important;
}

.stat-item, .pub-stat {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  text-align: center !important;
}

.stat-num, .pub-stat-num {
  font-size: 1.25rem;
  line-height: 1.2;
  text-align: center;
}

.stat-label, .pub-stat-label {
  font-size: 11px;
  line-height: 1.3;
  text-align: center;
}

/* ---- FOOTER ---- */
footer {
  background: #050d1a;
  padding: 2rem 3rem;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid rgba(91, 184, 232, 0.08);
}
.footer-left  { font-size: 12px; color: rgba(255,255,255,0.3); }
.footer-usyd  { font-size: 12px; color: rgba(255,255,255,0.25); letter-spacing: 0.5px; }
.footer-visitors { display: flex; align-items: center; }
.footer-visitors img { height: 20px; display: block; opacity: 0.9; }

/* ---- BUTTONS ---- */
.btn-primary {
  background: var(--ice-blue); color: white; border: none;
  padding: 0.75rem 1.75rem; border-radius: 6px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  letter-spacing: 0.3px; transition: background 0.2s, transform 0.15s;
  font-family: 'DM Sans', sans-serif; text-decoration: none; display: inline-block;
}
.btn-primary:hover { background: var(--ice-bright); transform: translateY(-1px); }

.btn-secondary {
  background: transparent; color: rgba(255,255,255,0.7);
  border: 1px solid rgba(91,184,232,0.3);
  padding: 0.75rem 1.75rem; border-radius: 6px;
  font-size: 13px; font-weight: 400; cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  font-family: 'DM Sans', sans-serif; text-decoration: none; display: inline-block;
}
.btn-secondary:hover { border-color: var(--ice-bright); color: white; }

/* ---- ANIMATIONS ---- */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   RESPONSIVE / MOBILE
   ============================================
   The page editor writes literal desktop pixel values straight onto
   elements as inline style="" attributes (fixed widths/heights on text,
   and position:absolute; left/top coordinates on drag-placed elements).
   Inline styles normally beat an external stylesheet, so every rule
   below that needs to win over one uses !important — that's not
   heavy-handedness, it's the only way an external file can override
   inline styles the editor writes on individual elements. Rules are
   scoped by class/attribute, so nothing here touches elements that
   don't have the problem.
*/

html, body { overflow-x: hidden; }

/* Neutralize editor-written fixed pixel width/height on individual
   elements so text reflows instead of forcing horizontal scroll. */
@media (max-width: 900px) {
  [style*="width:"] {
    max-width: 100% !important;
    height: auto !important;
  }
  /* Drag-placed elements pinned to desktop pixel coordinates (e.g.
     "left: 900px") have nowhere to go on a phone screen — drop them
     back into normal document flow. Small local nudges (the same
     class used with position:relative for micro-adjustments) are
     left untouched. */
  .cms-hoverable[style*="position: absolute"] {
    position: static !important;
    left: auto !important;
    top: auto !important;
    display: block !important;
    margin: 1rem auto !important;
    text-align: center;
  }
}

/* ---- TABLET (≤900px): collapse wide multi-column layouts ---- */
@media (max-width: 900px) {
  section { padding: 3.5rem 1.5rem; }
  .hero, .page-hero { padding: 5.5rem 1.5rem 3.5rem; }
  .hero-grid { grid-template-columns: 1fr !important; gap: 2.5rem !important; }
  .research-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .people-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .contact-band { padding: 3.5rem 1.5rem; }
  .contact-inner { grid-template-columns: 1fr !important; gap: 2.5rem !important; }
  .about-grid { grid-template-columns: 1fr !important; }
  .news-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .mosaic { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .masonry { columns: 2 !important; }
  .industry-grid, .members-grid, .collab-grid, .timeline-grid { gap: 0.85rem !important; }
  footer { padding: 1.5rem; }

  /* Grid/flex items default to a min-width based on their largest
     un-shrinkable child (here, the editor's fixed-pixel text elements).
     That "blowout" is what was squeezing the hero: the row above still
     tries to fit a ~630px-wide child even though we capped that child's
     own max-width. Letting the item itself shrink below its content
     size is what actually makes the column narrow to fit the phone. */
  .hero-grid > *, .contact-inner > *, .about-grid > *, .pi-header > * {
    min-width: 0;
  }
}

/* ---- Hamburger menu button (built with CSS only; hidden on desktop) ---- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 34px; height: 34px;
  background: none; border: none; cursor: pointer; padding: 0;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block; width: 20px; height: 2px;
  background: rgba(255,255,255,0.85); border-radius: 2px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
nav.nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
nav.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
nav.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---- PHONE (≤640px) ---- */
@media (max-width: 640px) {
  section { padding: 3rem 1.25rem; }
  .section-title { font-size: 1.5rem !important; }
  .section-lead { max-width: 100% !important; }

  /* Nav collapses into a hamburger menu. Nav itself stays the same
     fixed height other pages rely on for their sticky "top: 64px"
     toolbars — only the dropdown panel below it is new. */
  nav { padding: 0 1rem; }
  /* The logo emblem carries the "ICE" branding on its own — drop the
     "ICE Laboratory ·" prefix on mobile and keep just the institution
     name, via generated content rather than truncating mid-word. */
  .nav-name { font-size: 0; }
  .nav-name::before {
    content: "University of Sydney";
    font-size: 14px; font-weight: 500;
    color: var(--ice-bright); letter-spacing: 0.3px;
  }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    max-width: none; max-height: 75vh; overflow-y: auto;
    background: rgba(10,22,40,0.98); backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(91,184,232,0.15);
  }
  nav.nav-open .nav-links { display: flex; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 0.9rem 1.5rem; font-size: 13px; }

  .hero, .page-hero { padding: 4.5rem 1.25rem 3rem; }
  .hero-eyebrow { font-size: 10px !important; letter-spacing: 1.5px !important; }
  .hero-subtitle { font-size: 11px !important; letter-spacing: 1px !important; padding-bottom: 1.25rem !important; }
  .hero-title { font-size: 1.9rem !important; }
  .hero-desc { max-width: 100% !important; font-size: 13.5px !important; text-align: left !important; }

  /* Item counts under the hero (news/publications/alumni stat strips) —
     forced onto a single row on every page (was wrapping to two rows once
     a page had 4 stats, e.g. Publications), with number/label sizes
     unified so all three pages' counters match exactly. Each stat item
     flexes to share the row evenly, and its label is left free to wrap
     onto a second line *within its own column* if needed — that keeps
     the row itself single, even when a label is long ("Years of PI's
     experience"), instead of overflowing or wrapping the whole item. */
  .stats-strip, .pub-stats {
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 0.4rem !important;
    padding: 0.6rem 0.75rem !important;
    text-align: center;
  }
  .stat-item, .pub-stat { flex: 1 1 0 !important; min-width: 0 !important; text-align: center !important; }
  .stat-num, .pub-stat-num { font-size: 0.85rem !important; line-height: 1.15 !important; text-align: center !important; }
  .stat-label, .pub-stat-label {
    font-size: 7.5px !important; letter-spacing: normal !important;
    line-height: 1.25 !important; white-space: normal !important; text-align: center !important;
  }

  /* Publications page: shorten mobile labels via ::before */
  .pub-stats .pub-stat:nth-child(1) .pub-stat-label,
  .pub-stats .pub-stat:nth-child(2) .pub-stat-label,
  .pub-stats .pub-stat:nth-child(3) .pub-stat-label,
  .pub-stats .pub-stat:nth-child(4) .pub-stat-label {
    font-size: 0 !important;
  }
  .pub-stats .pub-stat:nth-child(1) .pub-stat-label::before { content: "Publications"; }
  .pub-stats .pub-stat:nth-child(2) .pub-stat-label::before { content: "Articles"; }
  .pub-stats .pub-stat:nth-child(3) .pub-stat-label::before { content: "Reviews"; }
  .pub-stats .pub-stat:nth-child(4) .pub-stat-label::before { content: "Years"; }
  .pub-stats .pub-stat .pub-stat-label::before {
    font-size: 7.5px; letter-spacing: normal !important; line-height: 1.25;
  }

  /* Group photo and USYD logo on the homepage (index.html) are placed
     with drag-and-drop pixel coordinates that only make sense on a wide
     desktop layout — hide them on phones rather than have them float
     awkwardly over other content.
     Matched on the stable part of the filename only (not the full name
     with its numeric suffix) — the editor appends a new _1/_2/etc. every
     time the image is re-uploaded, so pinning to one exact suffix breaks
     the very next time that image gets replaced. */
  img[src*="Group_Logo"],
  img[src*="/Home/USYD"] {
    display: none !important;
  }

  .research-grid, .people-grid, .news-grid,
  .form-row, .mosaic { grid-template-columns: 1fr !important; }
  .masonry { columns: 1 !important; }

  /* Profile header (people.html) */
  .pi-header { flex-direction: column !important; align-items: center !important; text-align: center; }
  .pi-badges, .social-icons { justify-content: center; }
  .pi-name {
    font-size: clamp(0.95rem, 5.5vw, 1.15rem) !important;
    letter-spacing: -0.2px;
  }
  /* Social icon row (Scholar/ResearchGate/Publons/LinkedIn/YouTube/ORCID)
     was wrapping to two rows — shrink the icons and the gap between
     them so all six comfortably fit on one line instead. */
  .social-icons { flex-wrap: nowrap !important; gap: 0.4rem !important; }
  .social-icon img { height: 15px !important; }
  .tab-nav { overflow-x: auto; flex-wrap: nowrap !important; padding: 0 1rem; }

  /* Publication list card */
  .pub-card { flex-direction: column !important; gap: 0.75rem !important; }

  /* Category/year filter rows (gallery, news, photos): keep to a single
     scrollable line instead of wrapping, with a consistent, compact
     type size across all three pages. */
  .controls-bar {
    padding: 0.6rem 1.25rem;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -ms-overflow-style: none; scrollbar-width: none;
  }
  .controls-bar::-webkit-scrollbar { display: none; }
  /* Every direct child (labels, the "sep" divider, and — on photos.html
     — the #categoryFilters / #yearFilters wrapper divs) must refuse to
     shrink, or the wrappers compress and their buttons start
     overlapping each other instead of the row simply scrolling. */
  .controls-bar > * { flex-shrink: 0; }
  .controls-bar .controls-spacer { display: none; }
  .controls-bar label { font-size: 10px !important; }
  .filter-btn { font-size: 11px !important; padding: 0.28rem 0.7rem !important; }
  .sort-select { font-size: 11px !important; }

  /* Justified text reads poorly in a narrow column */
  .abstract-title, .abstract-text, .about-text p,
  .news-card-title, .news-card-body-text { text-align: left !important; }

  footer {
    flex-direction: column !important; gap: 0.6rem;
    text-align: center; padding: 1.5rem;
  }
}

/* ============================================
   CONTENT-CORRECTNESS FIXES (not viewport-specific —
   these are genuinely wrong at any screen size, so they
   apply everywhere rather than only inside a media query)
   ============================================ */

/* The homepage address ended up with an inline text-align:right on just
   its first line (likely an accidental editor click), so it read as
   indented relative to the second line beneath it. Address text should
   always be left-aligned; !important is needed to beat that inline style. */
.contact-text-val, .contact-text-val div { text-align: left !important; }

/* Long unbroken strings (URLs, emails) don't wrap by default — CSS only
   breaks at word boundaries unless told otherwise — so they silently
   overflow their container and get clipped instead of wrapping onto a
   second line. Affects the People page's info rows (website, email, etc.)
   and the homepage contact block equally. */
.info-val, .info-val a,
.contact-text-val, .contact-text-val a {
  overflow-wrap: break-word;
  word-break: break-word;
}
