/* ════════════════════════════════════════════════════════════
   TEMENOS LIFE · css/base.css
   Foundations: custom properties, resets, typography, shared
   utility classes. All colour references go through CSS vars so
   theme.js swaps them at runtime.
   ════════════════════════════════════════════════════════════ */

/* ── Design tokens (defaults; theme.js overrides via <body> style) */
:root {
  --bg-color:       #1C201C;
  --bg-surface:     #232823;
  --bg-raised:      #2A2F2A;
  --thread-color:   #4FA86A;
  --thread-dim:     #3a7d50;
  --ai-color:       #7eb8a0;
  --text-primary:   #E8EDE8;
  --text-secondary: #9aaa9a;
  --text-muted:     #5a6a5a;
  --border:         rgba(255,255,255,0.07);
  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      20px;
  --shadow-card:    0 2px 16px rgba(0,0,0,0.4);
  --font-display:   'Cormorant Garamond', Georgia, serif;
  --font-body:      'Inter', system-ui, sans-serif;
  --sidebar-w:      220px;
  --tabbar-h:       64px;
  --transition:     200ms ease;
}

/* ── Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
ul, ol { list-style: none; }
a { color: var(--thread-color); text-decoration: none; }

/* ── Typography scale */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
}
h1 { font-size: 2.2rem; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
p  { color: var(--text-secondary); }

/* ── Auth gate */
#auth-gate {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.auth-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}
.brand-mark {
  display: block;
  aspect-ratio: 1;
  background: var(--thread-color);
  -webkit-mask: url('../img/temenos-master-clean.png') center / contain no-repeat;
  mask: url('../img/temenos-master-clean.png') center / contain no-repeat;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  color: var(--thread-color);
}
.auth-brand-name {
  font-family: var(--font-display);
  font-size: clamp(2rem, 7vw, 2.85rem);
  line-height: 0.95;
  color: var(--thread-color);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-mark-large {
  width: clamp(4.75rem, 16vw, 6.7rem);
  opacity: 0.95;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--thread-color) 16%, transparent));
}
.auth-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-secondary);
}
.auth-form {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  padding-top: 0.15rem;
}
.auth-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.25rem;
}
.auth-actions .btn-primary { flex: 1; }
.auth-error {
  font-size: 0.82rem;
  color: #e06c75;
  margin-bottom: 0.5rem;
}
.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  width: 100%;
  max-width: 320px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.btn-email-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 320px;
  padding: 0.68rem 1.5rem;
  border: 1px solid color-mix(in srgb, var(--thread-color) 48%, var(--border));
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: color-mix(in srgb, var(--thread-color) 8%, transparent);
  font-size: 0.9rem;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
}
.btn-email-toggle:hover,
.btn-email-toggle[aria-expanded="true"] {
  border-color: var(--thread-color);
  background: color-mix(in srgb, var(--thread-color) 14%, transparent);
  color: var(--text-primary);
}
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-primary);
  width: 100%;
  max-width: 320px;
  transition: border-color var(--transition), background var(--transition);
}
.btn-google:hover { border-color: var(--text-secondary); background: var(--bg-raised); }

/* ── Buttons */
.btn-primary {
  padding: 0.65rem 1.75rem;
  background: var(--thread-color);
  color: #111;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 0.9rem;
  transition: opacity var(--transition);
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  padding: 0.55rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: border-color var(--transition), color var(--transition);
}
.btn-ghost:hover { border-color: var(--thread-color); color: var(--text-primary); }

/* ── Cards */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-card);
}

/* ── App shell layout */
#app-shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  /* bottom padding so content clears the mobile tab bar */
  padding-bottom: calc(var(--tabbar-h) + 1rem);
}
@media (min-width: 768px) {
  .content-area {
    padding-bottom: 1.5rem;
    margin-left: var(--sidebar-w);
  }
}

/* ── Placeholder (pillar stubs) */
.pillar-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 40vh;
  color: var(--text-muted);
}
.pillar-icon { font-size: 2.5rem; }

/* ── Form elements */
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
label { font-size: 0.8rem; color: var(--text-secondary); letter-spacing: 0.04em; text-transform: uppercase; }
input[type="text"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--thread-color);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Chip row (multi-select tags) */
.chip-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  padding: 0.3rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.chip.is-selected {
  background: var(--thread-color);
  border-color: var(--thread-color);
  color: #111;
}

/* ── Utility */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-muted  { color: var(--text-muted); }
.text-thread { color: var(--thread-color); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* ── Skeleton loading */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.6;  }
}
.skeleton-block {
  background: var(--bg-raised);
  border-radius: var(--radius-sm);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line {
  height: 13px;
  margin-bottom: 10px;
  background: var(--bg-raised);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}
.skeleton-line.short  { width: 38%; }
.skeleton-line.medium { width: 62%; }
.skeleton-card {
  height: 158px;
  background: var(--bg-raised);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ── View error state */
.view-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  min-height: 35vh;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.view-error p { font-size: 0.9rem; }
