/* Whole stylesheet for the site. Hand-written, no build step, no dependency:
   served straight from /public so it stays an external stylesheet and the
   `style-src 'self'` CSP in src/middleware.ts holds without exceptions. */

:root {
  --bg: #fffbeb;
  --surface: #fff;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --muted: #a8a29e;
  --dim: #78716c;
  --body: #44403c;
  --ink: #292524;
  --ink-strong: #1c1917;
  --hover: #e7e5e4;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 0.25rem;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- reset ---------- */

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

body,
h1,
p,
figure {
  margin: 0;
}

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

body {
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

img,
svg {
  display: block;
  max-width: 100%;
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* Toggled from JS in several views; must beat any layout display. */
.hidden {
  display: none !important;
}

/* ---------- shared primitives ---------- */

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  color: var(--dim);
}

.btn {
  padding: 0.25rem 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--dim);
}

.btn:hover {
  color: var(--ink);
}

.btn-lg {
  padding: 0.375rem 0.75rem;
}

.btn-outline {
  border: 1px solid var(--line-strong);
  color: var(--body);
}

.btn-outline:hover {
  background: var(--hover);
  color: var(--body);
}

/* both rules are needed: .btn:hover outranks a bare .btn-danger */
.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  color: var(--danger-hover);
}

.text-input {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  padding: 0.375rem 0.75rem;
  color: var(--ink);
  outline: none;
}

.text-input:focus {
  border-color: var(--dim);
}

/* ---------- splash (src/pages/index.astro) ---------- */

.splash {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  background: var(--surface);
  color: var(--body);
}

.splash-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 0 auto;
  max-width: 28rem;
  padding: 0 1.5rem;
  text-align: center;
}

.splash-art {
  width: 8rem;
  height: auto;
  color: var(--muted);
}

.splash-main h1 {
  font-size: 1.875rem;
  font-weight: 600;
  color: var(--ink-strong);
}

.splash-footer {
  border-top: 1px solid var(--line);
  padding: 1rem 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--dim);
}

/* ---------- password gate & fatal error (lib/client/app.ts) ---------- */

.gate {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

.gate-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.gate-input {
  width: 16rem;
  background: var(--surface);
  padding: 0.5rem 0.75rem;
}

.error-text {
  margin: 0;
  padding: 1rem;
  font-family: var(--mono);
  color: var(--ink);
}

/* ---------- modals (lib/client/views/dialogs.ts) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(28 25 23 / 0.4);
}

.modal {
  width: 20rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 1rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.15);
}

.modal-label {
  margin-bottom: 0.5rem;
  color: var(--dim);
}

.modal-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
}

/* second field in the confirm-password dialog */
.modal-input + .modal-input {
  margin-top: 0.5rem;
}

.modal-error {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* ---------- notes workspace (lib/client/views/workspace.ts) ---------- */

.layout {
  display: flex;
  height: 100vh;
}

.sidebar {
  display: flex;
  width: 18rem;
  flex-shrink: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.sidebar-title {
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem;
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.create-btn {
  margin: 0.5rem 0.75rem;
}

.note-list {
  flex: 1;
  overflow-y: auto;
}

.note-item {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 0;
  background: none;
  padding: 0.5rem 1rem;
  text-align: left;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-item:hover {
  background: var(--surface);
}

.note-item.is-active {
  background: var(--hover);
  color: var(--ink-strong);
}

.side-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  border-top: 1px solid var(--line);
  padding: 0.5rem;
}

.main {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 0.375rem 0.75rem;
}

.toolbar-right,
.note-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pane {
  min-height: 0;
  flex: 1;
}

.pane-empty {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.editor {
  height: 100%;
  width: 100%;
  resize: none;
  border: 0;
  background: var(--bg);
  padding: 1rem;
  font-family: var(--mono);
  line-height: 1.625;
  color: var(--ink);
  outline: none;
}

/* ---------- admin console (lib/client/views/admin.ts) ---------- */

.admin-page {
  margin: 0 auto;
  max-width: 42rem;
  padding: 2.5rem 1.5rem;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.admin-create {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.admin-input {
  flex: 1;
  min-width: 0;
  padding: 0.375rem 0.75rem;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  color: var(--dim);
}

.admin-list {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.625rem 1rem;
}

.admin-row + .admin-row {
  border-top: 1px solid var(--line);
}

.admin-row-main {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.75rem;
}

.admin-name {
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-name:hover {
  text-decoration: underline;
}

.badges {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--dim);
  white-space: nowrap;
}

.badge {
  border-radius: var(--radius);
  background: var(--hover);
  padding: 0.125rem 0.375rem;
}

.row-actions {
  display: flex;
  gap: 0.25rem;
}

.admin-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  font-size: 0.875rem;
  color: var(--dim);
}

.sep {
  margin: 0 0.5rem;
  color: var(--line-strong);
}

/* ---------- image gallery (lib/client/views/gallery.ts) ---------- */

.gallery-page {
  margin: 0 auto;
  max-width: 56rem;
  padding: 2.5rem 1.5rem;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.gallery-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.5rem;
}

.frame-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.5rem;
}

.grid-empty {
  grid-column: 1 / -1;
  padding: 4rem 0;
  text-align: center;
  color: var(--muted);
}

.tile {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  background: none;
}

.tile:hover {
  border-color: var(--muted);
}

.thumb {
  height: 10rem;
  width: 100%;
  object-fit: cover;
}

.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: rgb(0 0 0 / 0.85);
  padding: 1.5rem;
}

.viewer {
  position: relative;
  min-height: 0;
  width: 100%;
  flex: 1;
  touch-action: none;
  overflow: hidden;
}

.viewer-img {
  position: absolute;
  left: 0;
  top: 0;
  max-width: none;
  transform-origin: top left;
  border-radius: var(--radius);
  user-select: none;
  -webkit-user-select: none;
}

.viewer-bar {
  display: flex;
  max-width: 100%;
  align-items: center;
  gap: 1rem;
}

.viewer-caption {
  font-size: 0.875rem;
  color: var(--line-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viewer-btn {
  padding: 0.25rem 0.5rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  font-size: 0.875rem;
  color: var(--line-strong);
}

.viewer-btn:hover {
  color: var(--surface);
}

.viewer-btn.is-danger {
  color: #f87171;
}

.viewer-btn.is-danger:hover {
  color: #fca5a5;
}
