/* Wikipedia (Vector-ish) styling for OurStory Wiki, with light + dark themes */

:root {
  --bg: #f6f6f6;
  --content-bg: #fff;
  --text: #202122;
  --muted: #54595d;
  --faint: #72777d;
  --link: #3366cc;
  --link-new: #ba0000;
  --border: #a2a9b1;
  --accent: #a7d7f9;      /* header / content edge */
  --panel: #f8f9fa;       /* toc, code, tabs, tables */
  --panel-border: #eaecf0;
  --th-bg: #eaecf0;
  --flash-bg: #d5fdf4;
  --flash-border: #00af89;
  --err-bg: #fee7e6;
  --err-border: #dd3333;
  --btn-bg: #3366cc;
  --btn-text: #fff;
  --shadow: rgba(0,0,0,.08);
}

/* Manual dark mode (toggled) */
:root[data-theme="dark"] {
  --bg: #0f1114;
  --content-bg: #1b1e23;
  --text: #e6e6e6;
  --muted: #a9b1ba;
  --faint: #8a9199;
  --link: #6ea8ff;
  --link-new: #ff6d6d;
  --border: #3a4048;
  --accent: #2a5a86;
  --panel: #24282e;
  --panel-border: #33393f;
  --th-bg: #2c3138;
  --flash-bg: #123a30;
  --flash-border: #1c8f74;
  --err-bg: #40201e;
  --err-border: #c0392b;
  --btn-bg: #3f6fd6;
  --btn-text: #fff;
  --shadow: rgba(0,0,0,.5);
}

/* System dark mode, only when the user hasn't chosen manually */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1114;
    --content-bg: #1b1e23;
    --text: #e6e6e6;
    --muted: #a9b1ba;
    --faint: #8a9199;
    --link: #6ea8ff;
    --link-new: #ff6d6d;
    --border: #3a4048;
    --accent: #2a5a86;
    --panel: #24282e;
    --panel-border: #33393f;
    --th-bg: #2c3138;
    --flash-bg: #123a30;
    --flash-border: #1c8f74;
    --err-bg: #40201e;
    --err-border: #c0392b;
    --btn-bg: #3f6fd6;
    --btn-text: #fff;
    --shadow: rgba(0,0,0,.5);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
a.new { color: var(--link-new); }        /* red links = page doesn't exist yet */
a.new:visited { color: var(--link-new); opacity: .8; }

/* Header */
#mw-header {
  background: var(--content-bg);
  border-bottom: 1px solid var(--accent);
}
.header-inner {
  max-width: 1200px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 16px;
}
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); }
.logo-mark { font-size: 26px; }
.logo-text { font-size: 20px; font-weight: bold; font-family: Georgia, serif; }
.search { margin-left: auto; display: flex; }
.search input {
  border: 1px solid var(--border); border-right: none; padding: 5px 8px;
  border-radius: 2px 0 0 2px; width: 240px; font-size: 13px;
  background: var(--content-bg); color: var(--text);
}
.search button {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 5px 12px; border-radius: 0 2px 2px 0; cursor: pointer;
}
.user-links { display: flex; gap: 14px; align-items: center; font-size: 13px; }

/* Theme toggle button */
.theme-toggle {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 999px; width: 30px; height: 30px; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0; display: inline-flex;
  align-items: center; justify-content: center;
}
.theme-toggle:hover { border-color: var(--link); }

/* Body layout */
#mw-body { max-width: 1200px; margin: 0 auto; display: flex; align-items: flex-start; }
#mw-sidebar {
  width: 160px; flex-shrink: 0; padding: 16px 10px; font-size: 12.5px;
}
.portal { margin-bottom: 18px; }
.portal h3 {
  font-size: 12px; font-weight: normal; color: var(--muted);
  text-transform: lowercase; border-bottom: 0; margin: 0 0 4px;
}
.portal ul { list-style: none; margin: 0; padding: 0 0 0 6px; }
.portal li { margin: 2px 0; }

/* Content area */
#mw-content {
  flex: 1; background: var(--content-bg); border: 1px solid var(--accent);
  border-top: none; padding: 18px 28px 28px; min-height: 70vh; min-width: 0;
}
#firstHeading {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 28px; font-weight: normal; line-height: 1.3;
  border-bottom: 1px solid var(--border); padding-bottom: 4px; margin: 0 0 2px;
}
.tagline { color: var(--muted); font-size: 13px; font-style: italic; margin-bottom: 14px; }

/* Page action tabs */
.page-actions { display: flex; gap: 2px; float: right; margin-top: -4px; }
.tab, .tab-form { display: inline-block; }
.tab {
  font-size: 12.5px; padding: 3px 10px; background: var(--panel);
  border: 1px solid var(--border); border-bottom: none; border-radius: 3px 3px 0 0;
  color: var(--link);
}
.tab.active { background: var(--content-bg); font-weight: bold; color: var(--text); }
.tab.danger { color: var(--link-new); cursor: pointer; }
.tab-form { margin: 0; }
.tab-form button { font-family: inherit; }

/* Article typography */
.mw-parser-output h2 {
  font-family: Georgia, serif; font-weight: normal; font-size: 22px;
  border-bottom: 1px solid var(--border); padding-bottom: 3px; margin: 24px 0 8px;
}
.mw-parser-output h3 { font-size: 18px; margin: 18px 0 6px; }
.mw-parser-output p { margin: 8px 0; }
.mw-parser-output img { max-width: 100%; height: auto; }
.mw-parser-output ul, .mw-parser-output ol { margin: 8px 0 8px 24px; }
.mw-parser-output blockquote {
  border-left: 4px solid var(--panel-border); margin: 10px 0; padding: 4px 16px;
  color: var(--muted);
}
.mw-parser-output table {
  border-collapse: collapse; margin: 12px 0; background: var(--panel);
  border: 1px solid var(--border);
}
.mw-parser-output th, .mw-parser-output td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.mw-parser-output th { background: var(--th-bg); }
.mw-parser-output code {
  background: var(--panel); border: 1px solid var(--panel-border); border-radius: 2px;
  padding: 1px 4px; font-size: 13px;
}
.mw-parser-output hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* Table of contents */
.toc {
  display: inline-block; background: var(--panel); border: 1px solid var(--border);
  padding: 8px 16px; margin: 12px 0; font-size: 13px;
}
.toc h2 { border: none; font-size: 15px; margin: 0 0 4px; text-align: center; }
.toc ul { list-style: none; margin: 0; padding-left: 12px; }

.last-updated { margin-top: 26px; padding-top: 8px; border-top: 1px solid var(--panel-border);
  color: var(--faint); font-size: 12px; }

/* Flash / notices */
.flash { background: var(--flash-bg); border: 1px solid var(--flash-border); padding: 8px 12px;
  margin-bottom: 12px; border-radius: 2px; }
.flash.err { background: var(--err-bg); border-color: var(--err-border); }

/* Editor */
.edit-help { background: var(--panel); border: 1px solid var(--panel-border); padding: 8px 12px; }
textarea#editor {
  width: 100%; min-height: 460px; font-family: monospace; font-size: 13.5px;
  line-height: 1.5; padding: 12px; border: 1px solid var(--border); border-radius: 2px;
  background: var(--content-bg); color: var(--text);
}
.editor-actions { margin-top: 10px; display: flex; align-items: center; gap: 12px; }
button, .btn-cancel {
  font-size: 14px; padding: 6px 16px; border-radius: 2px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
.editor-actions button, .new-form button, .login-card button {
  background: var(--btn-bg); color: var(--btn-text); border-color: var(--btn-bg);
}
.btn-cancel { text-decoration: none; }
#upload-status { color: var(--muted); font-size: 12px; }

.new-form { display: flex; flex-direction: column; gap: 8px; max-width: 420px; }
.new-form input { padding: 8px; border: 1px solid var(--border); font-size: 14px;
  background: var(--content-bg); color: var(--text); }
.new-form button { align-self: flex-start; }

.allpages, .search-results { line-height: 1.9; }
.snippet { color: var(--muted); font-size: 12.5px; margin-left: 4px; }

/* Photo gallery grid */
.pswp-gallery {
  display: grid; gap: 8px; margin-top: 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.pswp-thumb {
  position: relative; display: block; overflow: hidden; border-radius: 4px;
  aspect-ratio: 1 / 1; background: var(--panel); border: 1px solid var(--panel-border);
}
.pswp-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .25s ease;
}
.pswp-thumb:hover img { transform: scale(1.05); }
.pswp-caption-label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px;
  font-size: 11px; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65));
  opacity: 0; transition: opacity .2s;
}
.pswp-thumb:hover .pswp-caption-label { opacity: 1; }
.pswp__custom-caption, .pswp .custom-caption { display: none; }
.pswp .pswp__custom-caption { display: block; }
.pswp__custom-caption {
  position: absolute; bottom: 16px; left: 0; right: 0; text-align: center;
  color: #fff; font-size: 14px;
}

/* Footer */
#mw-footer {
  max-width: 1200px; margin: 12px auto; padding: 12px 16px;
  color: var(--faint); font-size: 12px; border-top: 1px solid var(--accent);
}

/* Login page */
.login-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--content-bg); border: 1px solid var(--accent); border-radius: 4px;
  padding: 36px 40px; width: 340px; text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
}
.login-mark { font-size: 46px; }
.login-card h1 { font-family: Georgia, serif; font-weight: normal; margin: 6px 0; color: var(--text); }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card input {
  width: 100%; padding: 9px; border: 1px solid var(--border); font-size: 15px;
  margin-bottom: 12px; border-radius: 2px; background: var(--content-bg); color: var(--text);
}
.login-card button { width: 100%; padding: 9px; font-size: 15px; }

/* PIN pad */
.pin-display { display: flex; justify-content: center; gap: 12px; margin: 6px 0 14px; }
.pin-display span {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); background: transparent;
}
.pin-display span.filled { background: var(--btn-bg); border-color: var(--btn-bg); }
#pin-input {
  position: absolute; opacity: 0; height: 0; width: 0; padding: 0;
  margin: 0; border: 0; pointer-events: none;
}
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px;
}
.keypad button {
  width: 100%; aspect-ratio: 1 / 1; font-size: 22px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center;
}
.keypad button:active { background: var(--btn-bg); color: var(--btn-text); }
.keypad .key-util { font-size: 18px; color: var(--muted); background: transparent; border-color: transparent; }
.pin-enter { width: 100%; padding: 10px; font-size: 15px; }
.admin-link {
  width: 100%; margin-top: 14px; background: transparent; border: none;
  color: var(--muted); font-size: 12.5px; cursor: pointer; text-decoration: underline;
}
#admin-form input { width: 100%; padding: 9px; border: 1px solid var(--border);
  font-size: 15px; margin: 8px 0 12px; border-radius: 2px;
  background: var(--content-bg); color: var(--text); }

/* Hamburger button — hidden on desktop, shown on mobile */
.hamburger {
  display: none; border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 18px; line-height: 1; padding: 4px 10px;
  border-radius: 3px; cursor: pointer;
}
#sidebar-backdrop { display: none; }

/* Mobile: sidebar becomes a slide-in drawer behind a hamburger */
@media (max-width: 720px) {
  .hamburger { display: inline-flex; align-items: center; }
  .search input { width: 140px; }

  #mw-body { flex-direction: column; }

  #mw-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 250px; max-width: 82vw; padding: 18px 16px;
    background: var(--content-bg); border-right: 1px solid var(--accent);
    overflow-y: auto; transform: translateX(-100%);
    transition: transform .22s ease; box-shadow: 2px 0 12px var(--shadow);
  }
  body.sidebar-open #mw-sidebar { transform: translateX(0); }

  #sidebar-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.45);
    opacity: 0; pointer-events: none; transition: opacity .22s ease;
  }
  body.sidebar-open #sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }

  #mw-content { border-left: none; border-right: none; padding: 16px; }
  #mw-header .header-inner { flex-wrap: nowrap; }
  .logo-text { font-size: 17px; }
}
