/* Client portal demo — layout and components.
   Palette tokens come from styles.css and theme.css. */

.portal {
  --surface: color-mix(in srgb, var(--ink) 4%, var(--paper));
  --surface-2: color-mix(in srgb, var(--ink) 7%, var(--paper));
  --hairline: color-mix(in srgb, var(--ink) 13%, transparent);
  --radius: 8px;
  --shadow: 0 1px 2px color-mix(in srgb, var(--ink) 7%, transparent),
    0 8px 24px -16px color-mix(in srgb, var(--ink) 35%, transparent);
  display: grid;
  grid-template-columns: 262px 1fr;
  max-width: 1500px;
  margin: auto;
}

.demo-banner {
  text-align: center;
  padding: 11px 20px;
  font: 12px/1.6 var(--mono);
  letter-spacing: 0.04em;
}

/* ---------- Sidebar ---------- */

.portal-sidebar {
  padding: 38px 26px;
  border-right: 1px solid var(--line);
  align-self: start;
  position: sticky;
  top: 0;
}
.portal-sidebar h2 {
  font-size: 23px;
  letter-spacing: -0.02em;
  margin: 0;
}
.muted {
  color: var(--muted);
}
.portal-sidebar > p {
  font-size: 14px;
  margin: 2px 0 0;
}
.portal-sidebar nav {
  display: grid;
  gap: 2px;
  margin: 32px 0;
}
.portal-sidebar nav a {
  padding: 11px 13px;
  font-size: 14px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  color: var(--muted);
  transition:
    background 0.18s,
    color 0.18s,
    border-color 0.18s;
}
.portal-sidebar nav a:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.portal-sidebar nav a.is-current {
  background: var(--surface-2);
  border-left-color: var(--signal, var(--accent));
  color: var(--ink);
  font-weight: 600;
}
.sidebar-summary {
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-bottom: 24px;
  display: grid;
  gap: 10px;
  font-size: 13px;
}
.sidebar-summary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}
.sidebar-summary strong {
  color: var(--ink);
  font-weight: 600;
}
.identity {
  border-top: 1px solid var(--line);
  padding-top: 22px;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}
.identity small {
  color: var(--muted);
}
.avatar {
  background: var(--ink);
  color: var(--paper);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 600 13px/1 var(--sans);
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* ---------- Main column ---------- */

.portal-main {
  min-width: 0;
  padding: 40px 44px 64px;
}
.portal-heading {
  display: flex;
  justify-content: space-between;
  gap: 25px;
  align-items: start;
}
.portal h1 {
  font-size: 38px;
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
}
.portal .eyebrow {
  margin-bottom: 12px;
  color: var(--muted);
}
.status {
  font: 11px var(--mono);
  letter-spacing: 0.06em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 9px 14px;
  white-space: nowrap;
}

/* ---------- Metric tiles ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: 16px;
  margin: 30px 0;
}
.metrics article {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.metrics p {
  font-size: 13px;
  margin: 0;
  color: var(--muted);
}
.metrics strong {
  display: block;
  font-size: 38px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-top: 6px;
}
.metrics small {
  font-size: 20px;
  color: var(--muted);
}
.metrics article > span {
  font-size: 12px;
  color: var(--muted);
}
.metric-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}
.trend {
  font: 11px/1 var(--mono);
  letter-spacing: 0.04em;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.trend.good {
  color: var(--signal, var(--accent));
  background: color-mix(in srgb, var(--signal, var(--accent)) 12%, transparent);
}
.sparkline {
  display: block;
  width: 100%;
  height: 38px;
  margin: 12px 0 8px;
  overflow: visible;
}
.sparkline .spark-line {
  fill: none;
  stroke: var(--signal, var(--accent));
  stroke-width: 1.75;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.sparkline .spark-fill {
  fill: color-mix(in srgb, var(--signal, var(--accent)) 12%, transparent);
  stroke: none;
}
.sparkline .spark-dot {
  fill: var(--signal, var(--accent));
}
.sparkline .spark-target {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  opacity: 0.7;
  vector-effect: non-scaling-stroke;
}

/* ---------- Project card ---------- */

.project {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
}
.project-title {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}
.portal h2 {
  font-size: 25px;
  letter-spacing: -0.025em;
}
.project p {
  font-size: 14px;
}
.pill {
  font: 500 12px/1.4 var(--sans);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  align-self: start;
  display: inline-block;
  white-space: nowrap;
}
.pill.active {
  background: color-mix(in srgb, var(--signal, var(--accent)) 14%, transparent);
  border-color: color-mix(
    in srgb,
    var(--signal, var(--accent)) 35%,
    transparent
  );
  color: var(--signal, var(--accent));
}
.pill.done {
  background: color-mix(in srgb, var(--ink) 10%, transparent);
}
.route {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
  padding: 0;
  margin: 28px 0;
  gap: 15px;
}
.route li {
  border-top: 3px solid var(--hairline);
  padding-top: 12px;
  font-size: 14px;
}
.route li span {
  display: block;
  font-size: 12px;
  margin-top: 5px;
  color: var(--muted);
}
.route .done {
  border-color: var(--muted);
}
.route .current {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}
.next-step {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  align-items: baseline;
  border-top: 1px solid var(--hairline);
  padding-top: 20px;
  font-size: 13px;
}
.next-step > span:last-child {
  color: var(--muted);
  margin-left: auto;
}

/* ---------- Section headings ---------- */

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 48px;
  gap: 20px;
}
.section-heading h2 {
  margin: 0 0 18px;
}
.section-heading > span {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- Timeline ---------- */

.timeline {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 26px 26px 22px;
  box-shadow: var(--shadow);
}
.timeline-scroll {
  overflow-x: auto;
  padding-bottom: 4px;
}
.timeline-rail {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  list-style: none;
  margin: 0;
  padding: 34px 0 0;
  min-width: 620px;
}
.timeline-rail:before {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--hairline);
}
.timeline-rail:after {
  content: "";
  position: absolute;
  top: 8px;
  left: 0;
  width: 62.5%;
  height: 2px;
  background: var(--signal, var(--accent));
}
.timeline-rail li {
  position: relative;
  padding-right: 20px;
}
.timeline-node {
  position: absolute;
  top: -34px;
  left: 0;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--hairline);
  z-index: 1;
}
.timeline-rail .done .timeline-node {
  background: var(--signal, var(--accent));
  border-color: var(--signal, var(--accent));
}
.timeline-rail .current .timeline-node {
  background: var(--paper);
  border-color: var(--signal, var(--accent));
  box-shadow: 0 0 0 4px
    color-mix(in srgb, var(--signal, var(--accent)) 18%, transparent);
}
.timeline-date {
  display: block;
  font: 11px var(--mono);
  letter-spacing: 0.05em;
  color: var(--muted);
}
.timeline-rail strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
  margin: 4px 0 4px;
}
.timeline-rail p {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}
.timeline-rail .current strong {
  color: var(--signal, var(--accent));
}

.schedule {
  list-style: none;
  margin: 26px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--hairline);
  display: grid;
  gap: 2px;
}
.schedule li {
  display: grid;
  grid-template-columns: 92px 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 13px 12px;
  border-radius: 6px;
  font-size: 14px;
}
.schedule li:hover {
  background: var(--surface);
}
.schedule li.is-next {
  background: color-mix(in srgb, var(--signal, var(--accent)) 7%, transparent);
}
.schedule-date {
  font: 12px var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
}
.schedule li.is-next .schedule-date,
.schedule li.is-next strong {
  color: var(--signal, var(--accent));
}
.schedule-owner {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.schedule strong {
  font-weight: 550;
}

/* ---------- Objectives ---------- */

.objective {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto;
  align-items: center;
  gap: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 22px 24px;
  margin-bottom: 12px;
}
.objective h3 {
  font-size: 17px;
  font-weight: 550;
  line-height: 1.4;
  margin: 0 0 8px;
}
.objective p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}
.objective .eyebrow {
  font-size: 10px;
  margin-bottom: 8px;
}
.objective > .pill {
  justify-self: start;
}
.objective .button {
  padding: 11px 14px;
  font-size: 12px;
}
.objective-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}
.objective-progress small {
  font-size: 12px;
  color: var(--muted);
}
progress {
  display: block;
  width: 100%;
  height: 8px;
  margin: 12px 0;
  appearance: none;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  accent-color: var(--accent);
  background: var(--surface-2);
  color: var(--accent);
}
progress::-webkit-progress-bar {
  background: var(--surface-2);
  border-radius: 999px;
}
progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}
progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}
.outline-button {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  min-height: 44px;
  transition:
    background 0.18s,
    border-color 0.18s;
}
.outline-button:hover {
  background: var(--surface-2);
  border-color: var(--muted);
}
.outline-button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* ---------- Activity ---------- */

.activity-day {
  font: 11px var(--mono);
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 26px 0 6px;
}
.activity-day:first-of-type {
  margin-top: 10px;
}
.activity-list {
  list-style: none;
  padding: 0 0 0 8px;
  margin: 0;
  position: relative;
}
.activity-list:before {
  content: "";
  position: absolute;
  left: 11px;
  top: 14px;
  bottom: 14px;
  width: 1px;
  background: var(--hairline);
}
.activity-list li {
  display: flex;
  gap: 18px;
  padding: 14px 0;
  position: relative;
}
.activity-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--paper);
  margin-top: 7px;
  flex-shrink: 0;
  z-index: 1;
}
.activity-dot.client {
  background: var(--paper);
  border: 2px solid var(--muted);
}
.activity-list strong {
  font-size: 15px;
  font-weight: 550;
}
.activity-list p {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 8px;
}
.activity-list li div > span {
  font-size: 14px;
}
.activity-tag {
  font: 10px var(--mono);
  letter-spacing: 0.07em;
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  margin-left: 8px;
  white-space: nowrap;
}

/* ---------- Behind the scenes ---------- */

.behind {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 34px;
  margin-top: 48px;
}
.backend-flow {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
}
.backend-flow article > span {
  font: 12px var(--mono);
  color: var(--copper);
}
.backend-flow h3 {
  font-size: 17px;
  margin: 8px 0;
}
.backend-flow p {
  font-size: 14px;
}
.demo-note {
  font-size: 12px;
  color: var(--muted);
}
.behind .demo-note {
  border-top: 1px solid color-mix(in srgb, var(--paper) 25%, transparent);
  padding-top: 20px;
  margin-bottom: 0;
}

/* ---------- Dialog ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  width: min(520px, calc(100% - 32px));
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 30px 70px -30px #00000059;
}
dialog::backdrop {
  background: #0b1f3399;
}
dialog h2 {
  font-size: 30px;
  letter-spacing: -0.025em;
  margin: 0 0 10px;
}
dialog p {
  font-size: 14px;
}
dialog label {
  display: block;
  font-size: 14px;
  margin: 18px 0 7px;
}
dialog input,
dialog textarea {
  box-sizing: border-box;
  width: 100%;
  font: 16px var(--sans);
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
}
.dialog-actions {
  display: flex;
  justify-content: end;
  gap: 12px;
  margin-top: 25px;
}

/* ---------- Dark mode tweaks for new components ---------- */

html[data-theme="dark"] .timeline,
html[data-theme="dark"] .metrics article,
html[data-theme="dark"] .objective {
  background: color-mix(in srgb, var(--ink) 6%, var(--paper));
}
html[data-theme="dark"] .timeline-node {
  background: var(--paper);
}
html[data-theme="dark"] .activity-dot {
  box-shadow: 0 0 0 4px var(--paper);
}

@media (prefers-reduced-motion: reduce) {
  .portal-sidebar nav a,
  .outline-button,
  .button {
    transition: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .portal {
    grid-template-columns: 210px 1fr;
  }
  .portal-main {
    padding: 28px;
  }
  .portal-heading {
    display: block;
  }
  .status {
    display: inline-block;
    margin-top: 4px;
  }
  .objective {
    grid-template-columns: 1fr 1fr;
  }
  .objective > button {
    justify-self: start;
    grid-column: 1 / -1;
  }
  .schedule li {
    grid-template-columns: 86px 1fr auto;
  }
  .schedule-owner {
    display: none;
  }
}

@media (max-width: 720px) {
  .portal {
    display: block;
  }
  .portal-sidebar {
    padding: 20px 22px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    position: static;
  }
  .portal-sidebar nav {
    display: flex;
    flex-wrap: wrap;
    margin: 14px 0 0;
    gap: 4px;
  }
  .portal-sidebar nav a {
    padding: 8px 12px;
    border-left: 0;
    border: 1px solid var(--line);
  }
  .portal-sidebar nav a.is-current {
    border-color: var(--signal, var(--accent));
  }
  .identity,
  .sidebar-summary,
  .portal-sidebar > p.muted {
    display: none;
  }
  .portal-main {
    padding: 24px 20px 48px;
  }
  .portal h1 {
    font-size: 30px;
  }
  .metrics {
    grid-template-columns: 1fr;
  }
  .project {
    padding: 20px;
  }
  .project-title {
    display: block;
  }
  .route {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  .timeline {
    padding: 20px;
  }
  .schedule li {
    grid-template-columns: 1fr auto;
    gap: 6px 14px;
    padding: 12px 10px;
  }
  .schedule-date {
    grid-column: 1 / -1;
  }
  .objective {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 20px;
  }
  .backend-flow {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .behind {
    padding: 24px;
  }
  .section-heading {
    align-items: start;
  }
  .section-heading > span {
    max-width: 130px;
    text-align: right;
  }
  .portal .header {
    gap: 15px;
  }
}
