/* MyNotes shared UI. One stylesheet for all seven stacks.
   Markup contract: shared-ui/MARKUP.md. Font file figtree.woff2 sits beside this file. */

@font-face {
  font-family: "Figtree";
  src: url("figtree.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  --indigo-950: #0f1445;
  --indigo-900: #161d5c;
  --indigo-700: #2a3591;
  --indigo-100: #e3e5f6;
  --ground: #f3f3fa;
  --surface: #ffffff;
  --ink: #161a3d;
  --ink-soft: #4b5080;
  --rule: #d6d8ea;
  --field-edge: #7f84b3;
  --red: #c42d14;
  --red-deep: #a3240f;
  --saffron: #f2b21c;
  --green: #14683f;

  --font: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --band-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='10' viewBox='0 0 24 10'%3E%3Crect width='24' height='10' fill='%23161d5c'/%3E%3Cpath d='M12 1 17.5 5 12 9 6.5 5Z' fill='%23f2b21c'/%3E%3Cpath d='M12 3.2 14.4 5 12 6.8 9.6 5Z' fill='%23161d5c'/%3E%3Ccircle cx='0' cy='5' r='1.8' fill='%23c42d14'/%3E%3Ccircle cx='24' cy='5' r='1.8' fill='%23c42d14'/%3E%3C/svg%3E");
  --field-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Crect width='56' height='56' fill='%23161d5c'/%3E%3Cpath d='M28 3 53 28 28 53 3 28Z' fill='none' stroke='%23f2b21c' stroke-width='2'/%3E%3Cpath d='M28 13 43 28 28 43 13 28Z' fill='%23c42d14'/%3E%3Ccircle cx='28' cy='28' r='4.5' fill='%23ffffff'/%3E%3Ccircle cx='0' cy='0' r='3' fill='%23ffffff'/%3E%3Ccircle cx='56' cy='0' r='3' fill='%23ffffff'/%3E%3Ccircle cx='0' cy='56' r='3' fill='%23ffffff'/%3E%3Ccircle cx='56' cy='56' r='3' fill='%23ffffff'/%3E%3C/svg%3E");
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--ground);
  caret-color: var(--red);
  accent-color: var(--indigo-700);
  scrollbar-color: var(--indigo-700) var(--ground);
}

::selection { background: var(--saffron); color: var(--indigo-950); }

h1, h2, h3 {
  margin: 0 0 0.75rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
h1 { font-size: clamp(1.6rem, 1.25rem + 1.4vw, 2.25rem); font-weight: 800; }
h2 { font-size: 1.35rem; font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
p { margin: 0 0 1rem; max-width: 68ch; }

a {
  color: var(--indigo-700);
  text-decoration: underline;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--red-deep); text-decoration-thickness: 2px; }

:focus-visible {
  outline: 3px solid var(--indigo-700);
  outline-offset: 2px;
  border-radius: 3px;
}

/* ---------- Nav ---------- */

.navbar {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1.5rem;
  padding: 0.85rem clamp(1rem, 4vw, 2.5rem) calc(0.85rem + 10px);
  background: var(--indigo-900);
  color: #fff;
}
.navbar::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 10px;
  background: var(--band-tile) repeat-x left center / 24px 10px;
}
.navbar :focus-visible { outline-color: var(--saffron); }

.brand {
  font-size: 1.5rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  color: #fff;
  text-decoration: none;
}
.brand:hover { color: var(--saffron); text-decoration: none; }

.nav-links { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.25rem; }
.nav-links a,
.nav-links .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
  border-radius: 6px;
}
.nav-links a:hover,
.nav-links .link-button:hover { background: rgba(255, 255, 255, 0.14); color: #fff; text-decoration: none; }
.nav-user {
  padding: 0 0.75rem;
  font-size: 0.9rem;
  color: #c9cdf0;
  max-width: 16ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 4rem;
}
.container:has(> .auth-card) { max-width: 920px; }

.muted { color: var(--ink-soft); font-size: 0.925rem; }

/* ---------- Cards and the auth card ---------- */

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: clamp(1.25rem, 3vw, 2rem);
}
.card > h1 { margin-bottom: 1rem; }

.auth-card {
  overflow: hidden;
  max-width: 880px;
  margin: 0 auto;
  padding-top: calc(clamp(1.25rem, 3vw, 2rem) + 56px);
}
.auth-card > * { position: relative; }
.auth-card::before,
.auth-card::after { content: ""; position: absolute; pointer-events: none; }
.auth-card::before {
  inset: 0 0 auto 0;
  height: 56px;
  background: var(--field-tile) repeat left top / 56px 56px;
}
.auth-card::after {
  inset: 0 0 auto 0;
  height: 10px;
  background: var(--band-tile) repeat-x left center / 24px 10px;
}

@media (min-width: 880px) {
  .auth-card {
    padding: 3rem 3rem 3rem calc(40% + 3rem);
    min-height: 440px;
  }
  .auth-card::before {
    inset: 0 auto 0 0;
    width: 40%;
    height: auto;
    background-size: 56px 56px;
  }
  .auth-card::after { inset: 0 0 auto 0; }
}

.auth-card form { max-width: 28rem; }

/* ---------- Forms ---------- */

form label,
.field-label {
  display: block;
  margin: 1.1rem 0 0.35rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
}
form > label:first-child { margin-top: 0; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="url"], input[type="tel"], select, textarea {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 0.6rem 0.8rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--field-edge);
  border-radius: 6px;
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
}
textarea { min-height: 9rem; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #6a6f9c; }
input:hover, select:hover, textarea:hover { border-color: var(--indigo-700); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--indigo-700);
  box-shadow: 0 0 0 3px var(--indigo-100), 0 0 0 4px var(--indigo-700);
}
input[aria-invalid="true"], .is-invalid { border-color: var(--red); }
input:disabled, textarea:disabled, select:disabled { background: var(--ground); color: var(--ink-soft); cursor: not-allowed; }

/* One-time code */
input[inputmode="numeric"][maxlength="6"] {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
  max-width: 14rem;
}

/* Framework-rendered paragraphs inside forms (Django as_p, WTForms) */
form > p { margin: 0 0 1rem; max-width: none; }
form > p > label { margin-top: 0; }
form ul { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.875rem; color: var(--ink-soft); }
form ul.errorlist, .field-error { padding: 0; list-style: none; color: var(--red-deep); font-weight: 600; font-size: 0.875rem; margin: 0.35rem 0 0; }
.helptext { display: block; margin-top: 0.3rem; font-size: 0.85rem; color: var(--ink-soft); }
.field-error { display: block; }

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

.btn,
input[type="submit"],
button[type="submit"]:not(.link-button) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  margin-top: 1.5rem;
  padding: 0 1.5rem;
  font: inherit;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  text-decoration: none;
  text-align: center;
  background: var(--red);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease-out, transform 0.1s ease-out;
}
.btn:hover,
input[type="submit"]:hover,
button[type="submit"]:not(.link-button):hover { background: var(--red-deep); color: #fff; text-decoration: none; }
.btn:active, input[type="submit"]:active, button[type="submit"]:not(.link-button):active { transform: translateY(1px); }
.btn[disabled], .btn:disabled, input[type="submit"]:disabled { background: var(--indigo-100); color: var(--ink-soft); border-color: var(--rule); cursor: not-allowed; }
.btn-primary { background: var(--red); color: #fff; }
.btn-secondary {
  margin-left: 0.5rem;
  color: var(--indigo-900);
  background: #fff;
  border-color: var(--field-edge);
}
.btn-secondary:hover { background: var(--indigo-100); color: var(--indigo-900); }
.btn-danger { background: var(--red-deep); }

.inline-form { display: inline; margin: 0; }
.link-button {
  display: inline;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 0.925rem;
  color: var(--indigo-700);
  background: none;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}
.link-button:hover { color: var(--red-deep); }
.link-danger, .link-danger:hover { color: var(--red-deep); }

/* ---------- Alerts: the band ---------- */

.alert {
  position: relative;
  max-width: 880px;
  margin: 0 auto 1.25rem;
  padding: calc(10px + 0.9rem) 1.25rem calc(10px + 0.9rem);
  font-weight: 650;
  color: #fff;
  background: var(--indigo-900);
  border-radius: 8px;
  overflow: hidden;
}
.alert::before, .alert::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  height: 10px;
  background: var(--band-tile) repeat-x left center / 24px 10px;
}
.alert::before { top: 0; }
.alert::after { bottom: 0; }
.alert-error, .alert-danger { background: var(--red-deep); }
.alert-success { background: var(--green); }
.alert-info, .alert-warning { background: var(--indigo-900); }
.alert a { color: #fff; }

ul.flashes { list-style: none; margin: 0; padding: 0; }

/* ---------- Reset-flow stations ---------- */

.steps {
  display: flex;
  gap: 0;
  margin: 0 0 1.5rem;
  padding: 0;
  list-style: none;
  max-width: 28rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.steps li { position: relative; flex: 1; padding-top: 1.5rem; }
.steps li::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 2px solid var(--field-edge);
  border-radius: 50%;
}
.steps li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 18px;
  right: 6px;
  height: 2px;
  background: var(--rule);
}
.steps .is-done { color: var(--ink); }
.steps .is-done::before { background: var(--indigo-700); border-color: var(--indigo-700); }
.steps .is-done::after { background: var(--indigo-700) !important; }
.steps [aria-current="step"] { color: var(--red-deep); }
.steps [aria-current="step"]::before { background: var(--red); border-color: var(--red); box-shadow: 0 0 0 4px #f6d4cd; }

/* ---------- Users table ---------- */

.dashboard-header, .notes-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}
.dashboard-header h1, .notes-header h1 { margin: 0; }
.notes-header .btn { margin-top: 0; }

.users-table, .table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
  font-size: 0.95rem;
}
.users-table th, .users-table td, .table th, .table td {
  padding: 0.8rem 1rem;
  text-align: left;
  vertical-align: baseline;
  border-bottom: 1px solid var(--rule);
}
.users-table th, .table th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #fff;
  background: var(--indigo-900);
  border-bottom: 0;
}
.users-table th:first-child, .table th:first-child { border-top-left-radius: 7px; }
.users-table th:last-child, .table th:last-child { border-top-right-radius: 7px; }
.users-table tbody tr:last-child td, .table tbody tr:last-child td { border-bottom: 0; }
.users-table tbody tr:hover td, .table tbody tr:hover td { background: var(--ground); }
.users-table td, .table td { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.users-table th:last-child, .users-table td:last-child,
.table th:last-child, .table td:last-child { text-align: right; white-space: nowrap; }
.table-container { overflow-x: auto; }

@media (max-width: 640px) {
  .users-table, .table { display: block; overflow-x: auto; }
}

/* ---------- Notes ---------- */

.notes-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.note-card {
  display: flex;
  flex-direction: column;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 8px;
}
.note-card h3 { margin-bottom: 0.4rem; }
.note-content { margin: 0 0 0.75rem; font-size: 0.925rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { margin-top: auto; font-size: 0.8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.note-actions { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-top: 0.5rem; font-size: 0.925rem; }

.empty { padding: 2rem 1rem; text-align: center; color: var(--ink-soft); background: var(--surface); border: 1px dashed var(--field-edge); border-radius: 8px; }

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