/* ════════════════════════════════════════════════════════════
   Client Portal — builds on home.css (Swiss tokens, chrome) and
   lookup.css (form fields, guide, record view). Here: the sign-in
   steps, the step-aware guide, and the profile editor.
   ════════════════════════════════════════════════════════════ */

/* ─── Sign-in steps ────────────────────────────────────────── */
.sw-lookup[hidden] { display: none; }
.sw-portal-step { display: flex; flex-direction: column; gap: 24px; }
.sw-portal-step[hidden] { display: none; }
.sw-step-title {
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: var(--sw-weight-display);
  font-stretch: var(--sw-width-display); letter-spacing: -0.025em; line-height: 1;
}
.sw-step-lead { color: var(--sw-ink-2); text-wrap: pretty; margin-top: -8px; }

.sw-form-message.is-info { border-left-color: var(--sw-ink); background: var(--sw-paper); color: var(--sw-ink); }

.sw-field input.sw-otp {
  min-height: 72px; padding-left: calc(18px + 0.5em);
  font-size: 2rem; font-weight: var(--sw-weight-display); letter-spacing: 0.5em; text-align: center;
  font-feature-settings: "kern", "tnum", "lnum";
}
.sw-field input.sw-otp::placeholder { color: var(--sw-rule); letter-spacing: 0.5em; }

.sw-text-link {
  padding: 0; border: none; background: none; cursor: pointer;
  font: inherit; font-weight: var(--sw-weight-strong); color: var(--sw-ink);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px;
  transition: color 150ms var(--sw-ease);
}
.sw-text-link:hover { color: var(--sw-red); }
.sw-text-link[disabled] { opacity: 0.5; cursor: default; }

/* ─── Guide doubles as a progress register ─────────────────── */
.sw-guide-steps[hidden] { display: none; }
.sw-guide-steps li { transition: opacity 200ms var(--sw-ease); }
.sw-guide-steps .sw-guide-no { color: #A5A5AC; transition: color 200ms var(--sw-ease); }
.sw-guide-steps li[aria-current="step"] .sw-guide-no { color: var(--sw-red); }
.sw-guide-steps li[aria-current="step"] { box-shadow: inset 0 3px 0 -1px var(--sw-red); }
.sw-guide-steps li.is-done .sw-guide-no { color: var(--sw-ink); }

/* ─── Signed-in: welcome header ────────────────────────────── */
.sw-portal-welcome { display: flex; flex-direction: column; gap: 16px; padding-bottom: clamp(32px, 4vw, 56px); }
.sw-portal-welcome .sw-kicker { grid-column: auto; padding-right: 0; background: none; }
.sw-portal-greeting {
  font-size: var(--sw-text-hero-title); font-weight: var(--sw-weight-display); font-stretch: var(--sw-width-display);
  line-height: 0.95; letter-spacing: -0.035em; text-wrap: balance;
}
.sw-portal-session { color: var(--sw-ink-2); max-width: 60ch; text-wrap: pretty; }
.sw-portal-session strong { color: var(--sw-ink); font-weight: var(--sw-weight-strong); }

/* ─── Signed-in: notice above the vault ─────────────────────── */
.sw-portal-result .sw-form-message { margin-bottom: 24px; }
body.home .sw-portal-result .sw-btn-accent { cursor: pointer; }

/* ─── Profile editor (inside .sw-record) ────────────────────── */
.sw-profile-fields {
  grid-column: 4 / -1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px var(--sw-col-gap);
}
.sw-profile-fields .sw-field-wide { grid-column: 1 / -1; }
.sw-profile-fields .sw-field input { min-height: 52px; font-size: 1.0625rem; letter-spacing: 0; font-variant-numeric: normal; }
.sw-profile-fields .sw-field label abbr { text-decoration: none; color: var(--sw-red); }
.sw-profile-message { margin: 28px 0 0; }
.sw-profile-actions {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--sw-col-gap);
  padding: clamp(28px, 3.5vw, 44px) 0 0;
}
.sw-profile-actions > div { grid-column: 4 / -1; display: flex; flex-direction: column; gap: 20px; }
.sw-profile-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.sw-profile-buttons .sw-btn { min-height: 52px; padding: 0 28px; }

@media (max-width: 768px) {
  .sw-profile-fields, .sw-profile-actions > div { grid-column: 1 / -1; }
  .sw-profile-fields { grid-template-columns: 1fr; }
  .sw-profile-actions { grid-template-columns: 1fr; }
  .sw-profile-buttons .sw-btn { flex: 1 1 100%; }
  .sw-portal-result .vv-section-title { flex-wrap: wrap; row-gap: 6px; }
  .sw-portal-result .vv-section-title .vv-count { flex-basis: 100%; }
}

/* ─── Signed-in: notifications ─────────────────────────────── */
.sw-portal-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.sw-notify-btn { gap: 10px; }
.sw-notify-btn[hidden] { display: none; }
.sw-notify-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  background: var(--sw-red); color: var(--sw-white); font-size: 0.75rem; font-weight: 800; font-feature-settings: "tnum";
}
.sw-notify-count[hidden] { display: none; }
body.home .sw-notify-btn:hover .sw-notify-count { background: var(--sw-white); color: var(--sw-red); }

.sw-notify-panel { margin: 0 0 clamp(32px, 4vw, 48px); border-top: 1px solid var(--sw-ink); animation: sw-notify-in 320ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.sw-notify-panel[hidden] { display: none; }
@keyframes sw-notify-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.sw-notify-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 18px 0 14px; border-bottom: 1px solid var(--sw-rule); }
.sw-notify-head h2 { font-size: var(--sw-text-lg); font-weight: var(--sw-weight-strong); }
.sw-notify-head h2:focus { outline: none; }
.sw-notify-list { list-style: none; max-height: 420px; overflow-y: auto; }
.sw-notice { padding: 16px 0 16px 16px; border-bottom: 1px solid var(--sw-rule); box-shadow: inset 3px 0 0 transparent; }
.sw-notice.is-new { box-shadow: inset 3px 0 0 var(--sw-red); background: linear-gradient(90deg, #FDF2F4, transparent 60%); }
.sw-notice-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-size: var(--sw-text-sm); color: var(--sw-ink-2); }
.sw-notice-new { font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--sw-red); }
.sw-notice-tn { font-weight: 700; color: var(--sw-ink); font-feature-settings: "tnum"; }
.sw-notice-title { margin-top: 4px; font-size: 1.0625rem; font-weight: var(--sw-weight-strong); }
.sw-notice-detail { margin-top: 2px; color: var(--sw-ink-2); }
.sw-notice .sw-text-link { margin-top: 8px; font-size: var(--sw-text-sm); }
.sw-notice-empty { padding: 18px 0; color: var(--sw-ink-2); }

/* ─── Signed-in: shipments on this account ─────────────────── */
#shipmentsView[hidden] { display: none; }
.sw-ships { margin-top: clamp(40px, 5vw, 72px); border-top: 1px solid var(--sw-ink); }
.sw-ships-head { display: flex; align-items: baseline; gap: 14px; padding: 24px 0 18px; border-bottom: 1px solid var(--sw-rule); }
.sw-ships-head h2 { font-size: var(--sw-text-h2); font-weight: var(--sw-weight-display); font-stretch: var(--sw-width-display); letter-spacing: -0.03em; line-height: 1; }
.sw-ships-count {
  font-size: clamp(1.5rem, 1rem + 1.4vw, 2.25rem); font-weight: var(--sw-weight-display); font-stretch: var(--sw-width-numeral);
  color: var(--sw-red); font-feature-settings: "kern", "tnum", "lnum"; line-height: 1;
}
.sw-ships-list { list-style: none; }
.sw-ship { border-bottom: 1px solid var(--sw-rule); animation: sw-ship-in 480ms cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes sw-ship-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.sw-ship-row {
  display: grid; grid-template-columns: minmax(150px, 1.1fr) minmax(0, 2fr) minmax(120px, 1fr) minmax(150px, 1fr) auto;
  align-items: center; gap: 12px 20px; padding: 18px 0;
}
.sw-ship-tn { font-weight: 800; font-size: 1.0625rem; letter-spacing: 0.01em; font-feature-settings: "tnum"; }
.sw-ship-route { color: var(--sw-ink-2); overflow-wrap: anywhere; }
.sw-ship-label { display: block; font-size: var(--sw-text-sm); color: var(--sw-ink-2); }
.sw-ship-value { font-weight: 600; }
.sw-ship-status .status-badge {
  display: inline-flex; align-items: center; gap: 8px; padding: 0; background: none; border: none; border-radius: 0;
  font-weight: var(--sw-weight-strong); font-size: 0.9375rem; color: var(--sw-ink); text-transform: none; letter-spacing: 0; box-shadow: none;
}
.sw-ship-status .status-badge::before { content: ""; width: 9px; height: 9px; background: currentColor; }
.sw-ship-status :is(.status-delivered) { color: #0A7D3E; }
.sw-ship-status :is(.status-in-transit, .status-out-for-delivery) { color: #1F5FAD; }
.sw-ship-status :is(.status-on-hold, .status-cancelled) { color: var(--sw-red); }
.sw-ship-status :is(.status-processing, .status-in-customs) { color: #A15C00; }
.sw-ship-toggle { min-height: 40px; padding: 0 16px; font-size: 0.875rem; white-space: nowrap; }
.sw-ship.is-open .sw-ship-toggle { background: var(--sw-ink); color: var(--sw-white); }
.sw-ship-detail { padding: 0 0 32px; }
.sw-ship-detail[hidden] { display: none; }
.sw-ship-detail .result-card { border-top-color: var(--sw-rule); }
.sw-ships-empty { padding: 24px 0; color: var(--sw-ink-2); }
@media (prefers-reduced-motion: reduce) { .sw-ship, .sw-notify-panel { animation: none; } }

@media (max-width: 900px) {
  .sw-ship-row { grid-template-columns: 1fr auto; }
  .sw-ship-route, .sw-ship-eta { grid-column: 1 / -1; }
  .sw-ship-toggle { grid-column: 1 / -1; justify-self: start; }
}
/* Box switcher: a client with several vault boxes opens the others without signing in again */
.sw-box-switch { display: inline-grid; gap: 4px; max-width: 100%; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.sw-box-switch select { max-width: 100%; text-transform: none; letter-spacing: 0; padding: 9px 30px 9px 12px; border: 1px solid currentColor; border-radius: 0; background: transparent; color: inherit;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.85rem; font-weight: 600; cursor: pointer; }
.sw-box-switch select:focus-visible { outline: 2px solid var(--sw-red, #E30613); outline-offset: 2px; }
.sw-box-switch select:disabled { opacity: 0.6; cursor: progress; }
@media (max-width: 600px) { .sw-box-switch, .sw-box-switch select { width: 100%; } }

/* "Sign in as client": an administrator is looking at this portal (js/client-portal.js) */
.sw-admin-view { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  margin: 0 0 24px; padding: 14px 18px; border: 1px solid var(--sw-ink, #111); border-left: 6px solid var(--sw-red, #E30613);
  background: repeating-linear-gradient(-45deg, transparent 0 10px, rgba(227, 6, 19, 0.05) 10px 20px); }
.sw-admin-view p { margin: 0; flex: 1 1 280px; }
.sw-admin-view strong { color: var(--sw-red, #E30613); text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.85em; }

/* Notifications in red: the button, its bell (rings on new ones, js/portal-motion.js) and the toasts */
body.home .sw-notify-btn.sw-notify-btn { background: var(--sw-red); border-color: var(--sw-red); color: var(--sw-white);
  transition: background-color 160ms cubic-bezier(0.22, 1, 0.36, 1), transform 140ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms; }
body.home .sw-notify-btn.sw-notify-btn:hover { background: color-mix(in srgb, var(--sw-red) 86%, #000); border-color: color-mix(in srgb, var(--sw-red) 86%, #000); color: var(--sw-white);
  box-shadow: 0 10px 22px -12px color-mix(in srgb, var(--sw-red) 80%, transparent); }
body.home .sw-notify-btn.sw-notify-btn:active { transform: scale(0.97); }
.sw-notify-btn .sw-notify-count, body.home .sw-notify-btn:hover .sw-notify-count { background: var(--sw-white); color: var(--sw-red); }
.sw-bell { width: 1.1em; height: 1.1em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round;
  transform-origin: 50% 12%; }
.sw-notify-btn.has-unread .sw-bell { animation: sw-bell-idle 4s ease-in-out 1.5s infinite; }
@keyframes sw-bell-idle { 0%, 88%, 100% { transform: rotate(0); } 91% { transform: rotate(-14deg); } 94% { transform: rotate(10deg); } 97% { transform: rotate(-6deg); } }
.sw-notice.is-new .sw-notice-new { display: inline-block; padding: 2px 7px; background: var(--sw-red); color: var(--sw-white); }
body.page-portal .vault-toast { background: var(--sw-red); color: #fff; border-color: rgba(0, 0, 0, 0.3); }
body.page-portal .vault-toast * { color: inherit; }
@media (prefers-reduced-motion: reduce) { .sw-notify-btn.has-unread .sw-bell { animation: none; } }
