/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Base styles */
:root {
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;

  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;

  /* Colors */
  --color-white: #ffffff;
  --color-surface: #f0f0f0;
  --color-surface-muted: #fafafa;
  --color-border: #e0e0e0;

  --color-success-surface: #d1e7dd;
  --color-success-surface-alpha: #d1e7dd48;
  --color-success-surface-hover: #d1e7dd9f;
  --color-success-border: #a3cfbb;
  --color-success-text: #0a3622;
  --color-success-accent: #3a956c;
  --color-success-main: #198754;
  --color-success-dark: #0b683e;

  /* Typography */
  --font-size-h1: 2.5rem;
  --font-size-h2: 1.75rem;
  --font-size-h3: 1.25rem;
}

/* Headings */
h1,
h2 {
  font-weight: 600;
}

h1 {
  font-size: var(--font-size-h1);
}

h2 {
  font-size: var(--font-size-h2);
}

h3 {
  font-size: var(--font-size-h3);
}

/* Code blocks */
pre,
code,
.trix-content pre {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
}

pre,
.trix-content pre {
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

code {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
}

/* Layout styles */
.container {
  max-width: 800px;
}

.container-sm {
  margin-inline: auto;
  max-width: 30rem;
}

/* Component styles */
.card {
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: var(--space-md);
  background-color: var(--color-surface);
  font-weight: 600;
  font-size: 1.125rem;
}

.card-body {
  padding: var(--space-xl);
}

.card--completed {
  border: 1px solid var(--color-success-border);
  background-color: var(--color-success-surface-alpha);

  .card-header {
    background-color: var(--color-success-surface);
    color: var(--color-success-text);
  }

  .form-check-input:checked {
    background-color: var(--color-success-accent);
    border-color: var(--color-success-accent);
  }

  .btn-outline-primary {
    background-color: var(--color-white);
    border-color: var(--color-success-main);
    color: var(--color-success-main);

    &:hover {
      background-color: var(--color-success-main);
      border-color: var(--color-success-main);
      color: var(--color-white);
    }
  }

  pre {
    background-color: var(--color-success-surface);
    border-color: var(--color-success-border);
  }
}

/* =============================================
   Days index — hero
   ============================================= */
.days-hero {
  position: relative;
  margin-bottom: var(--space-lg);
  overflow: hidden;
}

.days-progress {
  position: relative;
  z-index: 1;
}

.days-progress-stats {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
}

.days-progress-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 500;
}

.days-progress-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-success-main);
}

.days-progress-track {
  width: 100%;
  height: 8px;
  background: var(--color-surface);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgb(0 0 0 / 6%);
}

.days-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #059669 0%, #34d399 50%, #6ee7b7 100%);
  background-size: 200% 100%;
  animation: progress-shimmer 2s ease-in-out infinite;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* =============================================
   Days index — month groups
   ============================================= */
.days-month-group {
  margin-bottom: var(--space-2xl);
}

.days-month-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.days-month-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  white-space: nowrap;
}

.days-month-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--color-border) 0%, transparent 100%);
}

/* =============================================
   Days index — grid
   ============================================= */
.days-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

@media (min-width: 576px) {
  .days-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* =============================================
   Day card — base
   ============================================= */
.day-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-lg) var(--space-xl);
  text-decoration: none;
  color: #1e293b;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: linear-gradient(165deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 1px 2px rgb(0 0 0 / 4%);
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  animation: card-enter 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--card-index, 0) * 30ms);

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgb(0 0 0 / 6%);
    border-color: #cbd5e1;
    color: #1e293b;
    text-decoration: none;
  }

  &:active {
    transform: translateY(-1px);
    transition-duration: 0.1s;
  }
}

.day-card--locked {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
  background: var(--color-surface);
  border-color: transparent;
  box-shadow: none;
  padding: var(--space-md) var(--space-xl);
}

/* Suppress entrance animation on Turbo cache preview and when replacing a preview */
html[data-turbo-preview] .day-card,
.turbo-replace-preview .day-card {
  animation: none;
}

@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.day-card-date {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #94a3b8;
  transition: color 0.2s;
}

.day-card:hover .day-card-date {
  color: #64748b;
}

.day-card-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: #1e293b;
  transition: color 0.2s;
}

.day-card-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  background: var(--color-success-main);
  color: white;
}

.day-card-lock {
  font-size: 0.7rem;
  color: #cbd5e1;
}

/* =============================================
   Day card — today
   ============================================= */
.day-card--today {
  border-color: #818cf8;
  background: linear-gradient(165deg, #eef2ff 0%, #e0e7ff 100%);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 4%),
    0 0 0 3px rgba(129, 140, 248, 0.2);

  .day-card-date {
    color: #6366f1;
  }

  .day-card-title {
    color: #4338ca;
  }

  &:hover {
    border-color: #6366f1;
    box-shadow:
      0 4px 12px rgb(99 102 241 / 10%),
      0 0 0 3px rgba(129, 140, 248, 0.2);

    .day-card-title {
      color: #4338ca;
    }
  }
}

.day-card-today-tag {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: white;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  padding: 2px 8px;
  border-radius: 999px;
  line-height: 1.6;
  box-shadow: 0 1px 4px rgb(99 102 241 / 30%);
}

/* =============================================
   Day card — completed
   ============================================= */
.day-card--completed {
  border-color: var(--color-success-border);
  background: linear-gradient(165deg, #f0fdf4 0%, #dcfce7 100%);

  .day-card-title {
    color: var(--color-success-dark);
  }

  .day-card-date {
    color: var(--color-success-accent);
  }

  &:hover {
    border-color: var(--color-success-accent);
    box-shadow: 0 4px 12px rgb(25 135 84 / 8%);

    .day-card-title {
      color: var(--color-success-dark);
    }
  }
}

/* completed + today combo */
.day-card--completed.day-card--today {
  border-color: var(--color-success-border);
  background: linear-gradient(165deg, #f0fdf4 0%, #dcfce7 100%);
  box-shadow:
    0 1px 2px rgb(0 0 0 / 4%),
    0 0 0 3px rgba(25, 135, 84, 0.2);

  .day-card-title {
    color: var(--color-success-dark);
  }

  .day-card-today-tag {
    background: linear-gradient(135deg, var(--color-success-main), var(--color-success-accent));
    box-shadow: 0 1px 4px rgb(25 135 84 / 30%);
  }

  &:hover {
    border-color: var(--color-success-accent);
    box-shadow:
      0 4px 12px rgb(25 135 84 / 8%),
      0 0 0 3px rgba(25, 135, 84, 0.2);
  }
}

.list-group-item {
  padding: var(--space-lg);
  transition: all 0.2s ease-in-out;

  &:hover {
    background-color: var(--color-surface-muted);
  }
}

trix-editor.min-height-md {
  min-height: 7rem;
}

trix-editor.min-height-lg {
  min-height: 14rem;
}

.demo-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.demo-card {
  border: 1px solid #ddd;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.demo-card h3 {
  margin: 0 0 .5rem;
  font-size: 1.1rem;
}

.demo-card p:last-child {
  margin-bottom: 0;
}

.alert p:last-child {
  margin-bottom: 0;
}

/* Day navigation — breadcrumb arrows */
.breadcrumb-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
  box-shadow: 0 1px 3px rgb(0 0 0 / 4%);
  color: #6c757d;
  font-size: 0.75rem;
  text-decoration: none;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.breadcrumb-arrow-btn:hover {
  color: #111;
  background: rgb(0 0 0 / 5%);
  border-color: #ccc;
  transform: scale(1.12);
}

.breadcrumb-arrow-btn--disabled {
  opacity: 0.25;
  cursor: default;
  pointer-events: none;
}

/* Day navigation — footer cards */
.day-nav {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-2xl);
}

.day-nav-links {
  display: flex;
  justify-content: space-between;
  gap: var(--space-lg);
}

.day-nav-link {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg) var(--space-xl);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease-in-out;
  min-width: 0;
  flex: 1;
}

.day-nav-link:hover {
  background-color: var(--color-surface-muted);
  border-color: #ccc;
  transform: translateY(-2px);
  box-shadow: 0 0.25rem 0.75rem rgb(0 0 0 / 8%);
}

.day-nav-prev {
  align-items: flex-start;
}

.day-nav-next {
  align-items: flex-end;
}

.day-nav-placeholder {
  border: none;
  pointer-events: none;
}

.day-nav-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.day-nav-title {
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.day-nav-overview {
  display: inline-block;
  font-size: 0.875rem;
  color: #888;
  text-decoration: none;
  transition: color 0.15s;
}

.day-nav-overview:hover {
  color: #333;
}

/* Breadcrumbs */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.breadcrumb-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.breadcrumb-nav {
  margin-bottom: 0;
}

.breadcrumb-nav .breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.8rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 4%);
}

.breadcrumb-nav .breadcrumb-item {
  display: inline-flex;
  align-items: center;
}

.breadcrumb-nav .breadcrumb-item + .breadcrumb-item {
  padding-left: 0;
}

.breadcrumb-nav .breadcrumb-item + .breadcrumb-item::before {
  content: "";
  display: inline-block;
  width: 16px;
  height: 16px;
  margin: 0 0.35rem 0 0;
  opacity: 0.3;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M6 3l5 5-5 5'/%3E%3C/svg%3E") center / contain no-repeat;
  flex-shrink: 0;
}

.breadcrumb-nav .breadcrumb-item a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #6c757d;
  text-decoration: none;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.breadcrumb-nav .breadcrumb-item a:hover {
  color: #111;
  background-color: rgb(0 0 0 / 5%);
}

.breadcrumb-nav .breadcrumb-item a i {
  font-size: 0.65rem;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.breadcrumb-nav .breadcrumb-item a:hover i {
  opacity: 1;
}

.breadcrumb-nav .breadcrumb-item.active {
  color: #111;
  font-weight: 600;
  padding: 0.15rem 0.4rem;
  letter-spacing: -0.01em;
}
