@import "tokens.css";

/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-stack);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  background: var(--color-bg);
  color: var(--color-fg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 var(--space-2);
}

h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
}

h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

p {
  margin: 0 0 var(--space-3);
}

a {
  color: var(--color-link);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--color-accent-strong);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--color-surface);
  color: var(--color-link);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  z-index: 10;
}

.skip-link:focus {
  left: var(--space-2);
  top: var(--space-2);
}

/* ---------- Layout ---------- */

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  min-height: 4.5rem;
  padding: var(--space-2) max(var(--space-4), (100% - var(--content-width)) / 2 + var(--space-4));
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-fg);
  text-decoration: none;
}

.brand:hover {
  color: var(--color-fg);
}

/* Brand mark: a petrol tile drawn in CSS, no image request. */
.brand::before {
  content: "";
  width: 2rem;
  height: 2rem;
  border-radius: 9px;
  background: var(--color-accent);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: 0 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--color-fg-soft);
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--color-surface-muted);
  color: var(--color-fg);
}

.site-nav a[aria-current="page"] {
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-weight: 600;
}

.header-account {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.account-name {
  margin: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-weight: 600;
}

.account-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--color-muted);
}

.header-action {
  margin: 0;
}

.site-main {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  padding: var(--space-3) max(var(--space-4), (100% - var(--content-width)) / 2 + var(--space-4));
}

.site-footer p {
  margin: 0;
}

/* ---------- Text helpers ---------- */

.lede {
  color: var(--color-muted);
  font-size: 1rem;
}

.hint {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-target);
  padding: 0 1.125rem;
  border: 0;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button:hover {
  background: var(--color-accent-strong);
  color: var(--color-on-accent);
}

@media (prefers-color-scheme: dark) {
  .button:hover {
    background: var(--color-link);
  }
}

.button-secondary {
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-fg);
  font-weight: 500;
}

.button-secondary:hover {
  background: var(--color-surface-muted);
  color: var(--color-fg);
}

@media (prefers-color-scheme: dark) {
  .button-secondary:hover {
    background: var(--color-surface-muted);
  }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

/* Secondary action rendered as a button element (e.g. sign out). */
.link-button {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-fg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.link-button:hover {
  background: var(--color-surface-muted);
}

/* ---------- Status badges (text + dot; color never alone) ---------- */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  width: fit-content;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-neutral-fg);
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge[data-status="active"] {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.status-badge[data-status="grace_period"],
.status-badge[data-status="canceled_pending"] {
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}

.status-badge[data-status="revoked"] {
  background: var(--color-danger-bg);
  color: var(--color-danger-fg);
}

/* Ended states use a hollow dot as a shape cue in addition to the label. */
.status-badge[data-status="expired"]::before,
.status-badge[data-status="paused"]::before,
.status-badge[data-status="revoked"]::before {
  background: transparent;
  border: 1.5px solid currentColor;
}

.support-line {
  font-weight: 600;
}

.support-line[data-support="active"] {
  color: var(--color-fg);
}

.support-line[data-support="expiring_soon"] {
  color: var(--color-warning-fg);
}

.support-line[data-support="expired"],
.support-line[data-support="not_included"],
.support-line[data-support="unknown"] {
  color: var(--color-muted);
}

/* ---------- Page structure ---------- */

.page-head .lede,
.page-head .hint {
  margin: var(--space-1) 0 0;
}

.page-head-split {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.page-head-split .status-badge {
  margin: 0;
}

.panel {
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel > h2 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-3);
}

.panel > :last-child {
  margin-bottom: 0;
}

.panel-flush {
  padding: var(--space-3) 0 var(--space-2);
}

.panel-flush > h2 {
  padding: 0 var(--space-4);
  margin-bottom: var(--space-1);
}

.panel-centered {
  max-width: 35rem;
  width: 100%;
  margin: var(--space-5) auto;
  padding: var(--space-5);
}

.products > h2 {
  margin-bottom: var(--space-3);
}

/* Facts: label/value pairs (dates, support) */
.facts {
  margin: 0 0 var(--space-3);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-3);
}

.facts dt {
  font-size: 0.8125rem;
  color: var(--color-muted);
}

.facts dd {
  margin: 0.125rem 0 0;
  font-weight: 600;
}

/* "What needs your attention" */
.attention-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-2);
}

.attention-item {
  padding: var(--space-3);
  border-radius: 12px;
  background: var(--color-neutral-bg);
}

.attention-item[data-status="active"] {
  background: var(--color-accent-soft);
}

.attention-item[data-status="active"][data-support="expiring_soon"],
.attention-item[data-status="grace_period"],
.attention-item[data-status="canceled_pending"] {
  background: var(--color-warning-bg);
}

.attention-item[data-status="revoked"] {
  background: var(--color-danger-bg);
}

.attention-title {
  margin: 0;
  font-weight: 600;
}

.attention-item .hint {
  margin: 0.125rem 0 var(--space-2);
  color: var(--color-fg-soft);
}

.attention-action {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  font-weight: 600;
  font-size: var(--font-size-sm);
}

/* ---------- Dashboard cards ---------- */

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr));
  gap: var(--space-3);
}

.card {
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card > .actions {
  margin-top: auto;
  padding-top: var(--space-2);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-divider);
}

.card-head h3 {
  margin: 0;
}

.card-head h3 a {
  color: var(--color-fg);
  text-decoration: none;
}

.card-head h3 a:hover {
  color: var(--color-link);
  text-decoration: underline;
}

.card-head .status-badge {
  margin: 0;
  flex: none;
}

.empty-state {
  margin-top: var(--space-4);
  padding: var(--space-5) var(--space-4);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  text-align: center;
}

.empty-state p {
  max-width: 32rem;
  margin: 0 auto;
  color: var(--color-muted);
}

/* ---------- Product detail ---------- */

.breadcrumb {
  margin-bottom: calc(var(--space-3) - var(--space-5));
  font-size: var(--font-size-sm);
  color: var(--color-muted);
}

.callout {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  background: var(--color-neutral-bg);
  color: var(--color-fg);
}

.callout[data-status="active"] {
  background: var(--color-accent-soft);
}

.callout[data-status="grace_period"],
.callout[data-status="canceled_pending"] {
  background: var(--color-warning-bg);
}

.callout[data-status="revoked"] {
  background: var(--color-danger-bg);
}

.detail-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-4);
}

.detail-main {
  flex: 999 1 35rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.detail-side {
  flex: 1 1 20rem;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.link-list,
.notice-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.link-list li {
  padding: var(--space-2) var(--space-4);
}

.notice-list li {
  padding: var(--space-2) 0;
}

.link-list li + li,
.notice-list li + li {
  border-top: 1px solid var(--color-divider);
}

.link-list a {
  font-weight: 600;
}

.link-list .hint,
.notice-list p {
  margin: var(--space-1) 0 0;
}

.link-kind {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 0.0625rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.notice-list h3 {
  margin: 0;
  font-size: 1rem;
}

.notice-list p {
  color: var(--color-fg-soft);
  font-size: var(--font-size-sm);
}

/* ---------- Header extras and footer ---------- */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-4);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.footer-links a {
  color: var(--color-muted);
}

/* ---------- Forms in action rows ---------- */

.inline-form {
  display: inline-flex;
  margin: 0;
}

/* A POST button that looks like the attention link it replaces. */
.link-like {
  min-height: var(--touch-target);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-link);
  font: inherit;
  font-weight: 600;
  font-size: var(--font-size-sm);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-like:hover {
  color: var(--color-accent-strong);
}

.details-link {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-target);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.button-block {
  width: 100%;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--color-accent-soft);
  color: var(--color-link);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.tag-success {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}

.attention-item[data-kind="new-file"] {
  background: var(--color-accent-soft);
}

/* ---------- License panel ---------- */

.panel-license {
  overflow: hidden;
}

.panel-banner {
  margin: calc(-1 * var(--space-4)) calc(-1 * var(--space-4)) var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--color-accent-soft);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--font-size-sm);
}

.checksum {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--color-surface-muted);
  font-size: var(--font-size-sm);
}

.checksum-label {
  color: var(--color-muted);
}

.checksum code,
.notice-footer code {
  font-family: var(--font-mono);
  overflow-wrap: anywhere;
}

.table-scroll {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.history-table th {
  text-align: left;
  font-weight: 500;
  color: var(--color-muted);
}

.history-table th,
.history-table td {
  padding: var(--space-2) var(--space-3) var(--space-2) 0;
  border-bottom: 1px solid var(--color-divider);
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-status[data-status="active"] {
  color: var(--color-success-fg);
  font-weight: 600;
}

.history-status[data-status="revoked"] {
  color: var(--color-danger-fg);
}

/* ---------- Profile ---------- */

.page-narrow {
  width: 100%;
  max-width: 55rem;
  margin-inline: auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-3);
}

.field label {
  display: block;
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  min-height: var(--touch-target);
  padding: 0 0.75rem;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-fg);
  font: inherit;
}

.field [aria-invalid="true"] {
  border-color: var(--color-danger-fg);
}

.field .hint {
  margin: var(--space-1) 0 0;
}

.field-error {
  margin: var(--space-1) 0 0;
  color: var(--color-danger-fg);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.error-summary {
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  border: 1px solid var(--color-danger-fg);
  background: var(--color-danger-bg);
}

.error-summary h2 {
  font-size: var(--font-size-base);
}

.error-summary ul {
  margin: 0;
  padding-left: var(--space-4);
}

.saved-note {
  margin: 0;
  color: var(--color-success-fg);
  font-weight: 600;
}

.facts-divided {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
}

.account-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-accent);
  border-radius: 12px;
  background: var(--color-accent-soft);
}

.account-card p {
  margin: 0;
}

.account-card-name {
  font-weight: 600;
}

.account-card-state {
  margin-left: auto !important;
  color: var(--color-link);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

/* Another customer account the session can switch to (D-028): neutral,
   the active account keeps the accent. */
.account-card-option {
  border-color: var(--color-border);
  background: var(--color-surface);
}

.account-card-option + .account-card-option {
  margin-top: var(--space-2);
}

.account-card-option .button {
  margin-left: auto;
}

/* ---------- "No access" page ---------- */

.notice-panel {
  text-align: left;
}

.notice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  margin-bottom: var(--space-3);
  border-radius: 14px;
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
  font-size: 1.5rem;
  font-weight: 700;
}

.hint-box {
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border-radius: 12px;
  background: var(--color-surface-muted);
  font-size: var(--font-size-sm);
}

.hint-box p:last-child {
  margin: 0;
}

.notice-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-divider);
  font-size: var(--font-size-sm);
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  h1 {
    font-size: 1.625rem;
  }

  .site-header,
  .site-footer {
    padding-inline: var(--space-3);
  }

  .site-main {
    padding: var(--space-4) var(--space-3) var(--space-5);
  }

  .card {
    padding: var(--space-3);
  }

  .card .button,
  .card .inline-form {
    flex: 1 1 auto;
  }

  .card .inline-form .button {
    width: 100%;
  }

  .details-link {
    margin-left: 0;
  }

  .account-card-state,
  .account-card-option .button {
    margin-left: 0 !important;
  }

  .header-account {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .panel,
  .panel-centered {
    padding: var(--space-3);
  }

  .panel-flush {
    padding: var(--space-2) 0;
  }

  .panel-flush > h2,
  .link-list li {
    padding-inline: var(--space-3);
  }
}
