/* CATMap "Craftsman Atlas" theme — shared tokens and components for every
   page. Warm paper surfaces, mulberry-brick ink, a roofline-pin mark. See
   docs/superpowers/specs/2026-09-29-ui-redesign-design.md. System fonts
   only: this app makes zero third-party runtime requests. */

:root {
  --ink: #2a1d1a;
  --ink-2: #5b4a44;
  --ink-3: #75625a;
  --paper: #fbfaf8;
  --paper-2: #f1efeb;
  --surface: #ffffff;
  --line: #e9e5df;
  --line-strong: #d9d3ca;
  --brand: #842e4e;
  --brand-strong: #6b2240;
  --brand-tint: #f5e6ec;
  --clay: #c8623e;
  --gold: #e2a93b;
  --sage: #4f7d5f;
  --sage-tint: #e3eee4;
  --slate: #4f7486;
  --danger: #b3261e;
  --danger-tint: #fbe9e7;

  --font-display: ui-serif, "New York", "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif;
  --font-ui: system-ui, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;

  --shadow-1: 0 1px 2px rgba(42, 29, 26, 0.06), 0 1px 1px rgba(42, 29, 26, 0.04);
  --shadow-2: 0 2px 6px rgba(42, 29, 26, 0.06), 0 8px 24px -6px rgba(42, 29, 26, 0.12);
  --shadow-3: 0 6px 16px rgba(42, 29, 26, 0.08), 0 24px 48px -12px rgba(42, 29, 26, 0.24);

  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.4, 0.64, 1);
  --dur-1: 120ms;
  --dur-2: 200ms;
  --dur-3: 280ms;

  --focus-ring: 0 0 0 3px var(--surface), 0 0 0 5px var(--brand);
}

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

body {
  margin: 0;
  font: 400 15px/1.5 var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--brand);
  text-underline-offset: 0.18em;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Brand mark --- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 3px rgba(107, 34, 64, 0.25));
}
.brand-word {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}
.brand-name {
  font: 700 1.2rem/1 var(--font-display);
  letter-spacing: -0.02em;
}
.brand-sub {
  margin-top: 3px;
  font: 600 0.625rem/1 var(--font-ui);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45em;
  min-height: 40px;
  margin: 0;
  padding: 0 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font: 600 0.875rem/1 var(--font-ui);
  letter-spacing: -0.005em;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition:
    transform var(--dur-2) var(--ease-spring),
    background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}
.btn:hover {
  border-color: var(--ink-3);
}
/* Responds on pointer-down (:active fires natively on press), not on
   click completion. */
.btn:active {
  transform: scale(0.96);
  transition-duration: 60ms;
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}
.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.btn-primary {
  border-color: transparent;
  background: linear-gradient(180deg, #93375a, var(--brand) 55%, var(--brand-strong));
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 2px 6px -1px rgba(107, 34, 64, 0.45);
}
.btn-primary:hover {
  border-color: transparent;
  background: linear-gradient(180deg, #8a3254, var(--brand-strong) 60%, #5a1c36);
}
.btn-quiet {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
}
.btn-quiet:hover {
  border-color: transparent;
  background: rgba(42, 29, 26, 0.06);
  color: var(--ink);
}
.btn-danger {
  color: var(--danger);
}
.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger-tint);
}
.btn-sm {
  min-height: 32px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
}
/* After the variants, so a variant's own shadow can't hide the ring. */
.btn:focus-visible {
  box-shadow: var(--focus-ring);
}

/* --- Fields --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field-label {
  font: 600 0.8125rem/1.2 var(--font-ui);
  color: var(--ink-2);
}
.input,
.select {
  width: 100%;
  min-height: 44px;
  padding: 0 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: 400 1rem/1.3 var(--font-ui);
  box-shadow: 0 1px 0 rgba(42, 29, 26, 0.03) inset;
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-2) var(--ease-out);
}
.input::placeholder {
  color: #9a887e;
}
.input:hover,
.select:hover {
  border-color: var(--ink-3);
}
.input:focus-visible,
.select:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(132, 46, 78, 0.18);
}
.select {
  appearance: none;
  padding-right: 2.4rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%235b4a44' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 16px;
  cursor: pointer;
}
input[type='file'].input {
  padding: 0.55rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}
input[type='file'].input::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--paper);
  color: var(--ink);
  font: 600 0.8125rem/1 var(--font-ui);
  cursor: pointer;
}

/* --- Checkbox & switch (native inputs, restyled — still real checkboxes
   for keyboard and assistive tech) --- */
.check {
  appearance: none;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  border: 1.5px solid var(--line-strong);
  border-radius: 5px;
  background: var(--surface) center / 12px no-repeat;
  cursor: pointer;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out),
    transform var(--dur-2) var(--ease-spring);
}
.check:checked {
  border-color: var(--brand);
  background-color: var(--brand);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2l2.3 2.3 4.7-5' fill='none' stroke='%23fff' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.check:active {
  transform: scale(0.88);
}

.switch {
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: var(--r-pill);
  background: #d9ccbd;
  cursor: pointer;
  transition: background-color var(--dur-2) var(--ease-out);
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(42, 29, 26, 0.3);
  transition: transform var(--dur-3) var(--ease-spring);
}
.switch:checked {
  background: var(--sage);
}
.switch:checked::after {
  transform: translateX(16px);
}
.switch:disabled {
  opacity: 0.6;
  cursor: progress;
}

/* --- Page backdrop: a faint topographic contour texture --- */
.topo-bg {
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='640' height='520' viewBox='0 0 640 520'%3E%3Cg fill='none' stroke='%23842e4e' stroke-opacity='.065' stroke-width='1.2'%3E%3Cpath d='M0 110c90-44 160 34 250 2s140-96 230-62 110 70 160 44'/%3E%3Cpath d='M0 142c90-42 168 42 256 10s136-90 222-58 112 74 162 48'/%3E%3Cpath d='M0 176c96-38 170 50 262 18s134-84 214-54 114 78 164 52'/%3E%3Cpath d='M0 360c80 32 150-42 240-10s130 94 220 62 120-58 180-36'/%3E%3Cpath d='M0 394c80 32 156-36 244-4s130 88 214 58 122-52 182-30'/%3E%3Cpath d='M0 428c86 28 160-30 248 2s126 82 206 56 124-48 186-26'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 640px 520px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
  }
  .btn:active,
  .check:active {
    transform: none;
  }
}

/* --- Inline rename (src/inline-rename.js) --- */
.rename-btn {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink-3);
  opacity: 0.7;
  cursor: pointer;
  transition: opacity var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out),
    color var(--dur-1) var(--ease-out);
}
.rename-btn[hidden] {
  display: none;
}
.rename-btn:hover {
  background: var(--brand-tint);
  color: var(--brand);
  opacity: 1;
}
.rename-btn:focus-visible {
  outline: none;
  opacity: 1;
  box-shadow: var(--focus-ring);
}

.inline-rename-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  padding: 2px 8px;
  border: 1.5px solid var(--brand);
  border-radius: var(--r-xs);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  letter-spacing: inherit;
}
.inline-rename-input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.inline-rename-input:disabled {
  opacity: 0.6;
}
