/* Final responsive interaction layer for touch, tablet, and narrow viewports. */

@layer components {
  /* Keep editorial labels typographic instead of rendering them as white chips. */
  html body.public-shell.public-shell .site-shell.site-shell main#main-content :is(
    .kicker,
    .panel-topline,
    .feature-eyebrow,
    .card-kicker,
    .section-eyebrow,
    .about-panel-label,
    .projects-panel-label
  ) {
    color: #26775f !important;
    -webkit-text-fill-color: #26775f !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content :is(
    .page-hero .page-copy,
    .hero,
    .news-desk-hero,
    .news-crosslink-section,
    .news-events-editorial-section,
    .events-desk-hero,
    .media-hero,
    .journal-splash,
    .journal-story-dark,
    .projects-hero-copy,
    .projects-routes-panel,
    .projects-search-panel,
    .projects-framework-panel,
    .projects-next-tile,
    .coming-soon-panel,
    .membership-newsletter-section,
    .about-hero-panel,
    .about-final-cta-tile,
    .homepage-journal-panel,
    .homepage-final-cta
  ) :is(
    .kicker,
    .panel-topline,
    .feature-eyebrow,
    .card-kicker,
    .section-eyebrow,
    .about-panel-label,
    .projects-panel-label
  ) {
    color: #9fd0bb !important;
    -webkit-text-fill-color: #9fd0bb !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #publishing-integrity .kicker {
    color: #e0f3ea !important;
    -webkit-text-fill-color: #e0f3ea !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #call-for-papers .kicker {
    color: #14533f !important;
    -webkit-text-fill-color: #14533f !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .membership-hero-copy.membership-hero-copy {
    color: #ffffff !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    border-color: transparent !important;
    box-shadow: none !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .membership-hero-copy.membership-hero-copy :is(h1, p, .lead) {
    color: #ffffff !important;
    -webkit-text-fill-color: #ffffff !important;
  }

  /* Present the publication route once, as a spacious grid rather than two competing timelines. */
  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process.journal-workflow-story {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-story-copy {
    width: 100% !important;
    max-width: none !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 1rem !important;
    margin-block: clamp(1.5rem, 3vw, 2.25rem) !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact > section {
    display: grid !important;
    grid-template-columns: 2.5rem minmax(0, 1fr) !important;
    grid-template-rows: auto 1fr !important;
    column-gap: 0.9rem !important;
    row-gap: 0.35rem !important;
    min-height: 9.5rem !important;
    padding: 1.15rem !important;
    border: 1px solid rgba(38, 119, 95, 0.18) !important;
    border-radius: 8px !important;
    background: #ffffff !important;
    box-shadow: 0 10px 26px rgba(23, 32, 29, 0.07) !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact > section::after {
    display: none !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact > section > span {
    grid-row: 1 / 3 !important;
    align-self: start !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact h3 {
    margin: 0 !important;
    color: #17201d !important;
    -webkit-text-fill-color: #17201d !important;
    font-size: 1.05rem !important;
    line-height: 1.25 !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact p {
    margin: 0 !important;
    color: #53605a !important;
    -webkit-text-fill-color: #53605a !important;
    line-height: 1.55 !important;
  }
}

@layer components {
  @media (max-width: 900px) {
    html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
  }

  @media (max-width: 600px) {
    html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact {
      grid-template-columns: minmax(0, 1fr) !important;
      gap: 0.75rem !important;
    }

    html body.public-shell.public-shell .site-shell.site-shell main#main-content #submission-process .journal-timeline-compact > section {
      min-height: 0 !important;
      padding: 1rem !important;
    }
  }
}

/* Visually unified cards use their existing title link as the full hit area. */
.card:has(.card-title > a) {
  position: relative;
}

/* Final contrast safeguards for the consolidated Journal's dark panels. */
html body.public-shell.public-shell .site-shell.site-shell main#main-content .journal-story-row .journal-specialisation-grid dd {
  color: #34433d !important;
  -webkit-text-fill-color: #34433d !important;
}

html body.public-shell.public-shell .site-shell.site-shell main#main-content .journal-story-dark .journal-framework-grid article :is(h3, p) {
  color: #17201d !important;
  -webkit-text-fill-color: #17201d !important;
}

.card:has(.card-title > a) .card-title > a::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
}

.card:has(.card-title > a) :is(a, button, input, select, textarea, summary) {
  position: relative;
  z-index: 2;
}

/* Avoid a percentage min-height cycle after membership disclosures collapse. */
html body.public-shell .site-shell main .membership-tier-grid-membership > .membership-tier-card {
  min-height: 0 !important;
  height: auto !important;
}

/* Keep membership purchase controls above decorative/card layers and reliable on touch browsers. */
html body.public-shell .site-shell main .membership-tier-actions,
html body.public-shell .membership-tier-dialog-join,
html body.public-shell .site-shell main .membership-checkout-layout .form-actions {
  position: relative;
  z-index: 4;
  isolation: isolate;
}

html body.public-shell.public-shell .site-shell.site-shell main#main-content :is([data-membership-purchase], [data-membership-checkout-submit]) {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(38, 119, 95, 0.2);
}

@media (max-width: 720px), (hover: none) and (pointer: coarse) {
  html body.public-shell.public-shell .site-shell.site-shell main#main-content :is([data-membership-purchase], [data-membership-checkout-submit]) {
    width: 100% !important;
    min-height: 52px !important;
    justify-content: center !important;
  }
}

/* Membership account creation must never retain the desktop sidebar columns on phones. */
@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-hero .submission-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 1rem !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-hero :is(.account-creation-card, .account-creation-side) {
    grid-column: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-hero .account-creation-side {
    display: none !important;
    position: static !important;
    z-index: auto !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form :is(.form-grid-full, .signup-password-field) {
    grid-column: 1 !important;
    min-width: 0 !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form :is(input:not([type="checkbox"]):not([type="radio"]), select, textarea),
  html body.auth-access-page .auth-form :is(input, select, textarea) {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 52px !important;
    font-size: 16px !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .form-grid {
    gap: 0.85rem !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .form-grid label > span {
    font-size: 14px !important;
    line-height: 1.4 !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .upload-placeholder {
    display: none !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .checkbox-label {
    display: grid !important;
    grid-template-columns: 24px minmax(0, 1fr) !important;
    align-items: start !important;
    gap: 0.7rem !important;
    width: 100% !important;
    min-height: 0 !important;
    padding: 0.8rem !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .checkbox-label input[type="checkbox"] {
    display: block !important;
    width: 22px !important;
    min-width: 22px !important;
    height: 22px !important;
    min-height: 22px !important;
    margin: 0.1rem 0 0 !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .checkbox-label span {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    color: #35423d !important;
    -webkit-text-fill-color: #35423d !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.45 !important;
  }

  html body.public-shell.public-shell .site-shell.site-shell main#main-content .account-creation-form .form-actions .button {
    min-height: 52px !important;
  }

  html body.auth-access-page .auth-shell {
    padding-block: 1.25rem !important;
  }

  html body.auth-access-page .auth-brand-lockup {
    margin-bottom: 1rem !important;
  }

  html body.auth-access-page .auth-crest {
    width: min(34vw, 128px) !important;
  }

  html body.auth-access-page .auth-card {
    width: 100% !important;
    padding: 1rem !important;
  }
}

/* Reviewer panels use light surfaces, so their local reading palette must be dark. */
html body.portal-workspace-page .site-shell main :is(.reviewer-assignment-panel, .reviewer-document-panel, .reviewer-decision-panel) {
  --portal-text: #17201d;
  --portal-muted: #53605a;
  color: #17201d !important;
  -webkit-text-fill-color: initial !important;
}

html body.portal-workspace-page .site-shell main :is(.reviewer-assignment-panel, .reviewer-document-panel, .reviewer-decision-panel) :is(h2, h3, p, strong, small, label, .form-label, .muted) {
  color: #17201d !important;
  -webkit-text-fill-color: #17201d !important;
}

html body.portal-workspace-page .site-shell main :is(.reviewer-assignment-panel, .reviewer-document-panel, .reviewer-decision-panel) .muted {
  color: #53605a !important;
  -webkit-text-fill-color: #53605a !important;
}

@media (max-width: 1080px) {
  .site-header:not(.landing-workspace):not(.admin-workspace) .main-nav {
    max-height: 0;
  }

  .site-header:not(.landing-workspace):not(.admin-workspace) .main-nav.is-open {
    max-height: min(76dvh, 680px) !important;
  }

  body.nav-open {
    overflow: hidden;
  }
}

@media (max-width: 980px) {
  body.admin-workspace-page .admin-layout,
  body.admin-workspace-page .admin-layout-with-topbar {
    display: flex !important;
    flex-direction: column !important;
  }

  body.admin-workspace-page .admin-sidebar {
    order: -1 !important;
    width: 100% !important;
  }

  body.portal-workspace-page .portal-panel-grid {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 860px) {
  html body.portal-workspace-page .site-shell main .reviewer-assignment-panel {
    order: 1;
  }

  html body.portal-workspace-page .site-shell main .reviewer-decision-panel {
    order: 2;
  }

  html body.portal-workspace-page .site-shell main .reviewer-document-panel {
    order: 3;
  }

  html body.portal-workspace-page .site-shell main .submission-detail-layout {
    display: flex !important;
    flex-direction: column !important;
  }

  html body.portal-workspace-page .site-shell main .submission-detail-aside {
    order: -1 !important;
  }
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  html body.public-shell .site-shell main > .hero .hero-carousel-dots {
    display: flex !important;
    gap: 0.35rem !important;
    top: auto !important;
    right: 0.75rem !important;
    bottom: 0.75rem !important;
    left: auto !important;
    padding: 0.2rem !important;
    border-color: rgba(255, 255, 255, 0.38) !important;
    background: rgba(13, 20, 18, 0.82) !important;
    transform: none !important;
  }

  html body.public-shell .site-shell main > .hero .hero-carousel-dots button {
    display: grid !important;
    place-items: center !important;
    width: 44px !important;
    min-width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
  }

  html body.public-shell .site-shell main > .hero .hero-carousel-dots button::before {
    width: 8px;
    height: 8px;
    content: "";
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.58);
    transition: width 180ms var(--easing), background 180ms var(--easing);
  }

  html body.public-shell .site-shell main > .hero .hero-carousel-dots button.is-active::before {
    width: 22px;
    background: #fff;
  }

  :is(.journal-section-nav-inner, .section-nav-inner, .portal-tablist, .filter-chip-row, .research-topic-chips, .admin-workspace-header-actions) {
    scroll-padding-inline: 1rem !important;
    scrollbar-width: thin !important;
    scrollbar-color: rgba(38, 119, 95, 0.55) transparent !important;
  }

  :is(.journal-section-nav-inner, .section-nav-inner, .portal-tablist, .filter-chip-row, .research-topic-chips, .admin-workspace-header-actions)::-webkit-scrollbar {
    height: 4px !important;
  }

  :is(.journal-section-nav-inner, .section-nav-inner, .portal-tablist, .filter-chip-row, .research-topic-chips, .admin-workspace-header-actions)::-webkit-scrollbar-thumb {
    border-radius: 999px !important;
    background: rgba(38, 119, 95, 0.55) !important;
  }

  :is(.journal-section-nav, .section-nav, .news-desk-nav, .events-desk-nav) {
    top: 58px !important;
  }

  :is(.footer-links a, .footer-legal a, .submission-detail-actions a, .reviewer-document-actions a, .paper-reader-actions a, .paper-reader-footnote a) {
    display: inline-flex !important;
    align-items: center !important;
    min-height: 44px !important;
    padding-block: 0.45rem !important;
  }

  .paper-card-summary {
    -webkit-line-clamp: 4 !important;
  }

  :is(.card-title, .paper-card-title, .paper-card-authors, .submission-detail-facts dd, .reviewer-document-head, .admin-account-card) {
    overflow-wrap: anywhere !important;
  }
}

@media (max-width: 700px) {
  .paper-reader-shell > .pdf-viewer,
  html body.portal-workspace-page .site-shell main .reviewer-pdf-viewer {
    display: none !important;
  }

  .paper-reader-actions,
  html body.portal-workspace-page .site-shell main .reviewer-document-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
  }

  .paper-reader-actions > *,
  html body.portal-workspace-page .site-shell main .reviewer-document-actions > * {
    width: 100% !important;
    justify-content: center !important;
  }

  .qualification-skill-row:not(.qualification-skill-row-head) {
    grid-template-columns: 1fr !important;
    gap: 0.45rem !important;
  }

  .qualification-skill-row-head {
    display: none !important;
  }

  body.admin-workspace-page .admin-rich-toolbar {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.admin-workspace-page .admin-rich-toolbar > * {
    width: 100% !important;
  }

  body.admin-workspace-page select[multiple] {
    min-height: 11rem !important;
  }

  .website-edit-dialog {
    width: calc(100% - 1rem) !important;
    max-height: calc(100dvh - 1rem) !important;
    margin: auto !important;
    overflow: auto !important;
    overscroll-behavior: contain !important;
  }
}

@media (max-width: 680px) {
  .site-header.admin-workspace .nav-row {
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 0.5rem !important;
  }

  .site-header.admin-workspace .brand {
    min-width: 0 !important;
  }

  .site-header.admin-workspace .brand-logo {
    width: min(32vw, 128px) !important;
  }

  .site-header.admin-workspace .brand-crest {
    width: 38px !important;
    height: 38px !important;
  }

  .site-header.admin-workspace .header-actions {
    gap: 0.3rem !important;
  }

  .site-header.admin-workspace .admin-entry {
    min-width: 44px !important;
    min-height: 44px !important;
    padding: 0.55rem 0.65rem !important;
  }

  .cookie-banner {
    right: max(0.5rem, env(safe-area-inset-right)) !important;
    bottom: max(0.5rem, env(safe-area-inset-bottom)) !important;
    left: max(0.5rem, env(safe-area-inset-left)) !important;
    width: auto !important;
    max-height: min(42dvh, 18rem) !important;
    overflow: auto !important;
    border-radius: 16px !important;
  }

  .cookie-banner-inner {
    display: grid !important;
    grid-template-columns: 1fr auto !important;
    gap: 0.65rem !important;
    padding: 0.75rem !important;
  }

  .cookie-banner-text {
    font-size: 0.78rem !important;
    line-height: 1.4 !important;
  }

  .cookie-banner-actions .button {
    min-width: 72px !important;
    min-height: 44px !important;
  }

  .flash-stack {
    max-height: min(45dvh, 20rem) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  :is(a, button, summary, .card):active {
    transform: none !important;
  }
}
