/* Client portal (/login). Loaded only on the login pages, on top of styles.css,
   and built from its tokens: surfaces, radii, mono labels, one sage accent.
   A standalone page: no site nav or footer. Signed out it is a split screen
   (access card left, off-black brand panel right); signed in the panel goes
   and the project view takes the full width. */

.portal-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.portal-shell[data-state="ready"],
.portal-shell[data-state="empty"] {
  grid-template-columns: minmax(0, 1fr);
}
.portal-shell[data-state="ready"] .portal-shell__brand,
.portal-shell[data-state="empty"] .portal-shell__brand {
  display: none;
}

.portal-shell__main {
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 3vw, 2.25rem) clamp(1.25rem, 5vw, 4rem);
}
.portal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.portal-langs {
  display: flex;
  gap: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--text-soft);
}
.portal-langs a:hover,
.portal-langs a.is-active {
  color: var(--text);
}
.portal-shell__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 440px;
  margin-inline: auto;
  padding-block: 2.5rem;
}
.portal-shell[data-state="ready"] .portal-shell__content,
.portal-shell[data-state="empty"] .portal-shell__content {
  justify-content: flex-start;
  max-width: 980px;
  padding-block: clamp(2rem, 5vw, 3.5rem);
}
.portal-foot {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--text-soft);
  margin: 0;
}
.portal-foot a:hover {
  color: var(--text);
}

/* Access card */
.portal-access {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-diffuse);
  /* Full shorthand: styles.css gives every <section> vertical padding. */
  padding: clamp(1.5rem, 4vw, 2.5rem);
}
.portal-access__title,
.portal__title {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 0.75rem;
}
.portal__title {
  margin-bottom: 1.5rem;
}
.portal-access__lede {
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 1.75rem;
}
.portal-access .portal__fineprint {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

/* Brand panel */
.portal-shell__brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2rem;
  /* The landing hero's Jungfrau duotone (same URL, so it is usually cached),
     under a scrim that keeps the wordmark and the foot copy legible. */
  background-color: #0a0a0a;
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.55) 0%, rgba(10, 10, 10, 0.25) 45%, rgba(10, 10, 10, 0.85) 100%),
    url("/assets/images/backgrounds/jungfrau-duotone.jpg?v=1");
  background-image:
    linear-gradient(180deg, rgba(10, 10, 10, 0.55) 0%, rgba(10, 10, 10, 0.25) 45%, rgba(10, 10, 10, 0.85) 100%),
    image-set(
      url("/assets/images/backgrounds/jungfrau-duotone.webp?v=1") type("image/webp"),
      url("/assets/images/backgrounds/jungfrau-duotone.jpg?v=1") type("image/jpeg"));
  background-size: cover;
  background-position: center;
  color: #d4d4d8;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1.5rem, 5vw, 4rem);
}
.portal-brand__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
}
.portal-brand__eyebrow {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin: 0;
  /* Explicit: styles.css colors every <p>, so the panel color is not inherited. */
  color: #e4e4e7;
}
.portal-brand__name {
  position: relative;
  font-family: var(--font-brand);
  font-size: clamp(1.5rem, 2.4vw, 2.1rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #faf6f0;
}
.portal-brand__ridge {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -0.42em;
  height: 0.36em;
  color: #57ad87;
}
.portal-brand__ridge svg {
  display: block;
  width: 100%;
  height: 100%;
}
.portal-brand__line {
  font-size: clamp(1.25rem, 2.2vw, 1.6rem);
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.25;
  color: #fafafa;
  margin: 0 0 0.6rem;
}
.portal-brand__sub {
  color: #e4e4e7;
  margin: 0;
  line-height: 1.6;
  max-width: 44ch;
}

@media (max-width: 860px) {
  .portal-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .portal-shell__brand {
    display: none;
  }
}

.portal__message {
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.6;
  max-width: 60ch;
  margin: 0 0 1.5rem;
}
.portal[data-state="loading"] .portal__message {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.portal__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(1.25rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
}
.portal__card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.portal__project {
  font-size: clamp(1.3rem, 2.4vw, 1.6rem);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0;
}
.portal__note {
  margin: 1rem 0 0;
  color: var(--text-muted);
  line-height: 1.6;
  white-space: pre-line;
}

.portal__section {
  margin-top: 1.75rem;
  /* Full shorthand: styles.css gives every <section> vertical padding. */
  padding: 1.5rem 0 0;
  border-top: 1px solid var(--border);
}
.portal__label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
  margin: 0 0 0.9rem;
}

.portal__rows,
.portal__links {
  list-style: none;
  margin: 0;
  padding: 0;
}
.portal__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  padding: 0.7rem 0;
}
.portal__row + .portal__row {
  border-top: 1px solid var(--border);
}
.portal__row-main {
  /* Takes the free width so a long price line wraps inside it and the
     button or pill stays on the right. */
  flex: 1 1 14rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.portal__row-title {
  font-weight: 500;
  overflow-wrap: anywhere;
}
.portal__row-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  color: var(--text-soft);
}

/* Project hero: client logo, name, status and summary, with a cover image
   beside it when the project has one. */
.portal__hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  align-items: center;
}
.portal__hero--plain {
  grid-template-columns: minmax(0, 1fr);
}
.portal__logo {
  display: block;
  height: 48px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 1.25rem;
}
.portal__cover {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  object-position: center top;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.portal__summary {
  margin: 0.9rem 0 0;
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 52ch;
}
.portal__pill--status {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.portal__update {
  margin-top: 1.75rem;
  padding: 1rem 1.15rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.portal__update .portal__label {
  margin-bottom: 0.4rem;
}
.portal__update .portal__note {
  margin: 0;
  color: var(--text);
}

.portal__section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

/* Stage: a track of dots, one column per milestone. */
.portal__steps {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}
.portal__step {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1.5rem 0.9rem 0 0;
}
.portal__step::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--border-strong);
}
.portal__step:last-child::before {
  display: none;
}
.portal__step::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: 14px;
  height: 14px;
  border-radius: 99px;
  background: var(--surface);
  border: 2px solid var(--border-strong);
}
.portal__step--done::before {
  background: var(--accent-tone);
}
.portal__step--done::after {
  background: var(--accent-tone);
  border-color: var(--accent-tone);
}
.portal__step--current::after {
  background: var(--text);
  border-color: var(--text);
  box-shadow: 0 0 0 4px rgba(24, 24, 27, 0.12);
}
.portal__step-title {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.portal__step--done .portal__step-title {
  color: var(--text-muted);
}
.portal__step--current .portal__step-title {
  font-weight: 600;
}
.portal__step--upcoming .portal__step-title {
  color: var(--text-soft);
}
@media (max-width: 640px) {
  .portal__hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .portal__steps {
    grid-auto-flow: row;
  }
  .portal__step {
    padding: 0 0 1.1rem 1.75rem;
  }
  .portal__step::before {
    top: 0;
    bottom: 0;
    left: 6px;
    right: auto;
    width: 2px;
    height: auto;
  }
}

.portal__built,
.portal__team {
  list-style: none;
  margin: 0;
  padding: 0;
}
.portal__built {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem;
}
.portal__built-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.portal__built-detail {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-muted);
}
.portal__team {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.25rem;
}
.portal__person {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.portal__person .portal__row-main {
  flex: none;
}
.portal__avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 99px;
  object-fit: cover;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.portal__pill {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}
.portal__row-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.portal__link {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}
.portal__link:hover {
  color: var(--text);
  text-decoration-color: var(--text);
}
.portal__pill--upcoming {
  border-style: dashed;
  color: var(--text-soft);
}
.portal__pill--paid {
  border-color: var(--accent-tone);
  color: var(--accent-tone);
}

.portal__links a {
  display: inline-block;
  padding: 0.35rem 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-strong);
}
.portal__links a:hover {
  text-decoration-color: var(--text);
}

.portal__fineprint {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--text-soft);
}
.portal__error {
  font-size: 0.85rem;
  color: #b6553a;
}

.portal__account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 2rem;
}

.portal .btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Plan card: the first block on every project. Light while nothing is due;
   off-black with one light button when the client has something to pay. */
.portal__plan {
  margin-top: 1.75rem;
  /* Full shorthand: styles.css gives every <section> vertical padding. */
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.portal__plan--due {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-md);
}
.portal__plan--due .portal__label,
.portal__plan--due .portal__row-meta,
.portal__plan--due .portal__fineprint {
  color: #a1a1aa;
}
.portal__plan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem 1.25rem;
  padding: 0.35rem 0 0.9rem;
}
.portal__plan-row + .portal__plan-row {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}
.portal__plan--due .portal__plan-row + .portal__plan-row {
  border-top-color: #27272a;
}
.portal__plan-label {
  font-weight: 500;
}
.portal__plan-price {
  font-size: clamp(1.6rem, 3vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.portal__plan-price small {
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--text-soft);
}
.portal__plan--due .portal__plan-price small {
  color: #a1a1aa;
}
.portal__plan-clear,
.portal__plan-next {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
}
.portal__plan-next strong {
  font-weight: 500;
  color: var(--text);
}
.portal__plan .portal__fineprint {
  margin-top: 0.9rem;
  font-size: 0.8rem;
}
.btn--light {
  background: var(--accent-contrast);
  color: var(--accent);
  border: 1px solid var(--accent-contrast);
}
.btn--light:hover {
  background: #e4e4e7;
}

/* Live results: at most four tiles and one bar chart. */
.portal__tiles {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}
.portal__tile {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.portal__tile-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.portal__tile-value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: clamp(1.7rem, 3.2vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.portal__delta {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.1rem 0.4rem;
  border-radius: 99px;
  background: var(--surface-muted);
  color: var(--text-muted);
}
.portal__delta--up {
  background: rgba(79, 106, 92, 0.12);
  color: var(--accent-tone);
}
.portal__spark {
  display: block;
  width: 100%;
  height: 28px;
}
.portal__spark polyline {
  fill: none;
  stroke: var(--accent-tone);
  stroke-width: 1.6;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}
.portal__chart {
  margin-top: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.portal__bars {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.45rem;
}
.portal__bar {
  display: grid;
  grid-template-columns: minmax(6rem, 9rem) 1fr 3rem;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
}
.portal__bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}
.portal__bar-track {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-muted);
  overflow: hidden;
}
.portal__bar-fill {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--text);
}
.portal__bar-value {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-align: right;
}

/* Tabs: everything secondary, one panel at a time. */
.portal__tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}
.portal__tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  height: 34px;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  font: inherit;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.portal__tab:hover {
  color: var(--text);
}
.portal__tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.portal__tab-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  opacity: 0.7;
}
.portal__section .portal__update {
  margin-top: 1.25rem;
}
.portal__plan--due .portal__plan-next,
.portal__plan--due .portal__plan-clear {
  color: #a1a1aa;
}
.portal__plan--due .portal__plan-next strong {
  color: var(--accent-contrast);
}
