/* Design tokens (palette + semantic + type + shape) live in tokens.css, which
   Propshaft loads before this file. This stylesheet consumes the semantic
   variables only — no raw colors, so the palette can be re-skinned in one place.

   Aesthetic: Vercel Geist. Off-white canvas, gray-1000 ink, hairline gray-400
   borders, soft raised-card shadows, 6px corners, Geist Sans headings at weight
   600 with tracking that tightens as size grows, Geist Mono for codes (opening
   IDs, coordinates, timestamps). Neutral (gray-1000) primary action; blue-700 as
   the link/focus accent. Dark theme is the same tokens via prefers-color-scheme. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;            /* Geist copy-14 baseline */
  font-weight: var(--weight-reg);
  line-height: 20px;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- Headings: Geist weight 600, tracking tightens with size ---- */
h1,
h2,
h3 {
  margin-block-start: 0;
  font-weight: var(--weight-semi);
  text-wrap: balance;
}

p {
  margin-block-start: 0;
  text-wrap: pretty;
}

h1 {
  font-size: 32px;            /* heading-32 */
  line-height: 40px;
  letter-spacing: -1.28px;
}

h2 {
  font-size: 24px;            /* heading-24 */
  line-height: 32px;
  letter-spacing: -0.96px;
}

h3 {
  font-size: 20px;            /* heading-20 */
  line-height: 26px;
  letter-spacing: -0.4px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-strong);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

/* ---- Geist focus ring: surface gap + accent halo ---- */
a:focus-visible,
button:focus-visible,
.button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ---- Geist Mono for codes: opening IDs, coordinates, timestamps ---- */
.mono,
.opening-id,
time,
.log-entry header time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-6);
  width: min(var(--container), calc(100vw - 32px));
  margin: 0 auto;
  padding: var(--space-3) 0;
  background: var(--bg);
}

/* Hairline rule spans the full viewport; content stays in the column */
.topbar::after {
  content: "";
  position: absolute;
  inset-block-end: 0;
  inset-inline: 50%;
  width: 100vw;
  transform: translateX(-50%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  font-weight: var(--weight-semi);
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
  color: var(--text);
}

/* The badge IS the wordmark: blue accent fill, white text, white // separator */
.brand-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: var(--weight-semi);
  letter-spacing: -0.28px;
  line-height: 1;
}

.brand-sep {
  margin: 0 0.25em;
  /* Pale-blue // divider — tonal accent of the badge. Hardcoded (not a token):
     the badge fill is blue-700 in BOTH themes, so the slashes must stay light
     even in dark mode, where --blue-300 flips to a dark navy. */
  color: #cae7ff;   /* blue-400 (light value) */
  font-weight: var(--weight-reg);
}

.topbar nav {
  display: flex;
  gap: var(--space-4);
}

.topbar nav a {
  color: var(--muted);
  font-size: 14px;
  font-weight: var(--weight-med);
  text-decoration: none;
  transition: color var(--dur-state) var(--ease);
}

.topbar nav a:hover {
  color: var(--text);
  text-decoration: none;
}

.session {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  color: var(--muted);
  font-size: 13px;
}

.page {
  width: min(var(--container), calc(100vw - 32px));
  margin: 0 auto;
  padding: var(--space-8) 0 var(--space-16);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}

.page-header h1 {
  margin-bottom: var(--space-2);
}

.eyebrow,
.muted {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: var(--space-1);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

/* ---- Buttons: neutral (gray-1000) primary, hairline secondary ---- */
.button,
button,
input[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;            /* Geist default button height */
  padding: 0 14px;
  border: 1px solid var(--action);
  border-radius: var(--radius-sm);
  background: var(--action);
  color: var(--on-action);
  font: inherit;
  font-size: 14px;
  font-weight: var(--weight-med);
  letter-spacing: -0.28px;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--dur-state) var(--ease), border-color var(--dur-state) var(--ease), box-shadow var(--dur-state) var(--ease);
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--action-hover);
  border-color: var(--action-hover);
  text-decoration: none;
  color: var(--on-action);
}

.button.secondary,
.session button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.button.secondary:hover,
.session button:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-4);
}

/* ---- Panels: raised cards, hairline border, 6px corners, soft shadow ---- */
.card,
.panel,
.empty,
.auth-panel,
.log-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}

.empty {
  color: var(--muted);
  box-shadow: none;
  background: var(--surface-alt);
  border-style: dashed;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

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

th {
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: var(--weight-med);
  letter-spacing: 0;
  text-transform: uppercase;
}

.stack {
  display: grid;
  gap: var(--space-4);
  max-width: 640px;
}

label,
fieldset {
  display: grid;
  gap: var(--space-2);
  color: var(--text);
  font-size: 14px;
  font-weight: var(--weight-med);
}

fieldset {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: var(--weight-reg);
  transition: border-color var(--dur-state) var(--ease), box-shadow var(--dur-state) var(--ease);
}

textarea {
  padding: 10px 12px;
}

/* Geist input: border steps to strong gray on hover, accent ring on focus */
input:hover,
select:hover,
textarea:hover {
  border-color: var(--border-strong);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-soft);
}

textarea {
  resize: vertical;
}

.field-grid,
.detail-grid,
.mapper {
  display: grid;
  gap: var(--space-4);
}

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

.detail-grid,
.mapper {
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
}

.auth-panel {
  max-width: 420px;
  margin: 12vh auto 0;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 14px;
}

.flash.notice {
  background: var(--success-bg);
  color: var(--success-text);
  border-color: var(--success-text);
}

.flash.alert,
.error-list {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.error-list {
  border: 1px solid var(--danger-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.plan-frame {
  overflow: auto;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.plan-surface {
  position: relative;
  min-height: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: crosshair;
}

.plan-media {
  display: block;
  width: 100%;
  min-height: 560px;
  border: 0;
  object-fit: contain;
}

iframe.plan-media {
  height: 720px;
}

.plan-placeholder {
  display: grid;
  min-height: 560px;
  place-items: center;
  color: var(--muted);
}

/* ---- Pin: round marker. Danger = placed, accent = preview. ---- */
.pin {
  position: absolute;
  z-index: 2;
  width: 34px;
  height: 34px;
  transform: translate(-50%, -50%);
  border: 2px solid var(--background-100);
  border-radius: 50%;
  background: var(--danger);
  color: var(--background-100);
  box-shadow: var(--shadow-card);
  font-size: 0;
}

.pin::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--background-100);
}

.pin.preview {
  background: var(--accent);
  pointer-events: none;
}

.timeline {
  display: grid;
  gap: var(--space-3);
}

.log-entry header,
.log-entry footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--muted);
  font-size: 13px;
}

dl {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: var(--space-2) var(--space-4);
  font-size: 14px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

@media (max-width: 820px) {
  .topbar,
  .page-header,
  .session {
    align-items: stretch;
    flex-direction: column;
  }

  .session {
    margin-left: 0;
  }

  .detail-grid,
  .mapper {
    grid-template-columns: 1fr;
  }
}

/* ---- Dashboard shell: sidebar + content ---- */
.shell {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  width: min(var(--container), calc(100vw - 32px));
  margin: 0 auto;
}

.shell .page {
  width: auto;
  flex: 1;
  min-width: 0;
  margin: 0;
}

.sidebar {
  position: sticky;
  top: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-8);
  flex: 0 0 220px;
  min-height: calc(100vh - var(--space-16));
  padding: var(--space-8) 0;
}

.sidebar-nav,
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-link {
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  font-weight: var(--weight-med);
  border-left: 2px solid transparent;
}

.sidebar-link:hover {
  background: var(--surface-alt);
  text-decoration: none;
  color: var(--text);
}

.sidebar-link.is-active {
  border-left-color: var(--accent);
  color: var(--accent);
}

.sidebar-back {
  padding: var(--space-1) var(--space-3);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
}

.sidebar-context {
  margin: var(--space-2) 0;
  padding: 0 var(--space-3);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Openings category tabs ---- */
.tabs {
  display: flex;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: var(--weight-med);
  cursor: pointer;
}

.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ---- Floor plan thumbnails ---- */
.plan-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.plan-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 96px;
  height: 72px;
  overflow: hidden;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.plan-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.plan-thumb-label {
  padding: var(--space-1);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
