/* ========================================
   base.css — Jottit structural styles
   ======================================== */

/* ── 1. Reset ────────────────────────── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
}

img,
picture,
video,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

textarea {
  resize: none;
}

a {
  color: inherit;
}

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

/* ── 2. Tokens ───────────────────────── */
:root {
  /* Brand */
  --brand-1: #117a65;
  --brand-2: #28b463;
  --brand-3: #82e0aa;

  /* Status */
  --success: #2ecc71;
  --error: #e74c3c;

  /* Colors – light */
  --bg: #fff;
  --text: #444;
  --text-muted: #999;
  --text-bright: #111;
  --divider: #eee;
  --code-bg: #f5f5f5;
  --input-bg: #f5f5f5;
  --card-bg: #f7f7f8;

  /* Font families */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
  --font-mono: "SF Mono", Menlo, Consolas, monospace;

  /* Font sizes */
  --text-xs: 0.75rem;
  --text-sm: 0.85rem;
  --text-base: 1rem;
  --text-lg: 1.1rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;

  /* Font weights */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-bold: 600;

  /* Line heights */
  --leading-tight: 1.3;
  --leading-normal: 1.6;
  --leading-loose: 1.8;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 2.5rem;
  --space-8: 3rem;
  --space-9: 4rem;
  --space-10: 6rem;

  /* Layout */
  --measure: 50rem;
  --measure-narrow: 35rem;

  /* Border radius */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --radius-full: 50%;

  /* Transitions */
  --speed-fast: 100ms;
  --speed-normal: 200ms;

  /* Site-specific (theme-overridable) */
  --site-bg: var(--bg);
  --site-text: var(--text);
  --site-text-muted: var(--text-muted);
  --site-text-bright: var(--text-bright);
  --site-divider: var(--divider);
  --site-code-bg: var(--code-bg);
  --site-font: var(--font-sans);
  --site-font-header: var(--font-sans);
  --site-accent: var(--text-bright);
  --site-font-size: var(--text-base);
  --site-leading: var(--leading-normal);
  --site-measure: var(--measure);
  --editor-measure: 700px;
  --content-width: 75rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #333840;
    --text: #ccc;
    --text-muted: #777;
    --text-bright: #eee;
    --divider: #222;
    --code-bg: #1a1a1a;
    --input-bg: #2a2e34;
    --card-bg: #3c4149;
  }
}

/* Breakpoints (used in media queries) */
/* --bp-sm: 640px */
/* --bp-md: 864px */
/* --bp-lg: 1152px */

/* ── 3. Form elements ────────────────── */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--site-text-bright);
  margin-bottom: var(--space-2);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--site-font-size);
  line-height: var(--site-leading);
  color: var(--site-text-bright);
  background: var(--input-bg);
  border: 1px solid var(--site-divider);
  border-radius: var(--radius-pill);
  transition: border-color var(--speed-fast);
}

textarea {
  border-radius: var(--radius-md);
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 3l2 2H4L6 3zm0 6L4 7h4L6 9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-4) center;
  background-size: 16px 16px;
}

@media (forced-colors: active) {
  select {
    background-image: none;
  }
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--site-text-muted);
}

button,
input[type="submit"] {
  border: none;
  background: none;
  cursor: pointer;
}

/* ── 4. Main layout ──────────────────── */
main {
  max-width: var(--site-measure);
  margin: 0 auto;
  padding: var(--space-10) var(--space-4) var(--space-8);
}

/* ── 5. Avatar settings ──────────────── */
.avatar-section {
  margin-bottom: var(--space-6);
}

.avatar-row {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
  margin: 0;
}

.avatar-placeholder {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-full);
  background: var(--input-bg);
  color: var(--site-divider);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-placeholder svg {
  width: 100%;
  height: 100%;
}

.avatar-detail {
  min-width: 0;
}

.avatar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-2);
}

.avatar-actions a {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.avatar-remove {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #c0392b;
}

.avatar-detail .text-muted {
  font-size: var(--text-sm);
  margin-bottom: 0;
}

/* ── 6. Components ───────────────────── */
.top-nav {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
}

.top-nav a,
.top-nav .link-button {
  color: #bbb;
}

.link-button {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.inline {
  display: inline;
}

.page-centered {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-4);
  text-align: center;
}

.logo {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: 0;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2), var(--brand-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: inline-block;
}

.form-narrow {
  width: 100%;
  max-width: 340px;
  margin-bottom: var(--space-4);
}

.form-narrow .pill-input input {
  flex: 1;
}

.pill-input {
  display: flex;
  align-items: center;
  background: var(--site-bg);
  border: 1px solid var(--site-divider);
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4);
  font-family: var(--font-mono);
}

.pill-input-suffix {
  font-size: var(--text-base);
  color: var(--site-text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: var(--space-4);
}

.pill-input input {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: var(--space-2) 0;
  font-size: var(--text-base);
  min-width: 0;
  width: auto;
}

.pill-input-right input {
  text-align: right;
}

.pill-input input:focus {
  outline: none;
  border: none;
}

.pill-input input:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--site-bg) inset;
  -webkit-text-fill-color: var(--site-text-bright);
}

.pill-input button {
  border-radius: var(--radius-pill);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--bg);
  background: var(--text-bright);
  transition: opacity var(--speed-fast);
}

.pill-input button:hover {
  opacity: 0.8;
}

.passcode-inputs {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

.passcode-inputs input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-size: var(--text-2xl);
  font-family: var(--font-mono);
  background: var(--site-bg);
  border: 1px solid var(--site-text-muted);
  border-radius: var(--radius-md);
  padding: 0;
}

.passcode-inputs input:focus {
  outline: none;
  border-color: var(--site-text-bright);
}

.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--site-bg);
  background: var(--site-text-bright);
  border: none;
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--speed-fast);
}

.btn:hover {
  opacity: 0.8;
}

.icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: -2px;
}

.btn--sm {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
}

.btn--primary {
  background: color-mix(in srgb, var(--brand-1), var(--brand-2) 40%);
  color: #fff;
}

.btn--secondary {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--site-text-muted);
  border: 1px solid var(--site-divider);
  border-radius: var(--radius-pill);
  text-decoration: none;
  transition: color var(--speed-fast), border-color var(--speed-fast);
}

.btn--secondary:hover {
  color: var(--site-text-bright);
  border-color: var(--site-text-muted);
}

.panel {
  max-width: var(--measure);
  margin: 0 auto;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel--narrow {
  max-width: var(--measure-narrow);
}

@media (max-width: 640px) {
  .panel {
    background: none;
    border-radius: 0;
    padding: 0;
  }
}

.settings-form input[type="text"] {
  border-radius: var(--radius-pill);
}

.settings-form textarea {
  border-radius: 16px;
}

.panel-divider {
  border-top: 1px solid color-mix(in srgb, var(--site-divider), transparent 50%);
  margin-top: var(--space-8);
  padding-top: var(--space-8);
}

.domain-verified {
  color: var(--success);
  font-weight: var(--weight-medium);
}

.domain-verified::before {
  content: "\2713 ";
}

.domain-status {
  font-size: var(--text-sm);
}

.domain-instructions {
  margin: var(--space-4) 0;
  font-size: var(--text-sm);
}

.domain-instructions pre {
  font-size: var(--text-xs);
  margin-bottom: var(--space-3);
}

.domain-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.domain-remove {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #c0392b;
}

.export-zone {
  max-width: var(--measure-narrow);
  margin: var(--space-8) auto 0;
  border: 1px solid var(--site-divider);
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.export-zone h3 {
  margin-bottom: var(--space-2);
}

.export-zone p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.danger-zone {
  max-width: var(--measure-narrow);
  margin: var(--space-8) auto 0;
  border: 1px solid #c0392b;
  border-radius: var(--radius-md);
  padding: var(--space-6);
}

.danger-zone h3 {
  color: #c0392b;
  margin-bottom: var(--space-2);
}

.danger-zone p {
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.btn--danger {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: #fff;
  background: #c0392b;
  border: none;
  border-radius: var(--radius-pill);
  text-decoration: none;
  cursor: pointer;
  transition: opacity var(--speed-fast);
}

.btn--danger:hover {
  opacity: 0.8;
  color: #fff;
}

.btn--danger:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.error,
.success {
  font-size: var(--text-sm);
  display: inline-block;
  padding: var(--space-1) var(--space-4);
  border-radius: var(--radius-pill);
}

.error {
  color: var(--error);
  background: color-mix(in srgb, var(--error), transparent 88%);
}

.success {
  color: var(--success);
  background: color-mix(in srgb, var(--success), transparent 88%);
}

.editor-page {
  background: #fff;
  color: #444;
}

.editor {
  max-width: var(--editor-measure);
  min-height: 100vh;
  position: relative;
}

.editor form {
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.editor-error {
  color: #c0392b;
  margin-bottom: var(--space-4);
}

.editor .editor-title {
  border: none;
  border-radius: 0;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: #111;
  background: #fff;
  padding: 0;
  margin-bottom: var(--space-4);
}

.editor .editor-body {
  border: none;
  flex: 1;
  min-height: 60vh;
  font-size: var(--text-lg);
  line-height: var(--leading-loose);
  color: #444;
  background: #fff;
  padding: 0;
  resize: none;
}

.editor .editor-body.drag-over {
  border: 1px dashed #ddd;
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.editor-actions {
  position: fixed;
  bottom: var(--space-8);
  right: max(var(--space-4), calc((100vw - var(--editor-measure)) / 2 + var(--space-4)));
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.editor-draft {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 0;
}

.editor-draft input[type="checkbox"] {
  width: auto;
}

.draft-label {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: var(--weight-medium);
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: middle;
  border: 1px solid color-mix(in srgb, var(--site-text-muted), transparent 60%);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  margin-left: var(--space-3);
  background: #eee;
}

.back-link {
  margin-right: auto;
}

/* ── Admin menu ─────────────────────── */
.admin-menu {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  right: var(--space-4);
  z-index: 100;
  max-width: var(--content-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-4);
  pointer-events: none;
}

.admin-menu > * {
  pointer-events: auto;
}

.admin-avatar,
.admin-initials {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.admin-avatar img {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0;
}

.admin-avatar:hover,
.admin-initials:hover {
  box-shadow: 0 0 0 1px var(--bg), 0 0 0 2px var(--text-muted);
}

.admin-initials {
  background: var(--input-bg);
  border: 1px solid var(--divider);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  user-select: none;
}

.admin-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--space-4);
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.16);
  min-width: 160px;
  padding: var(--space-3) 0;
}

#admin-toggle:checked ~ .admin-dropdown {
  display: block;
}

.admin-dropdown a,
.admin-dropdown button {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
  color: var(--text);
  text-decoration: none;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
}

.admin-dropdown-divider {
  border: none;
  border-top: 1px solid var(--divider);
  margin: var(--space-2) 0;
}

.admin-dropdown a:hover,
.admin-dropdown button:hover {
  background: var(--input-bg);
  color: var(--text-bright);
}

/* ── Page nav ────────────────────────── */
/* ── Inline nav management ───────────── */
.page-nav-item {
  display: inline;
  position: relative;
}

.page-nav-item.dragging {
  opacity: 0.4;
}

.page-nav-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  border: 1px solid var(--site-text-muted);
  font-size: var(--text-sm);
  color: var(--site-text-muted);
  vertical-align: middle;
  line-height: 1;
  transition: color var(--speed-fast), border-color var(--speed-fast);
}

.page-nav-add:hover {
  color: var(--site-text-bright);
  border-color: var(--site-text-bright);
}

.page-nav-item ~ .page-nav-add-wrap {
  position: absolute;
  left: calc(100% + var(--space-5));
  top: 50%;
  transform: translateY(-50%);
}

input.page-nav-add-input {
  position: absolute;
  right: calc(100% + var(--space-3));
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  width: 200px;
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border-radius: var(--radius-pill);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--speed-normal), transform var(--speed-normal);
}

input.page-nav-add-input.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(0);
}

/* ── 7. Utilities ────────────────────── */
.mb-4 {
  margin-bottom: var(--space-4);
}

.mb-8 {
  margin-bottom: var(--space-8);
}

.mt-4 {
  margin-top: var(--space-4);
}

.mt-6 {
  margin-top: var(--space-6);
}

.text-muted {
  color: var(--site-text-muted);
  font-size: var(--text-sm);
}

.pl-5 {
  padding-left: var(--space-5);
}

.text-center {
  text-align: center;
}

.actions {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
}
