/* ── RESET ─────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── DARK THEME (default) ───────────────────────── */
:root {
  --bg-primary:      #0a0e14;
  --bg-gradient:     linear-gradient(135deg, #0a0e14 0%, #0d1117 100%);
  --bg-card:         #1a1f28;
  --bg-secondary:    #151920;
  --accent-primary:  #ff6b35;
  --accent-hover:    #ff855a;
  --text-primary:    #ffffff;
  --text-secondary:  #b0b8c4;
  --text-muted:      #6b7280;
  --border:          #2d3748;
  --shadow:          0 4px 6px -1px rgb(0 0 0 / .3), 0 2px 4px -2px rgb(0 0 0 / .3);
  --shadow-hover:    0 8px 24px -4px rgb(255 107 53 / .25);
  --card-glow:       0 0 0 2px rgba(255,107,53,.35);
  --header-bg:       rgba(21, 25, 32, .7);
}

/* ── LIGHT THEME ────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:      #f0f2f5;
  --bg-gradient:     linear-gradient(135deg, #f0f2f5 0%, #e4e7ec 100%);
  --bg-card:         #ffffff;
  --bg-secondary:    #f7f8fa;
  --accent-primary:  #c2410c;
  --accent-hover:    #9a3412;
  --text-primary:    #111827;
  --text-secondary:  #4b5563;
  --text-muted:      #9ca3af;
  --border:          #d1d5db;
  --shadow:          0 1px 3px rgb(0 0 0 / .06), 0 1px 2px -1px rgb(0 0 0 / .04);
  --shadow-hover:    0 8px 24px -4px rgb(194 65 12 / .15);
  --card-glow:       0 0 0 2px rgba(194,65,12,.2);
  --header-bg:       rgba(255, 255, 255, .75);
}

/* ── BASE ───────────────────────────────────────── */
body {
  font-family: 'Manrope', -apple-system, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── SMOOTH THEME TRANSITION ──────────────────── */
body,
body::before,
header,
.app-card,
.card-cta,
footer,
select, .theme-btn,
#reminders-wrap,
.reminder-chip {
  transition: background .4s ease, color .4s ease, border-color .4s ease, box-shadow .4s ease;
}

/* ── PARTICLE CANVAS BACKGROUND ───────────────── */
#particle-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}


/* ── HEADER (glassmorphism) ───────────────────── */
header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: var(--shadow);
}

.logo-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
}

.logo-img {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.logo-fallback {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
}
.logo-fallback span {
  display: block;
  font-size: .65rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}

select, .theme-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: .35rem .65rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
select option {
  background: var(--bg-card);
  color: var(--text-primary);
}
select { padding-right: 1.5rem; }
select:hover, .theme-btn:hover {
  border-color: var(--accent-primary);
  color: var(--text-primary);
}

/* ── THEME TOGGLE ANIMATION ───────────────────── */
.theme-btn {
  transition: border-color .15s, color .15s, transform .3s ease;
}
.theme-btn:active {
  transform: rotate(180deg);
}

/* ── HERO ───────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 3.5rem 2rem 2rem;
}
.hero-title {
  font-family: 'Space Mono', monospace;
  font-size: clamp(1.1rem, 3vw, 1.5rem);
  font-weight: 700;
  margin-bottom: .5rem;
  /* Gradient shimmer */
  background: linear-gradient(90deg, var(--accent-primary), #fbbf24, var(--accent-primary));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer 4s ease-in-out infinite;
}
.hero-sub {
  font-size: .9rem;
  color: var(--text-muted);
}

@keyframes shimmer {
  0%, 100% { background-position: 0% center; }
  50%      { background-position: 100% center; }
}

/* ── MAIN / GRID ────────────────────────────────── */
main {
  flex: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 4rem;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* ── GRID EXIT / ENTER ANIMATION ─────────────── */
.app-grid.exiting .app-card,
.app-grid.exiting .category-back {
  animation: cardOut .25s ease both;
}

@keyframes cardOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-15px) scale(0.97); }
}

/* ── APP CARD ───────────────────────────────────── */
.app-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: box-shadow .2s, border-color .2s, transform .15s;
  /* Staggered entrance */
  animation: cardIn .4s ease both;
  animation-delay: calc(var(--i, 0) * .07s);
  /* 3D tilt prep */
  transform-style: preserve-3d;
  will-change: transform;
}

/* ── CATEGORY CARD ───────────────────────────── */
.app-card.category {
  cursor: pointer;
  border-color: rgba(255,107,53,.2);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(255,107,53,.04) 100%);
}
[data-theme="light"] .app-card.category {
  border-color: rgba(194,65,12,.15);
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(194,65,12,.03) 100%);
}

.app-card.category:hover {
  border-color: rgba(255,107,53,.5);
  box-shadow:
    0 4px 12px rgba(0,0,0,.3),
    0 12px 40px rgba(0,0,0,.2),
    0 0 30px rgba(255,107,53,.1);
}
[data-theme="light"] .app-card.category:hover {
  border-color: rgba(194,65,12,.3);
  box-shadow:
    0 4px 16px rgba(0,0,0,.1),
    0 12px 40px rgba(0,0,0,.06),
    0 0 30px rgba(194,65,12,.08);
}

.category-cta {
  background: rgba(255,107,53,.15) !important;
  color: var(--accent-primary) !important;
}
[data-theme="light"] .category-cta {
  background: rgba(194,65,12,.1) !important;
}

.category-chevron {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  font-size: 1.8rem;
  color: var(--accent-primary);
  opacity: .4;
  transition: opacity .2s, transform .2s;
  font-weight: 300;
}
.app-card.category:hover .category-chevron {
  opacity: .8;
  transform: translateY(-50%) translateX(3px);
}

/* ── BACK BUTTON ─────────────────────────────── */
.category-back {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: .75rem;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.25rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-family: 'Manrope', sans-serif;
  font-size: .9rem;
  font-weight: 600;
  transition: color .15s, border-color .15s, background .15s;
  animation: cardIn .3s ease both;
}
.category-back:hover {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  background: rgba(255,107,53,.05);
}
.back-arrow {
  font-size: 1.1rem;
  transition: transform .2s;
}
.category-back:hover .back-arrow {
  transform: translateX(-3px);
}
.back-label {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
}

/* ── ANIMATED GRADIENT BORDER ─────────────────── */
.app-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 13px;
  padding: 1px;
  background: conic-gradient(
    from var(--border-angle, 0deg),
    transparent 30%,
    var(--accent-primary) 50%,
    transparent 70%
  );
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask-composite: exclude;
  z-index: 1;
  opacity: 0;
  transition: opacity .3s ease;
  pointer-events: none;
}
.app-card:hover::before {
  opacity: 1;
  animation: rotateBorder 3s linear infinite;
}
[data-theme="light"] .app-card:hover::before {
  opacity: .6;
}

@keyframes rotateBorder {
  to { --border-angle: 360deg; }
}

/* Register custom property for animation */
@property --border-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.app-card:hover {
  border-color: transparent;
  box-shadow:
    0 4px 12px rgba(0,0,0,.3),
    0 12px 40px rgba(0,0,0,.2),
    0 0 20px rgba(255,107,53,.06),
    inset 0 0 0 1px rgba(255,107,53,.08);
  transform: translateY(-2px);
}

/* ── CARD SPOTLIGHT (mouse-following glow) ───── */
.app-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    250px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(255,107,53,.07) 0%, transparent 100%
  );
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
  z-index: 1;
}
.app-card:hover::after { opacity: 1; }
[data-theme="light"] .app-card:hover::after {
  background: radial-gradient(
    250px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
    rgba(194,65,12,.05) 0%, transparent 100%
  );
}
[data-theme="light"] .app-card {
  box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 0 0 1px rgba(0,0,0,.03);
}
[data-theme="light"] .app-card:hover {
  box-shadow:
    0 4px 16px rgba(0,0,0,.1),
    0 12px 40px rgba(0,0,0,.06),
    0 0 20px rgba(194,65,12,.05),
    inset 0 0 0 1px rgba(194,65,12,.1);
}

/* ── SHINE SWEEP ─────────────────────────────── */
.app-card .shine-sweep {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}
.app-card .shine-sweep::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(255,255,255,.06) 45%,
    rgba(255,255,255,.1) 50%,
    rgba(255,255,255,.06) 55%,
    transparent 70%
  );
  transition: none;
}
.app-card:hover .shine-sweep::before {
  animation: shineSweep .6s ease forwards;
}

@keyframes shineSweep {
  from { left: -100%; }
  to   { left: 150%; }
}
[data-theme="light"] .app-card .shine-sweep::before {
  background: linear-gradient(
    105deg,
    transparent 30%,
    rgba(194,65,12,.04) 45%,
    rgba(194,65,12,.07) 50%,
    rgba(194,65,12,.04) 55%,
    transparent 70%
  );
}

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

/* ── CARD ICON BOUNCE ─────────────────────────── */
.card-icon {
  font-size: 2.4rem;
  line-height: 1;
  transition: transform .2s;
}
.app-card:hover .card-icon {
  animation: bounce .4s ease;
  filter: drop-shadow(0 0 10px rgba(255,107,53,.35));
}
[data-theme="light"] .app-card:hover .card-icon {
  filter: drop-shadow(0 0 8px rgba(194,65,12,.25));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  40%      { transform: translateY(-6px); }
  60%      { transform: translateY(-2px); }
}

.card-title {
  font-family: 'Space Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-desc {
  font-size: .85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
}

/* ── CTA ARROW SLIDE ──────────────────────────── */
.card-cta {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  align-self: flex-start;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: .45rem 1rem;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  pointer-events: none;
  transition: gap .2s ease;
}
.app-card:hover .card-cta {
  gap: .7rem;
}

/* ── FOOTER ─────────────────────────────────────── */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: .75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ── REMINDER WIDGET ────────────────────────────── */
#reminders-section {
  width: 100%; max-width: 620px;
  margin: 0 auto; padding: 0 1.5rem .75rem;
}
#reminders-wrap {
  background: var(--bg-card); border: 1px solid rgba(255,107,53,.3);
  border-radius: 10px; padding: .75rem 1rem; box-shadow: var(--shadow);
}
#reminders-header {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  padding-bottom: .45rem; cursor: pointer; user-select: none;
  border-bottom: 1px solid var(--border);
  font-family: 'Space Mono', monospace; font-size: .78rem;
  font-weight: 700; color: var(--accent-primary);
  transition: margin-bottom .2s;
}
#reminders-header.open { margin-bottom: .5rem; }
#reminders-header:not(.open) { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.reminder-chevron {
  font-size: .65rem; transition: transform .2s;
  display: inline-block; margin-left: .25rem;
}
#reminders-header.open .reminder-chevron { transform: rotate(180deg); }
#reminders-list {
  overflow: hidden; transition: max-height .25s ease, opacity .2s ease;
}
#reminders-list.collapsed { max-height: 0 !important; opacity: 0; }
.reminder-chip {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: .4rem .6rem;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 8px; margin-bottom: .35rem;
}
.reminder-chip:last-child { margin-bottom: 0; }
.reminder-dot { width: 8px; height: 8px; border-radius: 3px; flex-shrink: 0; margin-bottom: .2rem; }
.reminder-title { font-size: .75rem; font-weight: 700; color: var(--accent-primary); line-height: 1.2; margin-bottom: .15rem; text-transform: uppercase; letter-spacing: .03em; }
.reminder-msg { font-size: .82rem; font-weight: 600; color: var(--text-primary); line-height: 1.3; word-break: break-word; }
.reminder-date { font-size: .7rem; color: var(--text-muted); margin-top: .15rem; font-family: 'Space Mono', monospace; }
.reminder-doc-link {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600; color: var(--accent-primary);
  text-decoration: none; margin-top: .2rem;
  padding: .15rem .45rem; border: 1px solid rgba(255,107,53,.3);
  border-radius: 5px; background: rgba(255,107,53,.06);
  transition: background .15s, border-color .15s;
}
.reminder-doc-link:hover { background: rgba(255,107,53,.15); border-color: var(--accent-primary); }

/* ── RESPONSIVE: TABLET ────────────────────────── */
@media (max-width: 640px) {
  header { padding: 0 1rem; }
  .hero  { padding: 2rem 1rem 1rem; }
  main   { padding: 1rem .75rem 3rem; }
  #reminders-section { padding: 0 .75rem .75rem; }
}

/* ── RESPONSIVE: MOBILE APP-LAUNCHER ─────────── */
@media (max-width: 480px) {
  .hero { padding: 1.5rem 1rem .75rem; }
  .hero-title { font-size: 1.1rem; }
  .hero-sub { font-size: .75rem; }

  main { padding: .75rem .75rem 2rem; }

  .app-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: .75rem;
  }

  .app-card {
    padding: 1rem .75rem;
    gap: .5rem;
    align-items: center;
    text-align: center;
    border-radius: 10px;
  }

  .card-icon { font-size: 2rem; }
  .card-title { font-size: .8rem; line-height: 1.2; }
  .card-desc { display: none; }
  .card-cta { display: none; }

  .category-chevron { display: none; }

  .category-back {
    padding: .6rem 1rem;
    font-size: .8rem;
  }

  footer { padding: 1rem; font-size: .65rem; }
  #reminders-section { padding: 0 .75rem .5rem; }
}

/* ── REDUCED MOTION ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0s !important;
    animation-delay: 0s !important;
    transition-duration: 0s !important;
  }
}
