/**
 * Reef broker document portal: password gate plus Mia's tree-led library UI.
 */

:root {
  --squid: #262324;
  --shadow: #a51d46;
  --coral: #ee2966;
  --coral-dark: #c71f55;
  --fog: #77787a;
  --seafoam: #eaeaea;
  --surface: #f7f7f7;
  --white: #ffffff;
  --coral-8: rgba(238, 41, 102, 0.08);
  --coral-18: rgba(238, 41, 102, 0.18);
  --squid-6: rgba(38, 35, 36, 0.06);
  --squid-10: rgba(38, 35, 36, 0.1);
  --font-display: "ITC Avant Garde Gothic Pro", "Montserrat", sans-serif;
  --font-body: "ITC Avant Garde Gothic Pro", "Montserrat", sans-serif;
  --max-width: 1180px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--white);
  color: var(--squid);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

:focus-visible {
  border-radius: 4px;
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.portal-wrap {
  width: min(100% - 56px, var(--max-width));
  margin-inline: auto;
}

/* Authenticated header */
.portal-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--squid-10);
  box-shadow: 0 2px 0 var(--squid-6);
}

.portal-header-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 12px;
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.brand img {
  width: auto;
  height: 34px;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--squid-10);
}

.portal-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0;
  white-space: nowrap;
}

.portal-name small {
  display: block;
  margin-top: 3px;
  color: var(--fog);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-spacer {
  flex: 1 1 auto;
}

.search-shell {
  position: relative;
  width: min(360px, 38vw);
  flex: 0 1 360px;
}

.search-input-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 8px 14px;
  background: var(--seafoam);
  border: 2px solid transparent;
  border-radius: 999px;
  color: var(--fog);
  transition: background 150ms ease, border-color 150ms ease;
}

.search-input-row:focus-within {
  background: var(--white);
  border-color: var(--coral);
}

.search-input-row input {
  width: 100%;
  min-width: 0;
  padding: 0;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--squid);
  font-size: 14px;
  font-weight: 500;
}

.search-input-row input::placeholder {
  color: var(--fog);
  opacity: 1;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  max-height: 370px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--squid-10);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(38, 35, 36, 0.16);
}

.result-item {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  background: var(--white);
  border: 0;
  border-bottom: 1px solid var(--squid-6);
  cursor: pointer;
  text-align: left;
}

.result-item:last-child {
  border-bottom: 0;
}

.result-item:hover,
.result-item:focus-visible {
  background: var(--coral-8);
}

.result-title {
  font-size: 13px;
  font-weight: 700;
}

.result-path {
  color: var(--fog);
  font-size: 11px;
}

.result-empty {
  padding: 17px;
  color: var(--fog);
  font-size: 13px;
  text-align: center;
}

.info-shell {
  position: relative;
  flex: 0 0 auto;
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0;
  background: var(--white);
  border: 1px solid var(--squid-10);
  border-radius: 50%;
  cursor: pointer;
}

.icon-button:hover,
.icon-button[aria-expanded="true"] {
  border-color: var(--coral);
  color: var(--coral);
}

.info-popover {
  position: absolute;
  top: calc(100% + 11px);
  right: 0;
  width: 310px;
  padding: 17px 18px;
  background: var(--squid);
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(38, 35, 36, 0.3);
  color: var(--white);
}

.info-popover h2 {
  margin: 0 0 11px;
  color: var(--seafoam);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.info-popover dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px 11px;
  margin: 0;
}

.info-popover dt {
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
}

.info-popover dd {
  margin: 0;
  color: var(--seafoam);
  font-size: 12px;
}

.nav-signout {
  flex: 0 0 auto;
  color: var(--squid);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-signout:hover {
  color: var(--coral);
}

/* Breadcrumbs */
.breadcrumb-bar {
  position: sticky;
  top: 76px;
  z-index: 80;
  background: var(--seafoam);
  border-bottom: 1px solid var(--squid-10);
}

.breadcrumb-inner {
  display: flex;
  min-height: 54px;
  align-items: center;
  gap: 16px;
}

.back-button {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  gap: 6px;
  padding: 7px 13px 7px 9px;
  background: var(--white);
  border: 1px solid var(--squid-10);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.back-button:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.crumbs {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  font-size: 12px;
}

.crumbs button {
  padding: 3px 2px;
  background: transparent;
  border: 0;
  color: var(--fog);
  cursor: pointer;
  font-weight: 600;
}

.crumbs button:hover {
  color: var(--coral);
}

.crumb-current {
  font-weight: 700;
}

.crumb-separator {
  color: var(--fog);
  opacity: 0.65;
}

/* Home */
.portal-main {
  min-height: calc(100vh - 142px);
}

.home-hero {
  padding: 54px 0 58px;
  background: var(--coral);
  color: var(--white);
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 13px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 18px;
  height: 3px;
  background: currentColor;
  border-radius: 2px;
  content: "";
}

.eyebrow-light {
  color: var(--white);
  opacity: 0.88;
}

.home-hero h1,
.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.1;
}

.home-hero h1 {
  max-width: 680px;
}

.home-hero p {
  max-width: 650px;
  margin: 15px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  padding: 38px 0 72px;
}

.library-card,
.nav-card {
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--squid-10);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.library-card {
  min-height: 260px;
  gap: 16px;
  padding: 30px;
}

.library-card:hover,
.nav-card:hover {
  border-color: var(--coral);
  box-shadow: 0 14px 32px var(--coral-18);
  transform: translateY(-3px);
}

.icon-badge {
  display: grid;
  width: 56px;
  height: 56px;
  place-items: center;
  background: var(--coral-8);
  border-radius: 8px;
  color: var(--coral);
}

.library-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.25;
}

.library-card p {
  margin: 0;
  color: var(--fog);
  font-size: 14px;
}

.card-cta {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  margin-top: auto;
  color: var(--coral);
  font-size: 13px;
  font-weight: 700;
}

.card-cta svg {
  transition: transform 150ms ease;
}

.library-card:hover .card-cta svg {
  transform: translateX(3px);
}

/* Tree views */
.node-view {
  padding-bottom: 82px;
}

.page-head {
  padding: 43px 0 6px;
}

.page-head h1 {
  max-width: 820px;
}

.page-intro {
  max-width: 660px;
  margin: 14px 0 0;
  color: var(--fog);
  font-size: 15px;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 40px 0 5px;
  color: var(--fog);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.section-divider::after {
  height: 1px;
  flex: 1;
  background: var(--squid-10);
  content: "";
}

.branch-slot {
  min-height: 0;
}

.branch-connector {
  display: block;
  width: 100%;
  height: 76px;
  margin-bottom: -4px;
}

.branch-connector path {
  fill: none;
  stroke: var(--coral);
  stroke-linecap: round;
  stroke-width: 2.5;
  opacity: 0.55;
}

.branch-connector circle {
  fill: var(--coral);
  opacity: 0.9;
}

.nav-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
}

.nav-card-grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.nav-card {
  min-height: 172px;
  gap: 12px;
  padding: 23px;
}

.nav-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.nav-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.chevron {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  place-items: center;
  background: var(--coral-8);
  border-radius: 50%;
  color: var(--coral);
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.nav-card:hover .chevron {
  background: var(--coral);
  color: var(--white);
  transform: translateX(2px);
}

.nav-card-description {
  color: var(--fog);
  font-size: 13px;
}

.nav-card-cta {
  margin-top: auto;
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
}

/* Documents */
.benefit-summary-card,
.doc-card {
  display: flex;
  min-width: 0;
  gap: 21px;
  border-radius: 8px;
}

.benefit-summary-card {
  align-items: center;
  margin-top: 27px;
  padding: 27px 30px;
  overflow: hidden;
  background: var(--squid);
  color: var(--white);
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 21px;
  margin-top: 27px;
}

.doc-card {
  align-items: flex-start;
  padding: 23px;
  background: var(--white);
  border: 1px solid var(--squid-10);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.doc-card:hover {
  border-color: var(--coral);
  box-shadow: 0 8px 24px var(--squid-6);
}

.doc-thumb {
  width: 84px;
  height: 108px;
  flex: 0 0 84px;
  object-fit: contain;
  background: var(--seafoam);
  border: 1px solid var(--squid-10);
  border-radius: 6px;
}

.benefit-summary-card .doc-thumb {
  width: 112px;
  height: 144px;
  flex-basis: 112px;
  background: var(--white);
  border-color: rgba(255, 255, 255, 0.2);
}

.doc-body {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
}

.doc-badge {
  display: inline-flex;
  margin-bottom: 9px;
  padding: 4px 8px;
  background: var(--squid-6);
  border-radius: 4px;
  color: var(--squid);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.benefit-summary-card .doc-badge {
  background: var(--coral);
  color: var(--white);
}

.doc-body h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.benefit-summary-card .doc-body h2 {
  color: var(--white);
  font-size: 21px;
  font-weight: 800;
}

.doc-description {
  margin: 6px 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.file-name-tag {
  display: inline-block;
  max-width: 100%;
  margin-top: 10px;
  padding: 6px 9px;
  overflow-wrap: anywhere;
  background: var(--coral-8);
  border-radius: 5px;
  color: var(--shadow);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.benefit-summary-card .file-name-tag {
  background: rgba(238, 41, 102, 0.23);
  color: var(--white);
}

.doc-download {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 8px 15px;
  background: var(--coral);
  border-radius: 999px;
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background 150ms ease, transform 150ms ease;
}

.doc-download:hover {
  background: var(--coral-dark);
  transform: translateY(-1px);
}

.empty-state {
  margin-top: 28px;
  padding: 52px 20px;
  color: var(--fog);
  text-align: center;
}

/* Footer */
.portal-footer {
  border-top: 1px solid var(--squid-10);
}

.portal-footer .portal-wrap {
  display: flex;
  min-height: 76px;
  align-items: center;
}

.foot-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--fog);
  font-size: 12px;
}

.foot-brand img {
  width: auto;
  height: 27px;
}

/* Password gate */
.gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 40px 22px;
  background: var(--squid);
}

.gate-card {
  width: min(100%, 430px);
  padding: 42px 38px;
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.34);
  text-align: center;
}

.gate-logo {
  width: auto;
  height: 44px;
  margin: 0 auto 22px;
}

.page-eyebrow {
  margin-bottom: 6px;
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.gate-card h1 {
  margin: 0 0 8px;
  font-size: 25px;
  line-height: 1.2;
}

.gate-card > p {
  margin: 0 0 25px;
  color: var(--fog);
  font-size: 14px;
}

.gate-error {
  margin-bottom: 17px;
  padding: 10px 13px;
  background: var(--coral-8);
  border: 1px solid var(--coral-18);
  border-radius: 6px;
  color: var(--shadow);
  font-size: 13px;
  font-weight: 600;
}

.gate-card input[type="password"] {
  width: 100%;
  min-height: 48px;
  margin-bottom: 13px;
  padding: 12px 15px;
  background: var(--white);
  border: 1px solid var(--squid-10);
  border-radius: 6px;
  color: var(--squid);
  outline: 0;
}

.gate-card input[type="password"]:focus {
  border-color: var(--coral);
}

.gate-card button[type="submit"] {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  background: var(--coral);
  border: 0;
  border-radius: 5px;
  color: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.gate-card button[type="submit"]:hover {
  background: var(--coral-dark);
}

@media (max-width: 900px) {
  .portal-header-inner {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
  }

  .header-spacer {
    display: none;
  }

  .search-shell {
    width: 100%;
  }

  .nav-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .branch-connector {
    display: none;
  }

  .section-divider {
    margin-bottom: 20px;
  }
}

@media (max-width: 700px) {
  .portal-wrap {
    width: min(100% - 36px, var(--max-width));
  }

  .portal-header-inner {
    grid-template-columns: 1fr auto auto;
    gap: 11px;
    padding: 11px 0;
  }

  .brand-divider,
  .portal-name {
    display: none;
  }

  .brand img {
    height: 31px;
  }

  .search-shell {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .info-shell {
    grid-column: 2;
    grid-row: 1;
  }

  .nav-signout {
    grid-column: 3;
    grid-row: 1;
  }

  .info-popover {
    right: -70px;
    width: min(310px, calc(100vw - 36px));
  }

  .breadcrumb-bar {
    position: static;
  }

  .breadcrumb-inner {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0;
  }

  .crumbs {
    line-height: 1.35;
  }

  .home-hero {
    padding: 42px 0 45px;
  }

  .home-hero h1,
  .page-head h1 {
    font-size: 32px;
  }

  .home-hero p {
    font-size: 14px;
  }

  .library-grid,
  .nav-card-grid,
  .nav-card-grid.cols-2,
  .doc-grid {
    grid-template-columns: 1fr;
  }

  .library-grid {
    gap: 17px;
    padding: 25px 0 55px;
  }

  .library-card {
    min-height: 230px;
    padding: 24px;
  }

  .node-view {
    padding-bottom: 58px;
  }

  .page-head {
    padding-top: 32px;
  }

  .benefit-summary-card,
  .doc-card {
    gap: 16px;
    padding: 20px;
  }

  .benefit-summary-card {
    align-items: flex-start;
  }

  .benefit-summary-card .doc-thumb {
    width: 84px;
    height: 108px;
    flex-basis: 84px;
  }

  .doc-thumb {
    width: 72px;
    height: 93px;
    flex-basis: 72px;
  }
}

@media (max-width: 430px) {
  .benefit-summary-card,
  .doc-card {
    flex-direction: column;
  }

  .benefit-summary-card .doc-thumb,
  .doc-thumb {
    width: 88px;
    height: 114px;
    flex-basis: auto;
  }

  .gate-card {
    padding: 34px 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}
