/* Wiki in a Bucket — default theme.
 * Neutral styling driven by CSS variables; restyle these to make a new theme. */

:root {
  --ink: #222831;
  --muted: #5b6b7c;
  --accent: #1b6ec2;
  --accent-dark: #155a9c;
  --page: #f4f6f8;
  --card: #ffffff;
  --line: #e2e8f0;
  --sidebar: #eef2f6;
  --redlink: #c0392b;
  --radius: 10px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* The hidden attribute must win over the display rules below (.modal,
 * .sidebar-col, .controls all set display, which would otherwise override it). */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--page);
  line-height: 1.55;
}

a { color: var(--accent); }
a.redlink { color: var(--redlink); border-bottom: 1px dotted var(--redlink); }

/* --- Header / nav -------------------------------------------------------- */
.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.logo {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--ink);
}
.logo span { color: var(--accent); }

/* The nav is a construct — a Quill region — rendered as a horizontal menu. */
.nav-region .ql-editor { padding: 0; }
.nav-region .ql-editor p { display: inline; margin: 0; }
.nav-region .ql-editor a {
  display: inline-block;
  margin-right: 1.1rem;
  text-decoration: none;
  font-weight: 600;
  color: var(--muted);
}
.nav-region .ql-editor a:hover { color: var(--accent); }
.nav-region .ql-editor a.active { color: var(--accent); }

/* --- Layout: content + optional sidebar ---------------------------------- */
.layout {
  max-width: var(--maxw);
  margin: 1.5rem auto 3rem;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: stretch;
}
body.has-sidebar .layout {
  grid-template-columns: minmax(0, 1fr) 300px;
}
.content-col, .sidebar-col { display: flex; min-width: 0; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  flex: 1;
  min-width: 0;
}
/* When a sidebar is present the two cards read as one joined panel. */
body.has-sidebar #page-content.card { border-radius: var(--radius) 0 0 var(--radius); border-right: none; }
.sidebar-card { background: var(--sidebar); border-radius: 0 var(--radius) var(--radius) 0; padding: 1.5rem; }

#page-content.missing .ql-editor { color: var(--muted); }

.notice {
  margin: 0 0 1rem;
  padding: 0.6rem 0.9rem;
  background: #fff8e1;
  border: 1px solid #f0d98a;
  border-radius: 6px;
  font-size: 0.92rem;
  color: #7a5b00;
}

/* --- Footer -------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--line);
  background: var(--card);
}
.site-footer .ql-editor {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
}

/* --- Quill read vs edit chrome ------------------------------------------- */
/* Read mode: no toolbar, no borders — the content just sits in the page. */
.ql-toolbar.ql-snow { display: none; border: none; padding: 0; }
.ql-container.ql-snow { border: none; font-family: inherit; font-size: 1rem; }
.region .ql-editor { padding: 0; line-height: inherit; }
.region .ql-editor img { max-width: 100%; height: auto; }

/* Edit mode: reveal the toolbar and a light editor frame. */
body.is-editing .ql-toolbar.ql-snow {
  display: block;
  border: 1px solid var(--line);
  border-radius: 6px 6px 0 0;
  background: #fafcff;
}
body.is-editing .region .ql-container.ql-snow {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 6px 6px;
}
body.is-editing .region .ql-editor { padding: 0.75rem 0.9rem; min-height: 3rem; }
body.is-editing .region { margin-bottom: 1rem; }

/* --- Floating controls --------------------------------------------------- */
.controls {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  gap: 0.5rem;
  z-index: 50;
}
.ctl {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  background: #fff;
  color: var(--ink);
}
.ctl--edit, .ctl--save { background: var(--accent); color: #fff; }
.ctl--save:hover, .ctl--edit:hover { background: var(--accent-dark); }
.ctl--cancel { background: #fff; color: var(--muted); }
.ctl[disabled] { opacity: 0.6; cursor: default; }

/* --- Login modal --------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  width: min(92vw, 340px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.modal-box h2 { margin: 0 0 1rem; font-size: 1.2rem; }
.modal-box label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.75rem; }
.modal-box input {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
}
.login-error { color: var(--redlink); font-size: 0.85rem; margin: 0 0 0.75rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

/* --- Mobile -------------------------------------------------------------- */
@media (max-width: 820px) {
  .layout { display: block; padding: 0 0.75rem; }
  .content-col, .sidebar-col { display: block; }
  body.has-sidebar #page-content.card { border-radius: var(--radius); border-right: 1px solid var(--line); }
  .sidebar-card { border-radius: var(--radius); margin-top: 1rem; }
  .card { padding: 1.25rem; }
}
