/* =====================================================================
   styles.css
   A distraction-free, premium-feeling notepad UI.
   Dark mode by default (deep charcoal + off-white), with an automatic
   light-mode fallback for users whose OS prefers light.
   ===================================================================== */

/* ---- Design tokens --------------------------------------------------- */
:root {
  --bg: #1a1b1e;              /* deep charcoal background */
  --bg-editor: #1a1b1e;
  --text: #e9e9ec;            /* soft off-white */
  --text-dim: #8a8b90;
  --caret: #8ab4ff;
  --accent: #8ab4ff;          /* soft periwinkle accent */
  --accent-warn: #e0b25a;
  --accent-error: #e0685a;
  --status-bg: rgba(255, 255, 255, 0.06);
  --status-border: rgba(255, 255, 255, 0.08);
  --shadow: rgba(0, 0, 0, 0.35);
  --selection: rgba(138, 180, 255, 0.25);

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-editor: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Light mode: kicks in automatically based on OS/browser preference */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf9f7;
    --bg-editor: #faf9f7;
    --text: #2a2a2e;
    --text-dim: #8a8a8e;
    --caret: #4a6fd4;
    --accent: #4a6fd4;
    --accent-warn: #b8862f;
    --accent-error: #c74b3d;
    --status-bg: rgba(0, 0, 0, 0.04);
    --status-border: rgba(0, 0, 0, 0.06);
    --shadow: rgba(0, 0, 0, 0.08);
    --selection: rgba(74, 111, 212, 0.15);
  }
}

/* ---- Reset ------------------------------------------------------------ */
* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  overflow: hidden; /* the textarea itself scrolls, not the page */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: var(--selection);
}

/* ---- App shell --------------------------------------------------------
   A single full-viewport container. The textarea fills essentially all
   of it, with breathing room via padding rather than visible chrome. */
.app {
  position: relative;
  height: 100vh;
  height: 100dvh; /* modern viewport unit, plays nicer with mobile browser bars */
  width: 100vw;
  display: flex;
}

/* ---- Editor ------------------------------------------------------------ */
.editor {
  flex: 1;
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg-editor);
  color: var(--text);
  caret-color: var(--caret);

  font-family: var(--font-editor);
  font-size: 1.15rem;
  line-height: 1.7;
  letter-spacing: 0.1px;

  /* Comfortable reading width on huge screens, full-bleed on small ones */
  padding: 8vh max(5vw, calc(50% - 380px)) 6vh;

  transition: background 0.3s ease;
}

.editor::placeholder {
  color: var(--text-dim);
}

/* Slim, unobtrusive scrollbar */
.editor::-webkit-scrollbar {
  width: 10px;
}
.editor::-webkit-scrollbar-thumb {
  background: var(--status-border);
  border-radius: 999px;
}
.editor::-webkit-scrollbar-track {
  background: transparent;
}

/* ---- Status indicator ---------------------------------------------------
   A tiny, quiet pill in the corner. It never demands attention — it just
   fades in when there's something to report. */
.status {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 7px 14px;
  border-radius: 999px;

  background: var(--status-bg);
  border: 1px solid var(--status-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px var(--shadow);

  font-size: 0.78rem;
  color: var(--text-dim);

  opacity: 0.85;
  transition: opacity 0.25s ease, transform 0.25s ease;
  user-select: none;
  pointer-events: none; /* purely informational, never blocks clicks/taps */
}

.status__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

/* State variants toggled via JS by swapping the modifier class */
.status--idle .status__dot {
  background: var(--text-dim);
}

.status--saving .status__dot {
  background: var(--accent-warn);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-warn) 25%, transparent);
  animation: pulse 1s ease-in-out infinite;
}

.status--saved .status__dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

.status--offline .status__dot,
.status--error .status__dot {
  background: var(--accent-error);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-error) 25%, transparent);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Responsiveness ----------------------------------------------------- */

/* Tablet */
@media (max-width: 900px) {
  .editor {
    padding: 6vh 6vw 6vh;
    font-size: 1.1rem;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .editor {
    padding: 5vh 5vw 8vh; /* extra bottom room so the status pill never overlaps text */
    font-size: 1rem;
    line-height: 1.65;
  }

  .status {
    bottom: 14px;
    right: 14px;
    padding: 6px 12px;
    font-size: 0.72rem;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .editor {
    padding: 4vh 4vw 8vh;
  }
}

/* Respect users who've asked for reduced motion */
@media (prefers-reduced-motion: reduce) {
  .status,
  .status__dot {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- Developer Credit ------------------------------------------------ */
.credit {
  position: fixed;
  bottom: 20px;      /* Matches the status pill vertical alignment */
  left: 20px;        /* Places it in the opposite corner */
  font-size: 0.75rem;
  color: var(--text-dim);
  opacity: 0.6;
  user-select: none;
  pointer-events: none; /* Ensures it doesn't block clicks */
}

/* Mobile adjustment to match your media queries */
@media (max-width: 600px) {
  .credit {
    bottom: 14px;
    left: 14px;
    font-size: 0.70rem;
  }
}

/* ---- Download Button ------------------------------------------------ */
.btn-download {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--status-bg);
  border: 1px solid var(--status-border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  z-index: 10;
}

.btn-download:hover {
  color: var(--text);
  background: var(--selection);
  border-color: var(--accent);
}

/* Mobile adjustment */
@media (max-width: 600px) {
  .btn-download {
    top: 14px;
    right: 14px;
  }
}