/*
  styles.css
  ==========
  All colors, spacing, and layout live here.

  The two blocks below hold the colors.
  - The first block is the LIGHT theme.
  - The second block is the DARK theme.
  To change a color, change its value in both blocks.
*/

/* ---------- LIGHT theme colors ---------- */
:root {
  --bg: #fbfbf9;            /* page background */
  --surface: #ffffff;      /* cards and bars */
  --surface-2: #f4f4f1;    /* soft fills */
  --text: #17181a;         /* main text */
  --muted: #6f7075;        /* dates and hints */
  --border: #e7e7e2;       /* thin lines */
  --accent: #0f766e;       /* buttons, links, pins (deep teal) */
  --accent-soft: rgba(15, 118, 110, 0.08);
  --danger: #b42318;       /* delete */
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 2px 6px rgba(20, 20, 20, 0.05);

  --radius: 12px;
  --bar-height: 56px;
  --max-width: 720px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---------- DARK theme colors ---------- */
[data-theme="dark"] {
  --bg: #16171a;
  --surface: #202226;
  --surface-2: #282a2f;
  --text: #e9e9e7;
  --muted: #9a9ba1;
  --border: #313339;
  --accent: #2dd4bf;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --danger: #f97066;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
}


/* ---------- Base ---------- */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Hide anything with this class. */
.hidden {
  display: none !important;
}

/* Each screen fills the window. */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}


/* ---------- Shared text fields and buttons ---------- */

.text-field {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  font-family: inherit;
}

.text-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  padding: 13px 16px;
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}

.primary-button:hover {
  filter: brightness(1.05);
}

/* Icon buttons in the top bar. Large enough to tap. */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
}


/* ---------- Login screen ---------- */

#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box {
  width: 100%;
  max-width: 380px;
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}

.login-title {
  margin: 0 0 6px;
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-lead {
  margin: 0 0 20px;
  color: var(--muted);
}

.hint {
  margin: 10px 2px 0;
  font-size: 13px;
  color: var(--muted);
}

.error {
  margin: 8px 2px 0;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
}


/* Secret key field with its show/hide button. */

.login-input-wrap {
  position: relative;
}

.login-input-wrap .text-field {
  padding-right: 48px;
}

.login-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  color: var(--muted);
}

.login-toggle.active {
  color: var(--accent);
}


/* ---------- Top bar (list and editor) ---------- */

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--bar-height);
  padding: 0 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.top-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.editor-actions {
  display: flex;
  gap: 2px;
}

/* Keeps the top-bar title centered when the two sides differ in width. */
.top-bar-spacer {
  width: 44px;
  flex: none;
}


/* ---------- Settings menu ---------- */

.menu {
  position: fixed;
  top: calc(var(--bar-height) - 4px);
  left: 8px;
  z-index: 20;
  min-width: 200px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-item {
  display: block;
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

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


/* Highlight color swatches in the toolbar. */

.tool-button.swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.tool-button.swatch .dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: block;
}

.tool-button.swatch.yellow .dot { background: #fde047; }
.tool-button.swatch.green .dot { background: #86efac; }
.tool-button.swatch.blue .dot { background: #93c5fd; }
.tool-button.swatch.pink .dot { background: #f9a8d4; }
.tool-button.swatch.orange .dot { background: #fdba74; }
.tool-button.swatch.purple .dot { background: #d8b4fe; }


/* ---------- List content ---------- */

.content {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
}

.new-note-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
}

.new-note-button .plus {
  font-size: 20px;
  line-height: 1;
}

.note-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-item {
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Pinned notes get a teal edge. */
.note-item.pinned {
  border-left: 3px solid var(--accent);
}

.note-open {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  text-align: left;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  min-width: 0;
}

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

.note-item-title {
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-date {
  font-size: 13px;
  color: var(--muted);
}

.note-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  color: var(--muted);
  background: transparent;
  border: none;
  border-left: 1px solid var(--border);
  cursor: pointer;
}

.note-pin:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* A pinned note shows a solid teal pin. */
.note-pin.active {
  color: var(--accent);
}

.empty-message {
  margin-top: 40px;
  text-align: center;
  color: var(--muted);
}


/* Red accents (trash icon, delete-all menu item). */
.icon-button.danger {
  color: var(--danger);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item.danger:hover {
  background: rgba(180, 35, 24, 0.08);
}

[data-theme="dark"] .menu-item.danger:hover {
  background: rgba(249, 112, 102, 0.12);
}


/* ---------- Editor ---------- */

.toolbar {
  position: sticky;
  top: var(--bar-height);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tool-button {
  flex: none;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}

.tool-button:hover {
  background: var(--surface-2);
}

.tool-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex: none;
}

.editor {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px;
  min-height: 0;
}

.note-title {
  width: 100%;
  padding: 4px 0;
  margin-bottom: 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
}

.note-title::placeholder {
  color: var(--muted);
}

.note-body {
  flex: 1;
  width: 100%;
  padding: 4px 0 40px;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  outline: none;
  overflow-y: auto;
  min-height: 200px;
}

/* Show placeholder text when the note body is empty. */
.note-body:empty::before {
  content: attr(data-placeholder);
  color: var(--muted);
  pointer-events: none;
}


/* ---------- Keyboard focus (accessibility) ---------- */

button:focus-visible,
.text-field:focus-visible,
.note-body:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}


/* ---------- Respect reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}


/* ---------- A little more room on wider screens ---------- */

@media (min-width: 700px) {
  .login-title {
    font-size: 44px;
  }
}
