/* =========================================================================
   parts.css — view-level layout: auth, wizard, provisioning, server, console.
   Loaded last so it can refine the shared primitives in components.css.
   ========================================================================= */

/* ---------- shells & typography utilities ---------- */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.h1 {
  font-size: clamp(2rem, 4.4vw, 2.9rem);
}

.h2 {
  font-size: clamp(1.45rem, 2.4vw, 1.8rem);
}

.h3 {
  font-size: 1.28rem;
}

.section-alt {
  background: var(--bg-2);
}

.section-head-copy {
  flex: 1 1 420px;
  max-width: 70ch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-head-aside {
  margin-left: auto;
}

.hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: 44px;
  align-items: center;
}

.region-note {
  font-size: 0.88rem;
  color: var(--text-2);
}

.badge-info {
  border-color: rgba(94, 159, 232, 0.34);
  background: rgba(94, 159, 232, 0.12);
  color: #b6d2f4;
}

/* anchors sit below the sticky header */
#specs,
#regions,
#rules,
#how {
  scroll-margin-top: calc(var(--header-h) + 20px);
}

@media (max-width: 940px) {
  .hero-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .section-head-aside {
    margin-left: 0;
  }
}

/* ---------- auth ---------- */

.auth-wrap {
  display: grid;
  grid-template-columns: minmax(0, 452px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-lg);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 4px;
}

.tick-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.9rem;
  color: var(--text-2);
}

.tick-list li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.tick-list svg {
  color: var(--accent);
  margin-top: 2px;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 580;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-btn:hover {
  color: #8ce8b3;
}

.field-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.83rem;
  font-weight: 580;
  color: var(--text-2);
}

.field-label svg {
  flex: none;
  color: var(--text-3);
}

.input-wrap {
  position: relative;
  display: block;
}

.input-lg {
  min-height: 50px;
  padding-right: 52px;
  font-size: 0.98rem;
}

.input-action {
  position: absolute;
  top: 50%;
  right: 7px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-3);
  cursor: pointer;
}

.input-action:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
}

.input-action.is-on {
  color: var(--accent);
}

.field.has-error .input {
  border-color: rgba(233, 115, 102, 0.66);
}

.strength {
  flex-direction: column;
  gap: 6px;
}

.strength-bars {
  display: flex;
  gap: 4px;
}

.strength-label {
  font-size: 0.78rem;
  color: var(--text-3);
}

.is-loading {
  pointer-events: none;
  opacity: 0.72;
}

@media (max-width: 980px) {
  .auth-wrap {
    grid-template-columns: minmax(0, 1fr);
    max-width: 520px;
  }

  .auth-card {
    max-width: none;
  }
}

/* ---------- cards, callouts, chips ---------- */

.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.9rem;
  color: var(--text-2);
}

.card-icon {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--accent);
  flex: none;
}

.card-icon.is-info {
  color: var(--info);
  border-color: rgba(94, 159, 232, 0.3);
}

.card-icon.is-warn {
  color: var(--warn);
  border-color: rgba(222, 146, 85, 0.32);
}

.callout-icon {
  color: var(--text-3);
  margin-top: 1px;
}

.callout-info .callout-icon {
  color: var(--info);
}

.callout-warn .callout-icon {
  color: var(--warn);
}

.callout-accent .callout-icon {
  color: var(--accent);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-icon {
  width: 40px;
  min-height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.btn-quiet {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-2);
}

.btn-quiet:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

/* ---------- dashboard ---------- */

.server-card-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.server-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.18rem;
  font-weight: 640;
  letter-spacing: -0.01em;
}

.server-card-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding-top: 14px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-3);
}

.server-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.quota-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-2);
}

.quota-bar,
.bar-term {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  overflow: hidden;
}

.quota-bar i,
.bar-term i {
  position: absolute;
  inset: 0 auto 0 0;
  display: block;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) 0%, #8ce8b3 100%);
}

.bar-term.is-low i {
  background: linear-gradient(90deg, var(--warn) 0%, #f0b481 100%);
}

.meta-grid-1 {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 56px 28px;
  text-align: center;
  border-radius: var(--r-xl);
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
}

.empty-mark {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: var(--r-xl);
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

@media (max-width: 760px) {
  .server-side {
    align-items: flex-start;
  }
}

/* ---------- create wizard ---------- */

.wizard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 268px;
  gap: 24px;
  align-items: start;
}

.wizard-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 26px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.wizard-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 232px;
}

.wizard-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.nav-gap {
  flex: 1;
}

.wizard-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wizard-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.86rem;
  color: var(--text-2);
}

.wizard-summary div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.wizard-summary b {
  color: var(--text);
  font-weight: 580;
}

.step-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option {
  width: 100%;
  padding: 0;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.option:hover {
  border-color: var(--border-strong);
}

.option.is-selected {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(95, 207, 142, 0.12) 0%, rgba(95, 207, 142, 0.03) 100%);
}

.option.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.option-inner {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
}

.option-logo {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.24);
  color: var(--accent);
}

.option-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.option-title {
  font-weight: 600;
}

.option-sub {
  font-size: 0.83rem;
  color: var(--text-3);
}

.region-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.region-row.is-option {
  display: block;
  padding: 0;
}

.region-inner {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 128px 104px;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
}

.region-id {
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--text-3);
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.review-cell {
  padding: 13px 15px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.18);
}

.review-val {
  margin-top: 4px;
  font-weight: 580;
}

@media (max-width: 900px) {
  .wizard {
    grid-template-columns: minmax(0, 1fr);
  }

  .region-inner {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    row-gap: 8px;
  }

  .region-inner .region-ping {
    grid-column: 2 / -1;
  }
}

/* ---------- provisioning ---------- */

.deploy {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.deploy-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: center;
  align-items: center;
}

.deploy-grid {
  display: grid;
  grid-template-columns: minmax(0, 320px) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
  padding: 26px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.deploy-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 260px;
}

.deploy-ring {
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 10;
}

.ring-arc {
  fill: none;
  stroke: url(#deployGrad);
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.deploy-core {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  text-align: center;
}

.deploy-core-icon {
  color: var(--accent);
}

.deploy-pct {
  font-size: 1.9rem;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.deploy-stage-label {
  max-width: 190px;
  font-size: 0.82rem;
  color: var(--text-3);
}

.deploy-orbit {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.deploy-tool {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  border: 1px solid var(--accent-line);
  background: rgba(14, 21, 18, 0.92);
  color: var(--accent);
}

.deploy-aside {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.deploy-stages {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.deploy-stage-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: var(--r);
  font-size: 0.9rem;
  color: var(--text-3);
  transition: color 0.2s ease, background 0.2s ease;
}

.deploy-stage-row.is-current {
  color: var(--text);
  background: var(--accent-soft);
}

.deploy-stage-row.is-done {
  color: var(--text-2);
}

.deploy-stage-icon {
  display: grid;
  place-items: center;
  color: var(--text-3);
}

.deploy-stage-row.is-current .deploy-stage-icon,
.deploy-stage-row.is-done .deploy-stage-icon {
  color: var(--accent);
}

.deploy-log {
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: #060b09;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.7;
  color: #cfe0d8;
  min-height: 132px;
}

.deploy-log-line {
  color: var(--text-2);
}

.deploy-log-line b {
  color: var(--accent);
  font-weight: 500;
}

@media (max-width: 900px) {
  .deploy-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }

  .deploy-stage {
    min-height: 220px;
  }
}

/* ---------- server detail ---------- */

.server-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: 24px;
  align-items: start;
}

.server-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 20px;
  margin-bottom: 22px;
}

.page-head-actions {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.stat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-3);
}

.spark-host {
  margin-top: 10px;
  height: 34px;
}

.power-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.access-row {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.access-row:last-child {
  border-bottom: 0;
}

.access-val {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
  overflow-wrap: anywhere;
}

.code-line {
  padding: 12px 14px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: #060b09;
  font-family: var(--mono);
  font-size: 0.83rem;
  color: #cfe0d8;
  overflow-x: auto;
}

@media (max-width: 940px) {
  .server-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .access-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .access-row .access-val {
    grid-column: 1 / -1;
  }
}

/* ---------- console ---------- */

.terminal-tall .terminal-body {
  height: 440px;
}

.terminal-bar-aside {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.76rem;
  color: var(--text-3);
}

.terminal-prompt-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: #0a1210;
}

.spin-dot {
  display: inline-grid;
  place-items: center;
  color: var(--accent);
}

/* ---------- rules modal footer ---------- */

.modal-foot > :first-child {
  flex: 1 1 200px;
  min-width: 0;
}

.modal-foot .btn {
  flex: 0 0 auto;
}

.modal-head {
  position: sticky;
  top: -28px;
  z-index: 1;
  padding-top: 4px;
  background: linear-gradient(180deg, #202e29 74%, rgba(32, 46, 41, 0) 100%);
}

@media (max-width: 620px) {
  .modal-foot {
    flex-direction: column;
    align-items: stretch;
  }

  .modal-foot .btn {
    width: 100%;
  }
}

/* =========================================================================
   Corrections found during visual QA of the wizard, review step and modal.
   Flexbox is used where child counts vary, so nothing can overlap.
   ========================================================================= */

.option-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.option-logo {
  flex: none;
}

.option-body {
  flex: 1 1 auto;
  min-width: 0;
}

.option-inner > .badge {
  flex: none;
  margin-left: auto;
}

.region-inner {
  display: flex;
  align-items: center;
  gap: 14px;
}

.region-inner > * {
  min-width: 0;
}

.region-inner > :nth-child(2) {
  flex: 1 1 auto;
}

.region-inner > .region-ping {
  flex: 0 0 118px;
}

.region-inner > .badge {
  flex: none;
  margin-left: auto;
}

/* label / value pairs must stack, they are spans in the markup */
.meta-key,
.review-val,
.access-val,
.stat-sub {
  display: block;
}

/* the 268px sidebar is too narrow for auto-fit grids */
.wizard-side .meta-grid,
.wizard-side .meta-grid-1,
.wizard-side .review-grid,
.wizard-summary .meta-grid,
.server-side .meta-grid,
.server-side .meta-grid-1 {
  grid-template-columns: minmax(0, 1fr);
}

.wizard-summary .meta-cell,
.server-side .meta-cell {
  padding: 11px 14px;
}

/* keep both rule-gate buttons on screen even when the list scrolls */
.modal-foot {
  position: sticky;
  bottom: -28px;
  padding-bottom: 8px;
  background: linear-gradient(180deg, rgba(21, 30, 27, 0) 0%, #161f1c 26%, #161f1c 100%);
}

/* -------------------------------------------------------------------------
   Wizard rows wrap their content in a single .option-inner / .region-inner
   span, so the outer button must be a plain block instead of the 3-column
   grid used by the static cards in components.css.
   ------------------------------------------------------------------------- */

.option-list .option,
button.option {
  display: block;
  grid-template-columns: none;
  padding: 0;
  gap: 0;
}

.option-inner {
  padding: 15px 16px;
}

.option-title,
.option-name {
  font-weight: 620;
  font-size: 0.98rem;
}

.option-body .option-sub {
  white-space: normal;
}

/* .region-id here is the text column of a wizard row, not a mono identifier */
.region-inner .region-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  font-family: var(--sans);
  font-size: 0.95rem;
  color: var(--text);
}

.region-inner .region-name {
  display: block;
}

.region-inner .region-flag {
  flex: 0 0 30px;
}

.ping-bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 999px;
  background: var(--accent);
  transition: width 0.5s ease;
}

.ping-bar.is-fair > i {
  background: var(--warn);
}

.ping-bar.is-poor > i {
  background: var(--danger);
}

/* opaque sticky footer so the rules list scrolls cleanly underneath it */
.modal-foot {
  background: #161f1c;
  box-shadow: 0 -12px 18px -12px rgba(0, 0, 0, 0.9);
}

/* -------------------------------------------------------------------------
   Deploy log lines are single text spans, so the two-column grid in
   animations.css squeezed every word onto its own row.
   ------------------------------------------------------------------------- */

.deploy-log .deploy-log-line {
  display: block;
  grid-template-columns: none;
  position: relative;
  padding-left: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.deploy-log .deploy-log-line::before {
  content: "\203a";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  opacity: 0.7;
}

.deploy-log .deploy-log-line.is-done::before {
  content: "\2713";
}

.deploy-grid {
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 30px;
  align-items: center;
}

@media (max-width: 900px) {
  .deploy-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* -------------------------------------------------------------------------
   .hero only wraps .hero-inner, which is the real two-column grid.
   Without this the whole hero was squeezed into the first grid column.
   ------------------------------------------------------------------------- */

.hero {
  display: block;
  grid-template-columns: none;
}

/* -------------------------------------------------------------------------
   Phone header: brand stays on one line, the badges / account controls move
   to their own row instead of overflowing the viewport.
   ------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .site-header .wrap {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    min-height: 0;
    padding: 10px 16px 12px;
  }

  .brand {
    flex: none;
  }

  .brand-name {
    white-space: nowrap;
  }

  .header-spacer {
    display: none;
  }

  .header-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 6px;
  }

  .header-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  #specs,
  #regions,
  #rules {
    scroll-margin-top: 128px;
  }
}

/* -------------------------------------------------------------------------
   Wizard summary panel: one label/value pair per row inside a 260px column.
   ------------------------------------------------------------------------- */

.meta-grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
}

.wizard-summary .meta-grid,
.wizard-summary .meta-grid-1 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: row;
}

.wizard-summary .meta-cell,
.meta-grid-1 .meta-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  min-width: 0;
  padding: 11px 14px;
}

.wizard-summary .meta-key,
.meta-grid-1 .meta-key {
  display: block;
  width: 100%;
}

.wizard-summary .meta-val,
.meta-grid-1 .meta-val {
  display: block;
  width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
