/* ==========================================================================
   IJMSMT: Editorial design layer & motion
   An editorial, print-journal look: a masthead hero with a live table of
   contents over nautical-chart artwork, quiet hover states and restrained
   motion. Loaded last. All motion is off for users who prefer reduced motion,
   and nothing is hidden unless JavaScript is running (html.js).
   ========================================================================== */
:root {
  --color-gold: #C9982E;
  --color-gold-dark: #9A7215;
  --color-ocean: #1D4E89;
  --color-paper: #F4F7FA;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Guard against any stray element widening the page sideways. */
body { overflow-x: clip; }

/* ---------- Preloader: the logo zooms in, breathes, then zooms away ---------- */
.preloader { display: none; }

html.show-preloader .preloader {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: grid;
  place-items: center;
  background: #FFFFFF;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.preloader-logo {
  width: 120px;
  height: auto;
  animation:
    logo-zoom-in 0.4s var(--ease-out) both,
    logo-breathe 1.1s ease-in-out 0.4s infinite;
}

html.show-preloader body { overflow: hidden; }
html.preloader-done .preloader { opacity: 0; visibility: hidden; pointer-events: none; }
html.preloader-done .preloader-logo { animation: logo-zoom-out 0.3s ease-in forwards; }
html.preloader-done body { overflow: auto; }

@keyframes logo-zoom-in { from { transform: scale(0.55); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes logo-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes logo-zoom-out { to { transform: scale(1.35); opacity: 0; } }

/* ---------- Header & navigation ---------- */
/* No backdrop-filter here: it would turn the header into the containing block
   for the fixed mobile drawer and push the page wider than the screen. */
.site-header { background-color: #FFFFFF; }
.site-header.is-scrolled { box-shadow: 0 4px 18px rgba(16, 42, 67, 0.07); }

/* The journal's full name lives in the hero and footer; the header keeps the
   logo + acronym so the navigation always fits on one line. */
.brand-fullname { display: none; }

.nav-link { position: relative; }
.nav-link::after {
  content: "";
  position: absolute;
  left: 0.8rem;
  right: 0.8rem;
  bottom: 0.25rem;
  height: 2px;
  background: var(--color-primary-navy);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.nav-link:hover, .nav-link.active { background-color: transparent; }
.nav-link:hover::after, .nav-link.active::after { transform: scaleX(1); }

/* Switch to the hamburger before the full navigation runs out of room. */
@media (max-width: 1100px) {
  .nav-menu, .nav-actions .btn-subscribe-nav { display: none; }
  .mobile-menu-toggle { display: flex; }
}

/* Hidden drawer links should not be reachable by keyboard. */
.mobile-nav-panel { visibility: hidden; transition: transform var(--transition-normal), visibility 0s linear 0.2s; }
.mobile-nav-panel.is-open { visibility: visible; transition: transform var(--transition-normal), visibility 0s; }

/* ---------- Buttons ---------- */
.btn { transition: transform 0.2s var(--ease-out), box-shadow 0.2s, background-color 0.2s, border-color 0.2s, color 0.2s; }
.btn-primary:hover, .btn-subscribe-nav:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(16, 42, 67, 0.2); }

.section-eyebrow { color: var(--color-gold-dark); }

/* ---------- Home: editorial masthead hero ---------- */
.hero-masthead {
  position: relative;
  overflow: hidden;
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-border);
  padding-top: 1.5rem;
  color: var(--color-primary-navy);
}

/* Nautical chart: depth contours and soundings, fading out behind the text */
.hero-chart {
  position: absolute;
  inset: 0;
  color: #2A5A8A;
  opacity: 0.2;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 5%, #000 55%);
  mask-image: linear-gradient(90deg, transparent 5%, #000 55%);
}
.hero-chart svg { width: 100%; height: 100%; display: block; }
.hero-masthead .container { position: relative; }

.hero-meta-rule {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-top: 2px solid var(--color-primary-navy);
  border-bottom: 1px solid var(--color-primary-navy);
  padding: 0.55rem 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-navy-light);
}

.hero-grid-ed {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 3.5rem;
  align-items: start;
  padding: 3.25rem 0 3rem;
}

.hero-kicker {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--color-secondary-navy);
  margin-bottom: 0.35rem;
}

.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 5vw, 4.25rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: #0A1B2A;
  margin-bottom: 1.5rem;
  overflow-wrap: break-word;
}
.hero-title .amp { font-style: italic; font-weight: 400; color: var(--color-ocean); }
.hero-title .hero-acronym {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  line-height: 1.4;
  color: var(--color-ocean);
  margin-bottom: 0.6rem;
}
.hero-title .hero-kicker {
  display: block;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: normal;
}

.hero-lede {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--color-text-body);
  max-width: 38rem;
  margin-bottom: 2rem;
}

.hero-cta { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem 1.75rem; }
.hero-link {
  font-weight: 600;
  color: var(--color-primary-navy);
  border-bottom: 1px solid currentColor;
  padding-bottom: 2px;
}
.hero-link:hover { text-decoration: none; color: var(--color-ocean); }
.hero-link span { display: inline-block; transition: transform 0.25s var(--ease-out); }
.hero-link:hover span { transform: translateX(4px); }

/* "In this issue": a real table of contents */
.hero-toc {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1.4rem 1.5rem 1.2rem;
  box-shadow: 0 1px 2px rgba(16, 42, 67, 0.04), 0 14px 34px rgba(16, 42, 67, 0.08);
}
.hero-toc-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  border-bottom: 1px solid var(--color-primary-navy);
  padding-bottom: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hero-toc-head a { font-size: 0.8rem; letter-spacing: 0; text-transform: none; font-weight: 600; }
.hero-toc-list { list-style: none; padding: 0; margin: 0; }
.hero-toc-item {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--color-border);
}
.hero-toc-item:last-child { border-bottom: none; }
.toc-page { font-family: var(--font-serif); font-style: italic; color: var(--color-ocean); padding-top: 1px; }
.toc-title {
  display: block;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.35;
  color: var(--color-primary-navy);
}
.toc-title:hover { color: var(--color-ocean); }
.toc-authors { display: block; font-size: 0.8rem; color: var(--color-text-muted); margin-top: 0.2rem; }
.hero-toc-more { display: inline-block; margin-top: 0.4rem; font-size: 0.8rem; font-weight: 600; }
.hero-toc-empty { font-size: 0.9rem; color: var(--color-text-muted); padding-top: 0.75rem; }

/* Key facts as a ruled row, like a printed masthead */
.hero-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--color-primary-navy);
  margin: 0;
  padding: 1rem 0 1.25rem;
}
.hero-facts > div { padding: 0 1.25rem; border-left: 1px solid var(--color-border-dark); }
.hero-facts > div:first-child { padding-left: 0; border-left: none; }
.hero-facts dt { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); }
.hero-facts dd { margin: 0.15rem 0 0; font-weight: 600; font-size: 0.92rem; color: var(--color-primary-navy); }

@media (max-width: 960px) {
  .hero-grid-ed { grid-template-columns: 1fr; gap: 2.25rem; padding: 2.5rem 0 2.25rem; }
  .hero-meta-center { display: none; }
  .hero-chart { -webkit-mask-image: none; mask-image: none; opacity: 0.12; }
  .hero-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 1rem; }
  .hero-facts > div:nth-child(3) { padding-left: 0; border-left: none; }
}
@media (max-width: 560px) {
  .hero-meta-rule { font-size: 0.66rem; letter-spacing: 0.08em; }
  .hero-meta-rule span:last-child { display: none; }
  .hero-kicker { font-size: 1.1rem; }
  .hero-lede { font-size: 1rem; }
  .hero-toc { padding: 1.1rem 1.1rem 0.9rem; }
  .hero-facts > div { padding: 0 0.75rem; }
}

/* ---------- Inner page headers: same chart paper, lighter touch ---------- */
.page-masthead {
  position: relative;
  overflow: hidden;
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-border);
}
.page-masthead::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/chart-contours.svg") right center / auto 220% no-repeat;
  opacity: 0.1;
  -webkit-mask-image: linear-gradient(90deg, transparent 30%, #000 80%);
  mask-image: linear-gradient(90deg, transparent 30%, #000 80%);
  pointer-events: none;
}
.page-masthead .container { position: relative; }
.page-title { color: #0A1B2A; letter-spacing: -0.01em; }

/* ---------- Cards ---------- */
.article-card, .issue-card, .board-member-card, .subject-area-card, .workflow-step-card {
  transition: transform 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out), border-color 0.25s;
}
.article-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(16, 42, 67, 0.09); }
.article-title a { transition: color 0.2s; }
.article-title a:hover { color: var(--color-ocean); }
.issue-card:hover, .board-member-card:hover, .subject-area-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(16, 42, 67, 0.11);
}
.workflow-step-card:hover { transform: translateY(-3px); }

.keyword-pill { transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
a.keyword-pill:hover { background-color: #EAF1F8; border-color: #B9CDE2; color: var(--color-ocean); text-decoration: none; }

/* ---------- Callouts ---------- */
.submission-callout-card { position: relative; overflow: hidden; border-radius: 6px; }
.submission-callout-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/chart-contours.svg") right center / auto 180% no-repeat;
  filter: invert(1);
  opacity: 0.08;
  pointer-events: none;
}
.submission-callout-inner { position: relative; }
/* The card is navy, so its main button must not be navy too (it was invisible). */
.submission-callout-card .btn-primary { background-color: #FFFFFF; border-color: #FFFFFF; color: var(--color-primary-navy); }
.submission-callout-card .btn-primary:hover { background-color: #E6EDF5; border-color: #E6EDF5; color: var(--color-primary-navy); }

.stats-value { color: var(--color-ocean); }
.floating-toggle-btn { transition: transform 0.25s var(--ease-out), box-shadow 0.25s; }
.floating-toggle-btn:hover { transform: translateY(-2px); }

/* ---------- Responsive fixes ---------- */
/* Search box: inputs keep a built-in minimum width (~20 characters) inside a
   flex row, which pushed the Search button out of the clipped box on phones.
   Let the field shrink; the buttons keep their size. */
.search-input-field { min-width: 0; width: 100%; }
.search-icon-slot, .search-clear-btn, .search-submit-btn { flex-shrink: 0; }
@media (max-width: 480px) {
  .search-box-card { padding: 1.1rem; }
  .search-icon-slot { padding: 0 0.6rem; }
  .search-clear-btn { padding: 0 0.5rem; }
  .search-submit-btn { padding: 0.85rem 1rem; }
}

/* Manuscript callout: long email addresses wrap instead of running off the card. */
.submission-email-display { max-width: 100%; flex-wrap: wrap; }
.submission-email-display strong { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .submission-callout-card { padding: 2rem 1.25rem; }
  .submission-action-bar > .btn { width: 100%; justify-content: center; }
  .submission-email-display { width: 100%; }
}

/* Very small phones (320px, e.g. iPhone SE): keep logo, title and buttons on one line. */
@media (max-width: 380px) {
  .header-inner { gap: 0.5rem; }
  .journal-brand { gap: 0.5rem; }
  .brand-logo { width: 44px; }
  .brand-acronym { font-size: 1.15rem; }
  .nav-actions { gap: 0.4rem; }
}

/* Long option labels must not stretch selects past the screen edge. */
.filter-group { flex-wrap: wrap; min-width: 0; max-width: 100%; }
.filter-select { max-width: 100%; min-width: 0; }
@media (max-width: 640px) {
  .filter-group { width: 100%; }
  .filter-select { width: 100%; }
  .filter-bar, .search-filters-row { flex-direction: column; align-items: stretch; }
  .article-actions-row { flex-wrap: wrap; gap: 0.75rem; }
  .article-actions-left, .article-actions-right { flex-wrap: wrap; }
  .floating-toggle-btn span { display: none; }
  .floating-toggle-btn { padding: 0.85rem; border-radius: 50%; }
}

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: no-preference) {
  /* Chart contours draw themselves in, then the soundings appear */
  html.js .chart-contours path {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: contour-draw 2.2s var(--ease-out) forwards;
    animation-delay: calc(var(--i) * 60ms + 0.15s);
  }
  html.js .chart-soundings { opacity: 0; animation: fade-in 1.2s ease 1.4s forwards; }
  .hero-chart svg { animation: chart-drift 40s ease-in-out infinite alternate; }

  /* Masthead content rises in once the page (and preloader) is ready */
  html.js .hero-meta-rule,
  html.js .hero-title-block > *,
  html.js .hero-toc,
  html.js .hero-facts {
    opacity: 0;
    transform: translateY(18px);
  }
  html.js.is-loaded .hero-meta-rule,
  html.js.is-loaded .hero-title-block > *,
  html.js.is-loaded .hero-toc,
  html.js.is-loaded .hero-facts {
    animation: rise-in 0.8s var(--ease-out) forwards;
  }
  html.js.is-loaded .hero-title-block > *:nth-child(2) { animation-delay: 0.08s; }
  html.js.is-loaded .hero-title-block > *:nth-child(3) { animation-delay: 0.16s; }
  html.js.is-loaded .hero-title-block > *:nth-child(4) { animation-delay: 0.24s; }
  html.js.is-loaded .hero-toc { animation-delay: 0.2s; }
  html.js.is-loaded .hero-facts { animation-delay: 0.35s; }

  /* Table-of-contents entries cascade in */
  html.js .hero-toc-item { opacity: 0; transform: translateX(10px); }
  html.js.is-loaded .hero-toc-item { animation: slide-in 0.6s var(--ease-out) forwards; }
  html.js.is-loaded .hero-toc-item:nth-child(1) { animation-delay: 0.35s; }
  html.js.is-loaded .hero-toc-item:nth-child(2) { animation-delay: 0.45s; }
  html.js.is-loaded .hero-toc-item:nth-child(3) { animation-delay: 0.55s; }
  html.js.is-loaded .hero-toc-item:nth-child(4) { animation-delay: 0.65s; }

  /* Elements tagged by site.js fade up as they scroll into view */
  html.js .reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
  }
  html.js .reveal.is-visible { opacity: 1; transform: none; }
}

@keyframes contour-draw { to { stroke-dashoffset: 0; } }
@keyframes fade-in { to { opacity: 1; } }
@keyframes rise-in { to { opacity: 1; transform: none; } }
@keyframes slide-in { to { opacity: 1; transform: none; } }
@keyframes chart-drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(-1.5%, 1%) scale(1.04); } }

@media (prefers-reduced-motion: reduce) {
  .preloader-logo { animation: none; }
  .article-card:hover, .issue-card:hover, .board-member-card:hover, .subject-area-card:hover { transform: none; }
}

/* ---------- Error pages (404 / 500 / 403 / 400) ---------- */
.error-page {
  position: relative;
  overflow: hidden;
  background: var(--color-paper);
  padding: 5rem 0 6rem;
  min-height: 60vh;
}
.error-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../img/chart-contours.svg") right center / auto 140% no-repeat;
  opacity: 0.12;
  -webkit-mask-image: linear-gradient(90deg, transparent 25%, #000 75%);
  mask-image: linear-gradient(90deg, transparent 25%, #000 75%);
  pointer-events: none;
}
.error-page .container { position: relative; }
.error-grid { max-width: 40rem; }
.error-code {
  font-family: var(--font-serif);
  font-size: clamp(5rem, 16vw, 9rem);
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--color-ocean);
  opacity: 0.9;
  margin-bottom: 1rem;
}
.error-title { font-size: clamp(1.8rem, 4vw, 2.5rem); color: #0A1B2A; margin-bottom: 0.75rem; }
.error-text { font-size: 1.075rem; color: var(--color-text-body); line-height: 1.7; margin-bottom: 1.75rem; }
.error-search { max-width: 34rem; margin-bottom: 1.75rem; background: #FFFFFF; }
.error-links {
  list-style: none;
  padding: 1rem 0 0;
  margin: 0;
  border-top: 1px solid var(--color-border-dark);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}
.error-links a { font-weight: 600; color: var(--color-primary-navy); }
.error-links a:hover { color: var(--color-ocean); }
@media (max-width: 640px) { .error-page { padding: 3rem 0 4rem; } }
.error-body { background: var(--color-paper); }
.error-body .error-page { min-height: calc(100vh - var(--header-height)); }
