/* notes.lakis.net -- shared notes and to-do */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e0e3e8;
  --text: #14171a;
  --muted: #6b7280;
  --accent: #0e9f6e;
  --accent-text: #ffffff;
  --danger: #c0392b;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
  /* Notch and home-indicator insets; 0 everywhere that has none. */
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px);
  --right: env(safe-area-inset-right, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2026;
    --border: #2e343d;
    --text: #e7eaee;
    --muted: #939aa5;
    --accent: #10b981;
    --accent-text: #06231a;
    --danger: #f0938b;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The hidden attribute is only a user-agent `display: none`, and every author
   rule that sets `display` silently beats it. Several components below do, so
   the attribute has to be restated here or nothing can be hidden by script. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

body { display: flex; flex-direction: column; }
#app { display: flex; flex-direction: column; height: 100%; min-height: 0; }

/* ------------------------------------------------------------------ header */

.bar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(var(--top) + 10px) calc(var(--right) + 14px) 10px calc(var(--left) + 14px);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.bar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; }
.icon-btn {
  border: 0; background: transparent; color: var(--text);
  font-size: 22px; line-height: 1; padding: 6px 10px; border-radius: 8px;
}
.icon-btn:active { background: var(--bg); }

.tabs {
  display: flex; gap: 4px; padding: 8px calc(var(--right) + 12px) 8px calc(var(--left) + 12px);
  background: var(--panel); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 19;
}
.tab {
  flex: 1; padding: 9px 0; border: 0; border-radius: 9px;
  background: transparent; color: var(--muted); font-size: 15px; font-weight: 550;
}
.tab.is-active { background: var(--bg); color: var(--text); }

/* -------------------------------------------------------------------- main */

#main { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.view {
  padding: 12px calc(var(--right) + 14px) calc(var(--bottom) + 96px) calc(var(--left) + 14px);
}
.list { display: flex; flex-direction: column; gap: 8px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 3px; font-size: 15.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card p {
  margin: 0; color: var(--muted); font-size: 13.5px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .meta { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.pin-dot { color: var(--accent); margin-right: 4px; }

.search, .todo-add input, .login input {
  width: 100%; padding: 11px 13px; font-size: 16px;   /* 16px stops iOS zooming */
  color: var(--text); background: var(--panel);
  border: 1px solid var(--border); border-radius: 10px;
}
.search { margin-bottom: 12px; }
.search:focus, .todo-add input:focus, .login input:focus {
  outline: 2px solid var(--accent); outline-offset: -1px;
}

.empty { color: var(--muted); text-align: center; padding: 32px 12px; font-size: 14px; }

/* ------------------------------------------------------------------- todos */

.todo-add { display: flex; gap: 8px; margin-bottom: 12px; }
.add-btn {
  flex: 0 0 46px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 24px; line-height: 1;
}

.todo {
  display: flex; align-items: flex-start; gap: 11px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 12px; box-shadow: var(--shadow);
}
.check {
  flex: 0 0 24px; height: 24px; margin-top: 1px;
  border: 2px solid var(--muted); border-radius: 7px;
  background: transparent; color: transparent; font-size: 15px; line-height: 20px;
  padding: 0; text-align: center;
}
.todo.is-done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.todo-text { flex: 1; min-width: 0; word-break: break-word; }
.todo.is-done .todo-text { color: var(--muted); text-decoration: line-through; }
.todo .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.del { border: 0; background: transparent; color: var(--muted); font-size: 19px; padding: 0 4px; }

.done-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  border: 0; background: transparent; color: var(--muted);
  font-size: 13px; padding: 18px 2px 8px;
}
.text-btn {
  border: 0; background: transparent; color: var(--accent);
  font-size: 14px; padding: 12px 2px; text-align: left;
}
.text-btn.danger { color: var(--danger); }

/* ------------------------------------------------------------------ editor */

.editor { display: block; }

/* One sheet of paper rather than two loose form controls, so the editor sits
   in the same card language as the rest of the app. */
.edit-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px 20px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease;
}
.edit-card:focus-within { border-color: var(--accent); }

.edit-title, .edit-body {
  width: 100%; display: block; margin: 0;
  border: 0; background: transparent; color: var(--text);
  font: inherit; outline: none;
  -webkit-appearance: none; appearance: none;
}
.edit-title {
  font-size: 20px; font-weight: 650; line-height: 1.3; padding: 0 0 12px;
}
.edit-rule { height: 1px; background: var(--border); margin-bottom: 14px; }
.edit-body {
  font-size: 16px; line-height: 1.65; padding: 0;
  min-height: 42vh; resize: none;
  overflow: hidden;            /* height is grown to fit by app.js */
}
.edit-title::placeholder, .edit-body::placeholder { color: var(--muted); opacity: .75; }

.editor-meta {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 12px; color: var(--muted); padding: 12px 4px 2px;
}
.editor-actions { display: flex; gap: 6px; }
.editor-actions .text-btn { padding: 12px 10px; }

/* --------------------------------------------------------------- fab, sheet */

.fab {
  position: fixed; right: calc(var(--right) + 18px); bottom: calc(var(--bottom) + 18px);
  width: 56px; height: 56px; border: 0; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  font-size: 30px; line-height: 1; box-shadow: 0 4px 14px rgba(0, 0, 0, .22); z-index: 30;
}
.fab:active { transform: scale(.95); }

.sheet {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35);
  display: flex; align-items: flex-end; z-index: 50;
}
.sheet-card {
  width: 100%; background: var(--panel);
  border-radius: 16px 16px 0 0;
  padding: 18px calc(var(--right) + 18px) calc(var(--bottom) + 18px) calc(var(--left) + 18px);
}
.sheet-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; }

.btn {
  width: 100%; padding: 13px; border: 0; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); font-size: 16px; font-weight: 550;
}
.btn.ghost {
  background: transparent; color: var(--text);
  border: 1px solid var(--border); margin-bottom: 8px;
}

/* ------------------------------------------------------------------- login */

.login {
  max-width: 380px; margin: 0 auto;
  padding: calc(var(--top) + 12vh) calc(var(--right) + 22px) calc(var(--bottom) + 22px) calc(var(--left) + 22px);
  display: flex; flex-direction: column; gap: 12px;
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; }
.brand img { border-radius: 14px; }
.brand h2 { margin: 0; font-size: 21px; }
.error { color: var(--danger); font-size: 14px; margin: 2px 0 0; text-align: center; }

/* ------------------------------------------------------------ toast, hint */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--bottom) + 84px);
  background: #23262b; color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: 14px; z-index: 60; max-width: 88vw; text-align: center;
}

.ios-hint {
  position: fixed; left: 10px; right: 10px; bottom: calc(var(--bottom) + 10px);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 11px 13px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18); z-index: 55;
}
.ios-hint button { border: 0; background: transparent; color: var(--muted); font-size: 20px; }

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

/* ------------------------------------------------------- to-do documents */

.doc-row { display: flex; align-items: center; gap: 10px; margin-top: 7px; }
/* Named for what it is -- `.bar` is already the app header, and a collision
   there made the header a flex sibling of #main and eat half the screen. */
.progress {
  flex: 1; height: 5px; border-radius: 3px;
  background: var(--border); overflow: hidden;
}
.progress > span { display: block; height: 100%; background: var(--accent); }
.count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  color: var(--accent-text); background: var(--accent);
  border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: 2px;
}
.card.is-complete h3 { color: var(--muted); }

.banner {
  background: var(--accent); color: var(--accent-text);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
  font-size: 14px; font-weight: 550; text-align: center;
}
