/* PTMCO portal — components on top of the shared design system (ptmco.css,
   copied from site/assets by deploy.sh). Tokens, type and buttons come from there. */

@font-face { font-family: "Crimson Text"; font-weight: 700; font-display: swap; src: url("CrimsonText-Bold.ttf") format("truetype"); }

body.app { background: var(--mist); min-height: 100vh; display: flex; flex-direction: column; }
.app-main { flex: 1; padding-block: clamp(2rem, 1.5rem + 2.5vw, 3.75rem) 5rem; }
.narrow { max-width: 30rem; margin-inline: auto; }
.medium { max-width: 50rem; margin-inline: auto; }
.stack > * + * { margin-top: var(--stack-gap, 1.5rem); }

.app-footer { background: var(--ink); color: #93a0b8; font-size: var(--t-sm); padding-block: 1.5rem; }
.app-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem 1.5rem; }
.app-footer a { color: #b8c1d3; text-decoration: none; }
.app-footer a:hover { color: #fff; text-decoration: underline; }
.app-footer nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }

/* header: user menu */
.nav-user { font-size: var(--t-sm); color: var(--slate); max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- page titles ---------- */
.page-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem 2rem; margin-bottom: 2rem; }
.page-title h1 { font-size: var(--t-3xl); }
.page-title p { color: var(--slate); margin-top: .5rem; max-width: 38em; }
.center-title { text-align: center; margin-bottom: 1.75rem; }
.center-title h1 { font-size: var(--t-2xl); }
.center-title p { margin-top: .6rem; color: var(--slate); }

/* ---------- panels ---------- */
.panel { background: #fff; border: 1px solid var(--rule); border-radius: var(--radius); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1.5rem; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--rule); }
.panel-head h2 { font-size: var(--t-lg); }
.panel-head p { font-size: var(--t-sm); color: var(--slate); }
.panel-body { padding: 1.5rem; }
.panel-body > * + * { margin-top: 1.25rem; }
.panel-foot { padding: 1rem 1.5rem; border-top: 1px solid var(--rule); background: #fafbfc; font-size: var(--t-sm); color: var(--slate); border-radius: 0 0 var(--radius) var(--radius); }
.panel--pad { padding: clamp(1.5rem, 4vw, 2.25rem); }

/* ---------- alerts ---------- */
.alert { border: 1px solid; border-radius: var(--radius); padding: .85rem 1rem; font-size: var(--t-sm); line-height: 1.5; }
.alert b { display: block; font-size: var(--t-md); margin-bottom: .15rem; }
.alert--error { background: #fdf1f2; border-color: #f0c2c6; color: #8a1520; }
.alert--success { background: #eef7f1; border-color: #bfe0cb; color: #1d5a36; }
.alert--info { background: #eef3fb; border-color: #c9d6ee; color: var(--ink); }
.alerts { margin-bottom: 1.5rem; }
.alerts > * + * { margin-top: .75rem; }

/* ---------- forms ---------- */
.form > * + * { margin-top: 1.1rem; }
.field { display: grid; gap: .4rem; }
.field label, .field .label { font-weight: 600; font-size: var(--t-sm); }
.field .hint { font-size: var(--t-xs); color: var(--slate); }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.field-row a { font-size: var(--t-sm); color: var(--signal); font-weight: 600; text-decoration: none; }
.field-row a:hover { text-decoration: underline; }
.input {
  width: 100%; min-height: 3rem; padding: .65rem .9rem; border: 1.5px solid var(--rule-strong); border-radius: var(--radius);
  font: 400 var(--t-md)/1.3 var(--sans); color: var(--ink); background: #fff;
}
.input::placeholder { color: #8a93a6; }
.input:focus-visible { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(21, 34, 63, .15); }
.input--code { text-align: center; font: 600 1.75rem/1 ui-monospace, "SFMono-Regular", Menlo, monospace; letter-spacing: .4em; padding-left: 1.3em; }
.input--id { text-transform: uppercase; letter-spacing: .06em; }
.inline-form { display: flex; gap: .5rem; }
.inline-form .input { flex: 1; min-width: 0; }
.btn-block { width: 100%; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ink:hover { background: var(--ink-2); }
.btn-green { background: #1f7a4a; color: #fff; }
.btn-green:hover { background: #17633b; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { min-height: 2.4rem; padding: .45rem .9rem; }
.btn-plain { background: none; border: 0; padding: .25rem 0; font: 600 var(--t-sm)/1.2 var(--sans); color: var(--slate); cursor: pointer; text-decoration: none; }
.btn-plain:hover { color: var(--ink); text-decoration: underline; }
.split-actions { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.25rem; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--rule); margin: -.25rem 0 1.5rem; }
.tabs a { text-align: center; padding: .8rem .5rem; margin-bottom: -1px; font-weight: 600; font-size: var(--t-sm); color: var(--slate); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--signal); }
.below-card { text-align: center; margin-top: 1.5rem; font-size: var(--t-sm); color: var(--slate); }
.below-card a { color: var(--slate); }

/* ---------- status labels ---------- */
.status { display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .65rem; border-radius: 999px; font: 600 var(--t-xs)/1.3 var(--sans); white-space: nowrap; }
.status::before { content: ""; width: .45rem; height: .45rem; border-radius: 50%; background: currentColor; }
.status--done { background: #e6f3eb; color: #1d5a36; }
.status--ready { background: #e9eff9; color: var(--ink-2); }
.status--open { background: var(--signal-tint); color: var(--signal-dark); }
.status--locked { background: var(--mist); color: var(--slate); }
.status--failed { background: var(--mist); color: var(--ink-soft); }

/* ---------- dashboard: levels ---------- */
.levels { list-style: none; padding: 0; margin: 0; }
.level { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr) auto; gap: .75rem 1.5rem; align-items: center; padding: 1.35rem 1.5rem; border-top: 1px solid var(--rule); }
.level:first-child { border-top: 0; }
.level.is-next { box-shadow: inset 3px 0 0 var(--signal); }
.level-code { font: 600 var(--t-xl)/1 var(--serif); }
.level-name { font-weight: 600; line-height: 1.35; }
.level-meta { margin-top: .2rem; font-size: var(--t-sm); color: var(--slate); }
.level-meta .status { margin-right: .5rem; vertical-align: 1px; }
.level-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem 1rem; }
.level.is-locked .level-code, .level.is-locked .level-name { color: #8a93a6; }
@media (max-width: 44rem) {
  .level { grid-template-columns: 4rem minmax(0, 1fr); align-items: start; }
  .level-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th, .table td { text-align: left; padding: .85rem 1.5rem; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.table thead th { font-weight: 600; color: var(--slate); background: #fafbfc; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table td.num { font-variant-numeric: tabular-nums; }
.table a { color: var(--signal); font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table .strong { font-weight: 600; color: var(--ink); }

/* key/value lists (account) */
.kv { margin: 0; }
.kv div { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: .25rem 1.5rem; padding: .9rem 0; border-top: 1px solid var(--rule); }
.kv div:first-child { border-top: 0; padding-top: 0; }
.kv dt { color: var(--slate); font-size: var(--t-sm); }
.kv dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.kv dd small { display: block; margin-top: .2rem; font-weight: 400; font-size: var(--t-sm); color: var(--slate); }
@media (max-width: 36rem) { .kv div { grid-template-columns: 1fr; } }

.account-nav { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; margin-bottom: 2rem; font-size: var(--t-sm); }
.account-nav a { color: var(--slate); text-decoration: none; font-weight: 600; }
.account-nav a:hover { color: var(--ink); }
.list-rows { list-style: none; padding: 0; margin: 0; }
.list-rows li { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .35rem 1.5rem; padding: 1rem 1.5rem; border-top: 1px solid var(--rule); font-size: var(--t-sm); }
.list-rows li:first-child { border-top: 0; }
.list-rows b { font: 600 var(--t-md)/1.3 var(--serif); margin-right: .5rem; }
.list-rows .muted { color: var(--slate); }
.list-rows .links { display: flex; gap: 1.25rem; }
.list-rows a { color: var(--signal); font-weight: 600; text-decoration: none; }
.list-rows a:hover { text-decoration: underline; }
.empty { padding: 1.5rem; color: var(--slate); font-size: var(--t-sm); }

/* ---------- dialogs ---------- */
dialog.modal { width: min(30rem, calc(100% - 2rem)); padding: 0; border: 0; border-radius: var(--radius); color: var(--ink); box-shadow: 0 30px 60px -20px rgba(21, 34, 63, .45); }
dialog.modal::backdrop { background: rgba(21, 34, 63, .62); }
.modal-head { padding: 1.5rem 1.5rem 0; }
.modal-head h2 { font-size: var(--t-xl); }
.modal-head p { margin-top: .5rem; color: var(--slate); font-size: var(--t-sm); }
.modal-body { padding: 1.5rem; }
.modal-actions { display: flex; flex-direction: row-reverse; gap: .75rem; padding: 0 1.5rem 1.5rem; }
.modal-actions .btn { flex: 1; }
#payment-element { min-height: 12rem; }

/* ---------- exam ---------- */
.exam-intro .panel-body { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem 2rem; }
.exam-intro h1 { font-size: var(--t-2xl); }
.exam-intro .code { color: var(--signal); font: 600 var(--t-md)/1 var(--sans); letter-spacing: .02em; margin-bottom: .5rem; }
.exam-facts { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin: 0; font-size: var(--t-sm); }
.exam-facts dt { color: var(--slate); }
.exam-facts dd { margin: 0; font-weight: 600; }
.question { margin: 0; min-width: 0; }
.question legend { float: left; width: 100%; padding: 0; }
.question legend + * { clear: both; }
.question-count { display: block; font-size: var(--t-sm); color: var(--slate); margin-bottom: .6rem; }
.question-text { display: block; font: 600 var(--t-lg)/1.4 var(--serif); }
.options { display: grid; gap: .6rem; margin-top: 1.25rem; }
.option { display: grid; grid-template-columns: 1.25rem 1.6rem minmax(0, 1fr); gap: .75rem; align-items: start; padding: .9rem 1rem; border: 1.5px solid var(--rule); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background-color .12s; }
.option:hover { border-color: var(--rule-strong); background: #fafbfc; }
.option input { margin: .2rem 0 0; width: 1.1rem; height: 1.1rem; accent-color: var(--signal); }
.option .letter { font-weight: 700; color: var(--signal); }
.option:has(input:checked) { border-color: var(--signal); background: var(--signal-tint); }
.option:has(input:focus-visible) { outline: 3px solid var(--signal); outline-offset: 2px; }
.exam-bar { position: sticky; bottom: 0; z-index: 20; margin-top: 2rem; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: 0 -8px 24px -16px rgba(21, 34, 63, .3); padding: 1rem 1.25rem; display: flex; align-items: center; gap: 1.25rem; }
.meter { flex: 1; min-width: 6rem; }
.meter-label { font-size: var(--t-sm); color: var(--slate); margin-bottom: .4rem; }
.meter-label b { color: var(--ink); }
.meter-track { height: .4rem; background: var(--mist); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: var(--signal); border-radius: 999px; transition: width .2s; }

/* ---------- results ---------- */
.score-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border: 1px solid var(--rule); border-radius: var(--radius); }
.score-grid div { padding: 1.25rem; text-align: center; display: flex; flex-direction: column; }
.score-grid div + div { border-left: 1px solid var(--rule); }
.score-grid dt { font-size: var(--t-sm); color: var(--slate); margin-top: .35rem; }
.score-grid dd { margin: 0; order: -1; font: 600 var(--t-2xl)/1 var(--serif); font-variant-numeric: tabular-nums; }
.btn-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 30rem) { .btn-pair { grid-template-columns: 1fr; } }

/* ---------- certificate page ---------- */
.cert-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.5rem; }
.btn-linkedin { background: #0a66c2; color: #fff; }
.btn-linkedin:hover { background: #084f96; }
.cert-frame { overflow-x: auto; padding-bottom: .5rem; }
.cert--full { min-width: 44rem; font-size: clamp(.62rem, .3rem + .72vw, .95rem); }
.cert--full .cert-name { font-family: "Crimson Text", var(--serif); font-size: 3.6em; }
.cert-about { margin-top: 2rem; }
.cert-url { font: 500 var(--t-sm)/1.4 ui-monospace, "SFMono-Regular", Menlo, monospace; background: var(--mist); border: 1px solid var(--rule); border-radius: var(--radius); padding: .75rem 1rem; overflow-wrap: anywhere; }

@media print {
  body.app { background: #fff; }
  .site-header, .app-footer, .no-print { display: none !important; }
  .app-main { padding: 0; }
  .cert--full { min-width: 0; box-shadow: none; font-size: 9pt; }
  @page { size: A4 landscape; margin: 10mm; }
}

/* ---------- ALTCHA widget (self-hosted) ----------
   Host class is "captcha", not "altcha": the widget styles .altcha itself
   (all: revert-layer), which wiped the form spacing when the names collided. */
altcha-widget.captcha {
  display: block;
  margin-top: 1.1rem;
  --altcha-max-width: 100%;
  --altcha-border-radius: var(--radius);
  --altcha-border-color: var(--rule-strong);
  --altcha-color-base-content: var(--ink);
  --altcha-color-primary: var(--ink);
  --altcha-color-success: #1f7a4a;
  --altcha-color-error: var(--signal);
}
