/* ===== Markdown Notes - style.css (v3, full dark theme) ===== */

:root {
  color-scheme: dark;

  --bg: #0d1020;
  --surface: #151a2e;
  --surface-2: #1b2138;
  --line: #262d4a;
  --ink: #e8ebf7;
  --ink-soft: #98a1c2;
  --accent: #7c8cff;
  --accent-strong: #5b6bf0;
  --accent-tint: rgba(124, 140, 255, 0.14);
  --danger: #ff7b7b;
  --success: #3ecf8e;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.35), 0 16px 36px rgba(91, 107, 240, 0.22);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

::selection {
  background: rgba(124, 140, 255, 0.35);
  color: #fff;
}

/* ===== Background: deep navy with soft indigo glows ===== */
html {
  min-height: 100%;
  background:
    radial-gradient(700px 380px at 12% -6%, rgba(91, 107, 240, 0.28), transparent 70%),
    radial-gradient(640px 360px at 95% 0%, rgba(150, 90, 230, 0.18), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

/* Whole page = one centered column */
body {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px 72px;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Page-load animation (one calm sequence) ===== */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* "backwards" so no transform is left behind (keeps editor fullscreen working) */
body > nav,
body > h1,
body > input,
body > .editor-toolbar,
body > .CodeMirror,
body > .editor-statusbar,
body > button,
body > #notes {
  animation: rise 0.55s var(--ease) backwards;
}

body > h1                    { animation-delay: 0.06s; }
body > input:nth-of-type(1)  { animation-delay: 0.12s; }
body > input:nth-of-type(2)  { animation-delay: 0.18s; }
body > .editor-toolbar       { animation-delay: 0.24s; }
body > .CodeMirror           { animation-delay: 0.26s; }
body > .editor-statusbar     { animation-delay: 0.3s; }
body > button                { animation-delay: 0.34s; }
body > #notes                { animation-delay: 0.14s; }

/* ===== Navigation ===== */
nav {
  display: flex;
  gap: 4px;
  width: fit-content;
  margin: 24px 0 8px;
  padding: 5px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
}

nav a,
body > a {
  padding: 8px 18px;
  border-radius: 999px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

/* fallback if links are not wrapped in <nav> */
body > a { display: inline-block; margin-top: 24px; }

nav a:hover,
body > a:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
}

nav a.active {
  background: var(--accent-tint);
  color: #c9d0ff;
  box-shadow: inset 0 0 0 1px rgba(124, 140, 255, 0.35);
}

/* ===== Headings ===== */
h1 {
  position: relative;
  margin: 34px 0 30px;
  padding-bottom: 16px;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* short accent line under the heading = clean, professional touch */
h1::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 56px;
  height: 3px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
}

/* ===== Inputs ===== */
input {
  display: block;
  width: 100%;
  margin-bottom: 14px;
  padding: 13px 16px;
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
}

input::placeholder { color: #6b7499; }

input:hover { border-color: #353e63; }

input:focus {
  outline: none;
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.18), var(--shadow-sm);
  transform: translateY(-1px);
}

/* ===== SimpleMDE editor (dark) ===== */
.editor-toolbar {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  opacity: 1;
  box-shadow: var(--shadow-sm);
}

.editor-toolbar:hover { opacity: 1; }

.editor-toolbar a {
  color: var(--ink-soft) !important;
  border: 1px solid transparent !important;
  border-radius: 8px;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}

.editor-toolbar a:hover,
.editor-toolbar a.active {
  background: var(--accent-tint);
  border-color: transparent !important;
  color: #c9d0ff !important;
}

.editor-toolbar i.separator {
  border-left: 1px solid var(--line);
  border-right: none;
}

.CodeMirror {
  min-height: 320px;
  padding: 8px 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.7;
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.CodeMirror-focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(124, 140, 255, 0.14), var(--shadow-sm);
}

.CodeMirror-cursor { border-left: 2px solid var(--accent) !important; }

.CodeMirror-selected,
.CodeMirror-focused .CodeMirror-selected { background: rgba(124, 140, 255, 0.28) !important; }

.CodeMirror-gutters { background: transparent; border: none; }

/* markdown syntax colours inside the editor */
.CodeMirror .cm-header,
.CodeMirror .cm-strong   { color: #fff; }
.CodeMirror .cm-em       { color: #d5d9f2; }
.CodeMirror .cm-link,
.CodeMirror .cm-url      { color: var(--accent); }
.CodeMirror .cm-quote    { color: #7fd1b9; }
.CodeMirror .cm-comment  { color: #f0b37e; background: rgba(255, 255, 255, 0.05); border-radius: 4px; }
.CodeMirror .cm-formatting { color: #6b7499; }

.editor-statusbar {
  padding: 10px 4px 0;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.editor-preview,
.editor-preview-side {
  padding: 18px 22px;
  background: var(--surface);
  color: var(--ink);
}

.editor-preview a,
.editor-preview-side a { color: var(--accent); }

.editor-preview pre,
.editor-preview-side pre {
  background: #090c18;
  border-radius: 8px;
}

.editor-preview code,
.editor-preview-side code { background: rgba(255, 255, 255, 0.07); }

/* fullscreen mode */
.editor-toolbar.fullscreen { background: var(--surface); border-color: var(--line); }
.CodeMirror-fullscreen { background: var(--surface); border-color: var(--line); }
.editor-preview-side { border-color: var(--line); }

/* ===== Buttons ===== */
button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 22px;
  padding: 12px 26px;
  background: linear-gradient(135deg, var(--accent-strong), #8b5cf6);
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(91, 107, 240, 0.35);
  cursor: pointer;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease), filter 0.2s var(--ease);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  filter: brightness(1.08);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(91, 107, 240, 0.35);
}

button:focus-visible,
nav a:focus-visible {
  outline: 3px solid rgba(124, 140, 255, 0.5);
  outline-offset: 2px;
}

button:disabled {
  background: #2a3050;
  color: #6b7499;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

/* Refresh = secondary button */
#refreshBtn {
  margin-top: 0;
  margin-bottom: 26px;
  background: var(--surface);
  color: #c9d0ff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

#refreshBtn:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  filter: none;
}

/* ===== Status message ===== */
#msg {
  min-height: 1.4em;
  margin: 16px 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--success);
}

#msg.error { color: var(--danger); }

/* ===== Notes list ===== */
#notes {
  display: grid;
  gap: 18px;
}

#notes > * {
  padding: 24px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  animation: rise 0.45s var(--ease) backwards;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease), border-color 0.25s var(--ease);
}

#notes > *:hover {
  transform: translateY(-3px);
  border-color: #353e63;
  border-left-color: var(--accent);
  box-shadow: var(--shadow-md);
}

#notes > *:nth-child(2) { animation-delay: 0.06s; }
#notes > *:nth-child(3) { animation-delay: 0.12s; }
#notes > *:nth-child(4) { animation-delay: 0.18s; }
#notes > *:nth-child(5) { animation-delay: 0.24s; }

#notes > * > h2,
#notes > * > h3:first-child {
  margin: 0 0 4px;
  font-size: 1.25rem;
  line-height: 1.3;
  color: #fff;
}

#notes small,
#notes .author,
#notes .meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

/* ===== Rendered markdown ===== */
#notes p,
#notes ul,
#notes ol { margin: 0.7em 0; }

#notes ul,
#notes ol { padding-left: 1.4em; }

#notes h1,
#notes h2,
#notes h3 { color: #fff; }

/* the page-level heading style should not leak into notes */
#notes h1 { padding: 0; margin: 0.6em 0 0.4em; font-size: 1.5rem; }
#notes h1::after { display: none; }

#notes blockquote {
  margin: 1em 0;
  padding: 6px 16px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
}

#notes code {
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #f3c999;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 0.88em;
}

#notes pre {
  padding: 16px 18px;
  overflow-x: auto;
  background: #090c18;
  color: #e7eaf6;
  border: 1px solid var(--line);
  border-radius: 10px;
}

#notes pre code {
  padding: 0;
  background: none;
  color: inherit;
}

#notes hr { border: none; border-top: 1px solid var(--line); }

#notes img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

#notes a { color: var(--accent); }

/* ===== Mobile ===== */
@media (max-width: 600px) {
  body { padding: 0 14px 48px; }
  h1 { font-size: 1.5rem; }
  #notes > * { padding: 18px 20px; }
}

/* ===== Respect reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}