/*
 * companion.css — Shared stylesheet for Tree Companion and Lawn Companion pages
 * Used by:
 *   /tools/tree-companion/index.html
 *   /tools/lawn-companion/index.html
 *
 * Design language: portal design system.
 * Clean bg, cards with borders, Outfit font, pill back-links,
 * decorative emojis — consistent with portal tokens.
 *
 * Class naming:
 *   Layout primitives  → .sky-bg, .bg-decor, .grass-footer, .container,
 *                        .back-link, .user-status, .section-header, .section-line
 *   Page header        → .page-icon, .page-title, .page-subtitle
 *   Cards              → .c-card, .c-card-header, .c-card-icon, .c-card-code,
 *                        .c-card-title, .c-card-desc, .c-draft-badge
 *   Badges             → .c-badge, .c-badge-active, .c-badge-soon
 *   Actions            → .c-card-actions, .c-action, .c-action.primary, .c-action.secondary
 *   Feature tags       → .c-card-features, .c-feature-tag, .c-card-target
 *   Auth               → .c-no-session
 *   Deprecated         → .c-header, .c-header-back, .c-header-user (kept for
 *                        backward compat; display:none)
 */

/* =============================================
   DESIGN TOKENS — exact match to Manager Hub
   ============================================= */
:root {
  --accent-green:     #16a34a;
  --accent-green-dark:#15803d;
  --bg-primary:       #f8fafc;
  --bg-card:          #ffffff;
  --text-primary:     #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #64748b;
  --border-subtle:    rgba(0,0,0,0.08);
  --border:           #e2e8f0;
  --shadow-md:        0 4px 12px rgba(0,0,0,0.08);
  --radius-md:        8px;
  --radius-lg:        12px;

  /* Legacy companion tokens — updated to portal design system */
  --c-primary:        #16a34a;
  --c-primary-light:  #16a34a;
  --c-primary-bg:     #f0fdf4;
  --c-text:           #0f172a;
  --c-text-muted:     #64748b;
  --c-border:         #e2e8f0;
  --c-border-coming:  #d1d5db;
  --c-bg:             #f8fafc;
  --c-card-bg:        #ffffff;
  --c-radius:         12px;
  --c-shadow:         0 4px 12px rgba(0,0,0,0.08);
  --c-shadow-hover:   0 12px 32px rgba(0,0,0,0.1);
}

/* =============================================
   RESET
   ============================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

/* =============================================
   BASE BODY — sky-to-green gradient (same as hub)
   ============================================= */
body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   SKY BACKGROUND — fixed radial gradient overlay
   ============================================= */
.sky-bg {
  display: none;
}

/* =============================================
   DECORATIVE BACKGROUND EMOJIS
   ============================================= */
.bg-decor {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.bg-emoji {
  position: absolute;
  opacity: 0.04;
  font-size: 12rem;
  transform: rotate(-15deg);
  user-select: none;
}

/* Companion-specific emoji positions — HTML sets themed emojis per page */
.bg-emoji.pos-tl  { top: 4%;  left: -5%;  font-size: 18rem; }
.bg-emoji.pos-tr  { top: 30%; right: -8%; font-size: 16rem; transform: rotate(12deg); }
.bg-emoji.pos-bl  { bottom: 18%; left: 4%; font-size: 11rem; transform: rotate(-8deg); }
.bg-emoji.pos-br  { bottom: 6%; right: 8%; font-size: 9rem;  transform: rotate(20deg); }

/* =============================================
   GRASS FOOTER — fixed decorative bar
   ============================================= */
.grass-footer {
  display: none;
}

/* =============================================
   MAIN CONTAINER
   ============================================= */
.container {
  position: relative;
  z-index: 5;
  max-width: 600px;
  margin: 0 auto;
  padding: 28px 20px 80px;
  min-height: 100vh;
}

/* =============================================
   BACK LINK — rounded pill (same as hub .back-link)
   ============================================= */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 24px;
  padding: 8px 16px;
  background: rgba(255,255,255,0.7);
  border-radius: 20px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.back-link:hover {
  background: rgba(255,255,255,0.95);
  transform: translateX(-4px);
}

/* =============================================
   PAGE HEADER — centered with icon (same as hub header)
   ============================================= */
.page-header {
  text-align: center;
  margin-bottom: 36px;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* .page-icon — gradient rounded square, portal style */
.page-icon {
  width: 80px;
  height: 80px;
  background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(22,163,74,0.3);
}

.page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.page-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* =============================================
   USER STATUS — fixed top-right pill (same as hub)
   ============================================= */
.user-status {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: white;
  border-radius: 50px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  min-height: 40px;
}

.user-status .user-avatar {
  width: 28px;
  height: 28px;
  background: var(--accent-green);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.user-status .user-name {
  font-weight: 600;
  color: var(--text-primary);
}

/* =============================================
   SECTION HEADER — uppercase label + gradient line
   ============================================= */
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  margin-top: 8px;
}

.section-header h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.section-line {
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, var(--border-subtle), transparent);
}

/* =============================================
   CARD CONTAINER — single-column, centered
   ============================================= */
.c-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* =============================================
   TOOL CARD — white glass card (mirrors hub .tool-card / .shared-card)
   ============================================= */
.c-card {
  background: var(--bg-card);
  border-radius: var(--c-radius);
  padding: 24px;
  color: var(--text-primary);
  transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
  display: block;
  text-decoration: none;
  box-shadow: var(--c-shadow);
  border: 2px solid transparent;
  animation: cardFadeIn 0.5s ease-out backwards;
}

.c-card:nth-child(1) { animation-delay: 0.1s; }
.c-card:nth-child(2) { animation-delay: 0.18s; }
.c-card:nth-child(3) { animation-delay: 0.26s; }

@keyframes cardFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* .c-card.active — clickable with green border accent on hover */
.c-card.active {
  cursor: pointer;
}

.c-card.active:hover {
  box-shadow: var(--c-shadow-hover);
  transform: translateY(-4px);
  border-color: rgba(22,163,74,0.35);
}

/* .c-card.coming-soon — muted preview card */
.c-card.coming-soon {
  opacity: 0.72;
  cursor: default;
  pointer-events: none;
  border-style: dashed;
  border-color: var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* =============================================
   CARD HEADER ROW
   ============================================= */
.c-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.c-card-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.c-card-code {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-green-dark);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* =============================================
   BADGES
   ============================================= */
.c-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 10px;
  border-radius: 20px;
  margin-left: auto;
}

.c-badge-active {
  background: #dcfce7;
  color: #15803d;
}

.c-badge-soon {
  background: #fef3c7;
  color: #92400e;
}

/* =============================================
   CARD BODY TEXT
   ============================================= */
.c-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.c-card-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 4px;
}

/* =============================================
   DRAFT COUNT BADGE
   ============================================= */
.c-draft-badge {
  display: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-green-dark);
  background: #dcfce7;
  padding: 3px 12px;
  border-radius: 20px;
  margin-top: 8px;
  margin-bottom: 2px;
}

/* =============================================
   ACTION BUTTONS
   ============================================= */
.c-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.c-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  min-height: 44px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.c-action.primary {
  background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
  color: white;
  flex: 1;
  box-shadow: 0 4px 14px rgba(22,163,74,0.35);
}

.c-action.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(22,163,74,0.5);
}

.c-action.secondary {
  background: rgba(255,255,255,0.8);
  color: var(--text-secondary);
  border: 2px solid var(--border);
  flex: 0 0 auto;
}

.c-action.secondary:hover {
  background: rgba(255,255,255,0.98);
  border-color: rgba(34,197,94,0.4);
  color: var(--text-primary);
}

@media (max-width: 380px) {
  .c-card-actions { flex-direction: column; }
  .c-action.secondary { flex: 1; }
}

/* =============================================
   FEATURE TAG CHIPS
   ============================================= */
.c-card-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.c-feature-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.7);
  border: 1px solid rgba(0,0,0,0.08);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
}

.c-card-target {
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* =============================================
   NO-SESSION BLOCK
   ============================================= */
.c-no-session {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.6);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
}

.c-no-session a {
  color: var(--greenx-dark);
  font-weight: 700;
  text-decoration: underline;
}

/* =============================================
   DEPRECATED CLASSES — kept for compat, hidden
   Legacy .c-header is replaced by .back-link pill.
   ============================================= */
.c-header       { display: none !important; }
.c-header-back  { display: none !important; }
.c-header-user  { display: none !important; }
.c-page-title   { display: none !important; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
  .page-title    { font-size: 1.85rem; }
  .page-subtitle { font-size: 0.9rem; }
  .container     { padding: 20px 16px 60px; }

  .bg-emoji          { font-size: 8rem; }
  .bg-emoji.pos-tl   { font-size: 12rem; }
  .bg-emoji.pos-tr   { font-size: 10rem; }

  .user-status { top: 12px; right: 12px; }
  .user-status .user-name { display: none; }

  .page-icon { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; }
}

/* =============================================
   DARK MODE
   NOTE: Three separate valid CSS blocks.
   Do NOT comma-group [data-theme="dark"] with @media at-rules — invalid CSS.
   ============================================= */

/* Dark mode — data-theme attribute (portal sets on <html>) */
[data-theme="dark"] body {
  background: #0e1419;
  color: #e8f5e9;
}

[data-theme="dark"] .sky-bg {
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(93,173,226,0.06) 0%, transparent 60%),
    linear-gradient(180deg, #0e1419 0%, #101820 20%, #111d1e 40%, #132318 60%, #172a1e 80%, #1c3224 100%);
}

[data-theme="dark"] .grass-footer {
  opacity: 0.3;
  filter: brightness(0.4);
}

[data-theme="dark"] .bg-emoji {
  opacity: 0.02;
}

[data-theme="dark"] .c-card {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
  color: #e8f5e9;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

[data-theme="dark"] .c-card:hover {
  background: rgba(255,255,255,0.07);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .c-card.coming-soon {
  border-color: rgba(255,255,255,0.06);
}

[data-theme="dark"] .page-icon {
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

[data-theme="dark"] .page-title {
  color: #e8f5e9;
}

[data-theme="dark"] .page-subtitle {
  color: #9cbe9c;
}

/* Dark mode — OS preference (standalone sessions) */
@media (prefers-color-scheme: dark) {
  body {
    background: #0e1419;
    color: #e8f5e9;
  }

  .sky-bg {
    background:
      radial-gradient(ellipse 120% 80% at 50% -20%, rgba(93,173,226,0.06) 0%, transparent 60%),
      linear-gradient(180deg, #0e1419 0%, #101820 20%, #111d1e 40%, #132318 60%, #172a1e 80%, #1c3224 100%);
  }

  .grass-footer {
    opacity: 0.3;
    filter: brightness(0.4);
  }

  .bg-emoji {
    opacity: 0.02;
  }

  .c-card {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.08);
    color: #e8f5e9;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }

  .c-card:hover {
    background: rgba(255,255,255,0.07);
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }

  .c-card.coming-soon {
    border-color: rgba(255,255,255,0.06);
  }

  .page-icon {
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  }

  .page-title {
    color: #e8f5e9;
  }

  .page-subtitle {
    color: #9cbe9c;
  }
}

[data-theme="dark"] .c-card-title     { color: #f0fdf4; }
[data-theme="dark"] .c-card-desc      { color: #9cbe9c; }
[data-theme="dark"] .c-card-code      { color: #6ee7b7; }
[data-theme="dark"] .c-feature-tag {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #a7c4a7;
}
[data-theme="dark"] .c-card-target    { color: #9cbe9c; }
[data-theme="dark"] .c-action.secondary {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.1);
  color: #6ee7b7;
}
[data-theme="dark"] .c-action.secondary:hover {
  background: rgba(110,231,183,0.12);
}
[data-theme="dark"] .c-draft-badge {
  background: rgba(34,197,94,0.2);
  color: #6ee7b7;
}
[data-theme="dark"] .back-link {
  background: rgba(255,255,255,0.07);
  color: #a7c4a7;
}
[data-theme="dark"] .back-link:hover {
  background: rgba(255,255,255,0.12);
}
[data-theme="dark"] .user-status {
  background: #1a2e1a;
  color: #f0fdf4;
}
[data-theme="dark"] .c-no-session {
  background: rgba(26,46,26,0.7);
  color: #9cbe9c;
}
