/* FlashNote Mobile — Design Tokens
   Adapted from desktop theme.css for iOS PWA */

/* --- Fonts (bundled locally) --- */
@font-face {
  font-family: 'DM Sans';
  src: url('../assets/DMSans-Variable.ttf') format('truetype');
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: 'Caveat';
  src: url('../assets/Caveat-Variable.ttf') format('truetype');
  font-weight: 400 700;
  font-display: swap;
}

/* --- Theme Variables --- */
@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-secondary: #f5f5f7;
    --surface: #f0f0f2;
    --text: #1a1a2e;
    --text-muted: #666;
    --border: #e0e0e4;
    --hover: #eaeaee;
    --accent: #FEFAA0;
    --accent-green: #2ecc71;
    --accent-green-dim: rgba(46, 204, 113, 0.1);
    --accent-mint: #B5EAD7;
    --danger: #e74c3c;
    --danger-dim: rgba(231, 76, 60, 0.08);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --input-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
    --focus-ring: 0 0 0 3px rgba(181, 234, 215, 0.4);
    --noise-opacity: 0.015;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1e1e2e;
    --bg-secondary: #1a1a28;
    --surface: #2a2a3e;
    --text: #e0e0e8;
    --text-muted: #888;
    --border: #3a3a4e;
    --hover: #33334a;
    --accent: #FEFAA0;
    --accent-green: #B5EAD7;
    --accent-green-dim: rgba(181, 234, 215, 0.12);
    --accent-mint: #B5EAD7;
    --danger: #e74c3c;
    --danger-dim: rgba(231, 76, 60, 0.12);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.2);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --input-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
    --focus-ring: 0 0 0 3px rgba(181, 234, 215, 0.25);
    --noise-opacity: 0.03;
  }
}

/* --- Base Reset --- */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* --- Typography --- */
body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* iOS safe area support */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.fn-note-text {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  line-height: 1.4;
}

/* --- Inputs --- */
.fn-input,
.fn-select,
.fn-textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* 16px prevents iOS auto-zoom on focus */
  outline: none;
  box-shadow: var(--input-shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.fn-input:focus,
.fn-select:focus,
.fn-textarea:focus {
  border-color: var(--accent-mint);
  box-shadow: var(--input-shadow), var(--focus-ring);
}

.fn-input::placeholder,
.fn-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* --- Buttons --- */
.fn-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.fn-btn:active { transform: scale(0.97); }
.fn-btn:disabled { opacity: 0.4; pointer-events: none; }

.fn-btn-primary {
  background: var(--accent);
  color: #1a1a2e;
  width: 100%;
}

.fn-btn-accent {
  background: var(--accent-green-dim);
  color: var(--accent-green);
}

.fn-btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
}

.fn-btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* --- Labels --- */
.fn-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.fn-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* --- Status dots --- */
.fn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.fn-dot-online { background: var(--accent-green); }
.fn-dot-offline { background: var(--border); }

/* --- Spinner --- */
.fn-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: fn-spin 0.6s linear infinite;
}

@keyframes fn-spin {
  to { transform: rotate(360deg); }
}

/* --- Screen layout helpers --- */
.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — excludes iOS keyboard/toolbar */
}

.screen.active {
  display: flex;
}

.screen-header {
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.screen-header h1 {
  font-size: 20px;
  font-weight: 700;
}

.screen-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* --- Note card (received notes) --- */
.note-card {
  border-radius: 14px;
  padding: 16px;
  margin: 12px 16px;
  box-shadow: var(--shadow-md);
}

.note-card .note-sender {
  font-size: 12px;
  font-weight: 600;
  color: rgba(0,0,0,0.5);
  margin-bottom: 2px;
}

.note-card .note-time {
  font-size: 11px;
  color: rgba(0,0,0,0.35);
  margin-bottom: 8px;
}

.note-card .note-message {
  font-family: 'Caveat', cursive;
  font-size: 22px;
  line-height: 1.4;
  color: rgba(0,0,0,0.7);
  word-wrap: break-word;
}

/* --- Tab bar (bottom navigation) --- */
.tab-bar {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.tab-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-bar-item.active {
  color: var(--accent-green);
}

.tab-bar-item .tab-icon {
  font-size: 22px;
  line-height: 1;
}

/* --- Empty state --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}
