/* Notch — Swiss Industrial Dispatch & Ticket Design System */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: light;
  --paper: #EFECE4;
  --card: #FAF8F2;
  --well: #E5E0D3;
  --ink: #141413;
  --muted: #605C55;
  --hair: #CFC8B8;
  --accent: #D93814;
  --accent-ink: #FAF8F2;
  --cobalt: #1C4987;

  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-sans: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    linear-gradient(to right, rgba(20, 20, 19, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(20, 20, 19, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Typography helpers ---------- */
.font-display { font-family: var(--font-display); }
.font-mono { font-family: var(--font-mono); }

.kicker {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- Masthead / Topbar ---------- */
.masthead {
  border-bottom: 1.5px solid var(--ink);
  background: var(--card);
}

.masthead-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.masthead-inner--narrow {
  max-width: 760px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding-left: 12px;
  border-left: 1px solid var(--hair);
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.route-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 11px;
  border: 1px solid var(--hair);
  background: var(--paper);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink);
  min-width: 0;
  max-width: 240px;
}

.route-tag .route-prefix {
  color: var(--muted);
  font-weight: 600;
  flex-shrink: 0;
}

.route-tag .route-host {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Surfaces & Ticket Geometry ---------- */
.plate {
  background: var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  position: relative;
}

.plate--flat {
  box-shadow: none;
}

.plate-head {
  padding: 14px 20px;
  border-bottom: 1.5px solid var(--ink);
  background: var(--well);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.plate-body {
  padding: 22px 20px;
}

/* Ticket perforation with semicircular die-cut notches */
.ticket-tear {
  position: relative;
  border-top: 1.5px dashed var(--hair);
  margin: 0;
  height: 1px;
}

.ticket-tear::before,
.ticket-tear::after {
  content: "";
  position: absolute;
  top: -10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink);
  z-index: 2;
}

.ticket-tear::before {
  left: -10px;
  clip-path: inset(0 0 0 8px);
}

.ticket-tear::after {
  right: -10px;
  clip-path: inset(0 8px 0 0);
}

/* ---------- Form Controls ---------- */
.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}

.field-label span.sub {
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.field {
  height: 46px;
  width: 100%;
  background: #fff;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  padding: 0 13px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink);
  transition: background-color 0.14s, box-shadow 0.14s;
}

.field.font-mono {
  font-family: var(--font-mono);
  font-size: 14px;
}

.field::placeholder {
  color: #9A958B;
}

.field:focus {
  outline: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.slug-join {
  display: flex;
  width: 100%;
}

.slug-prefix {
  height: 46px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  background: var(--well);
  border: 1.5px solid var(--ink);
  border-right: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
  max-width: 52%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Segmented Mode Switch */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1.5px solid var(--ink);
  background: var(--well);
}

.seg-thumb {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background: var(--ink);
  transition: transform 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.seg button {
  position: relative;
  z-index: 1;
  height: 40px;
  border: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s;
}

.seg button[aria-checked="true"] {
  color: var(--card);
}

/* Expiry stamp pills */
.exp-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.exp-pill {
  display: block;
  cursor: pointer;
}

.exp-pill span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 1.5px solid var(--ink);
  background: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  transition: background-color 0.12s, color 0.12s, transform 0.1s;
}

.exp-pill span:hover {
  background: var(--well);
}

.exp-pill input:checked + span {
  background: var(--ink);
  color: var(--card);
}

.exp-pill input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Tactile Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  width: 100%;
  padding: 0 20px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background-color 0.14s;
}

.btn-primary:hover:not(:disabled) {
  background: #C42F0D;
}

.btn-primary:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: progress;
}

.btn-ink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--card);
  border: 1.5px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(20, 20, 19, 0.25);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
}

.btn-ink:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(20, 20, 19, 0.25);
}

.btn-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background-color 0.12s, color 0.12s;
}

.btn-key:hover:not(:disabled) {
  background: var(--well);
}

.btn-key:active:not(:disabled) {
  transform: translate(1.5px, 1.5px);
  box-shadow: 0.5px 0.5px 0 var(--ink);
}

.btn-key:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-key[data-done] {
  background: var(--ink);
  color: var(--card);
}

.btn-key[data-armed] {
  background: var(--accent);
  color: var(--accent-ink);
}

select.btn-key {
  padding: 0 8px;
}

/* Status stamps (text-based, zero fake LED circles) */
.stamp {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border: 1px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.stamp--active {
  background: var(--ink);
  color: var(--card);
}

.stamp--expired {
  background: transparent;
  color: var(--accent);
  border-color: var(--accent);
}

.stamp--removed {
  background: var(--well);
  color: var(--muted);
  border-color: var(--hair);
}

/* Smooth reveal */
.reveal {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.24s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.reveal[data-open="true"] {
  grid-template-rows: 1fr;
}

.reveal > div {
  min-height: 0;
  overflow: hidden;
}

/* Alerts */
.alert-bar {
  border: 1.5px solid var(--accent);
  background: #FFF4F1;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 13px;
}

.error-text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--accent);
  margin: 0;
}

/* Dialog */
dialog.notch-dialog {
  margin: auto;
  width: calc(100% - 32px);
  max-width: 420px;
  padding: 0;
  border: 1.5px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  background: var(--card);
  color: var(--ink);
}

dialog.notch-dialog::backdrop {
  background: rgba(20, 20, 19, 0.5);
}

/* Responsive utilities */
@media (max-width: 640px) {
  .masthead-inner {
    padding: 12px 16px;
  }
  .brand-sub {
    display: none;
  }
  .route-tag {
    display: none;
  }
  .exp-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
  }
}
