/* WSRS Listening Sessions Notes — base styles.
   Accessibility first: high contrast, always-visible focus, respects user prefs. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #555555;
  --border: #767676;
  --link: #0b5fff;
  --link-visited: #6b3fa0;
  --focus: #0b5fff;
  --error: #b3261e;
  --ok: #1c7c34;
  --accent-bg: #f0f3ff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f2f2f2;
    --muted: #b8b8b8;
    --border: #9a9a9a;
    --link: #7db1ff;
    --link-visited: #c9a9ff;
    --focus: #7db1ff;
    --error: #ff8a80;
    --ok: #7ee08a;
    --accent-bg: #1b2233;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 100%/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1.125rem;
  color: var(--fg);
  background: var(--bg);
}

main {
  max-width: 60rem;
  margin: 0 auto;
  padding: 1.5rem;
}

header, footer {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
footer {
  border-bottom: 0;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

a { color: var(--link); }
a:visited { color: var(--link-visited); }

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

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 2px solid var(--focus);
}
.skip-link:focus {
  left: 0;
}

/* Primary nav */
nav[aria-label="Primary"] {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1.25rem;
}
.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}
.nav-links [aria-current="page"] {
  font-weight: 700;
  text-decoration: none;
}
.signed-in-as {
  color: var(--muted);
  margin-left: auto;
}

/* Forms */
form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 28rem;
}
label {
  font-weight: 600;
}
input[type="text"],
input[type="password"],
select,
textarea {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--fg);
}
button {
  font: inherit;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--accent-bg);
  color: var(--fg);
  cursor: pointer;
}
button:hover:not(:disabled) {
  border-color: var(--focus);
}
button:disabled {
  cursor: default;
  opacity: 0.6;
}

.error {
  color: var(--error);
  font-weight: 600;
}

/* --- Phase 2: tables, session form, actions ---------------------------- */

.toolbar {
  margin: 1rem 0;
}

.export-links {
  margin: 1.5rem 0 0;
  color: var(--muted);
}
.export-links a {
  margin: 0 0.15rem;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
}
/* Names the table (aria-labelledby). A heading, not a <caption>, so NVDA's
   "next table" jump lands in the grid rather than on caption text. */
.table-caption {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
thead th {
  background: var(--accent-bg);
}
.sort-btn {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.25rem 0;
  font-weight: 700;
}
.sort-btn:hover:not(:disabled) {
  text-decoration: underline;
}

/* Session form */
.session-form {
  max-width: 44rem;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
}
.field textarea {
  min-height: 18rem;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
}
.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.save-status {
  font-weight: 600;
  min-height: 1.5em;
}
.save-status.error {
  color: var(--error);
}

/* Actions */
.session-actions {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
}
.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
button.danger {
  border-color: var(--error);
  color: var(--error);
}
button.danger:hover:not(:disabled) {
  border-color: var(--error);
}
.confirm-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border: 2px solid var(--error);
  border-radius: 4px;
  max-width: 28rem;
}

.conflict-reload {
  margin-bottom: 1rem;
}

/* Visually present but primarily an announcement target */
.sr-live {
  min-height: 1.5em;
  margin: 0.5rem 0;
}

/* --- Phase 3: Markdown editor --------------------------------------- */

.md-editor {
  margin-top: 0.25rem;
}
.md-tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
}
.md-tab {
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 4px 4px 0 0;
  background: var(--bg);
  padding: 0.4rem 1rem;
  margin-bottom: -2px;
}
.md-tab[aria-selected="true"] {
  background: var(--accent-bg);
  border-bottom: 2px solid var(--accent-bg);
  font-weight: 700;
}

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0.5rem;
}
.md-tool {
  padding: 0.35rem 0.7rem;
  font-size: 0.95rem;
}
.md-textarea-label {
  display: block;
  margin-bottom: 0.25rem;
}
.md-textarea {
  width: 100%;
  min-height: 18rem;
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
}

#md-panel-preview {
  padding-top: 0.75rem;
}
.md-preview {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 1rem;
  min-height: 18rem;
  overflow-x: auto;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview table {
  width: auto;
  min-width: 60%;
}
.md-preview-empty {
  color: var(--muted);
  font-style: italic;
}

.draft-banner {
  border: 2px solid var(--focus);
  background: var(--accent-bg);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  max-width: 44rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.draft-banner p { margin: 0; }

/* --- Phase 4: collaboration --------------------------------------- */

/* "Someone else changed this session" — persistent and focusable. */
.remote-banner {
  border: 2px solid var(--focus);
  background: var(--accent-bg);
  border-radius: 4px;
  padding: 1rem;
  margin: 0 0 1.5rem;
  max-width: 44rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.remote-banner p { margin: 0; }

/* The three-way conflict choice, shown next to the save-status line. */
.conflict-box {
  border: 2px solid var(--error);
  background: var(--bg);
  border-radius: 4px;
  padding: 1rem;
  margin: 1rem 0;
  max-width: 44rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.conflict-box p { margin: 0; }

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