/*
 * Design System - Base Styles
 *
 * CSS custom properties, base HTML elements, and typography.
 * Based on the design exploration documented in WEEK_VIEW_DESIGN_FINDINGS.md
 */

/* ============================================
   CSS Custom Properties
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Princess+Sofia&family=Caveat:wght@400;700&family=Karla:wght@400;500;600&family=Crimson+Pro:wght@300;400&family=Reenie+Beanie&display=swap');

:root {
  /* Base Colors */
  --paper-bg: #FAF5ED;
  --paper-texture: #F2EBE0;

  /* Parchment */
  --parchment: #B8A08C;
  --parchment-dark: #9A8470;
  --parchment-light: #C4B5A0;

  /* Ink */
  --ink-dark: #3A3A3A;
  --ink-medium: #555;
  --ink-light: #AAA;

  /* Immovable (Blue) */
  --slate-blue: #4A6D8C;
  --dusty-blue: #5A7D9C;
  --charcoal-blue: #3D5A73;

  /* Color family CSS variables are dynamically injected from ColorFamily model */
  /* See app/views/layouts/application.html.erb for injection point */

  /* Decorative Accents */
  --dusty-rose: #D4A59A;
  --terra-cotta: #C9A593;
  --warm-tan: #DCC9B8;

  /* Semantic Colors (Toast, Badges, Status) */
  --color-success: #10b981;
  --color-success-muted: #6a9a5a;  /* Softer green for autosave indicators */
  --color-error: #ef4444;
  --color-info: #3b82f6;
  --color-warning: #f59e0b;
  --color-warning-light: #FEF3C7;
  --color-warning-dark: #92400E;

  /* Completed Task Colors — injected dynamically from the "completed" category's
   * color family in _color_family_styles.html.erb. No fallbacks here because
   * base.css loads AFTER the inline <style> tag and would override them. */

  /* UI Chrome Colors - fixed aesthetic colors for non-category UI elements.
   * These are NOT tied to task categories. Never use --cat-X-* variables for
   * buttons, progress bars, form radio highlights, sliders, or other generic UI.
   * --cat-X-* is exclusively for task/time-block category coloring. */
  --ui-green: #f0fae8;
  --ui-green-dark: #bec7a0;
  --ui-green-accent: #afba97;

  --ui-amber: #fcefe4;
  --ui-amber-dark: #f9c095;
  --ui-amber-accent: #e6b67f;

  --ui-blue: #e7e5f4;
  --ui-blue-dark: #b0c6e6;
  --ui-blue-accent: #87a8c0;

  --ui-pink: #fff1f1;
  --ui-pink-dark: #f0b6a5;
  --ui-pink-accent: #dda39c;

  /* Typography */
  --font-logo: 'Princess Sofia', cursive;
  --font-handwritten: 'Caveat', cursive;
  --font-accent: 'Reenie Beanie', cursive;
  --font-body: 'Karla', sans-serif;
  --font-serif: 'Crimson Pro', serif;

  /* Font sizes */
  --font-size-xs: 12px;
  --font-size-sm: 14px;
  --font-size-base: 16px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;
  --font-size-2xl: 32px;
  --font-size-3xl: 40px;

  /* Font weights */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line heights */
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.6;

  /* Opacity values */
  --opacity-subtle: 0.05;
  --opacity-light: 0.08;
  --opacity-medium: 0.15;
  --opacity-moderate: 0.4;
  --opacity-drag-highlight: 0.6;
  --opacity-fade: 0.7;
  --opacity-semi: 0.8;
  --opacity-bright: 0.9;
  --opacity-bright-hover: 0.95;
  --opacity-full: 1;

  /* Background colors with opacity */
  --bg-white-semi: rgba(255, 255, 255, 0.8);
  --bg-white-bright: rgba(255, 255, 255, 0.9);
  --bg-white-full: rgba(255, 255, 255, 1);

  /* Spacing scale */
  --space-2xs: 2px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-base: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Layout */
  --border-radius: 4px;
  --border-radius-md: 6px;
  --border-radius-lg: 8px;
  --border-radius-xl: 12px;
  --border-radius-pill: 20px;
  --border-radius-circle: 50%;
  --border-width: 1px;
  --border-width-medium: 1.5px;
  --border-width-strong: 2px;
  --border-width-thick: 4px;
  --content-max-width: 1600px;
  --content-max-width-ideas: 1200px;
  --content-max-width-narrow: 600px;
  --workspace-max-width: 1100px;
  --content-padding: var(--space-xl);
  --idea-card-min-width: 300px;

  /* Component Sizes */
  --size-checkbox: 20px;
  --size-icon: 24px;
  --size-icon-sm: 32px;
  --size-icon-lg: 48px;
  --size-lifecycle-circle: 72px;
  --size-content-min: 60px;
  --input-width-sm: 80px;

  /* Box shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-base: 0 2px 8px rgba(0, 0, 0, 0.05);
  --shadow-card: 2px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card-hover: 3px 3px 0 rgba(0, 0, 0, 0.08);
  --shadow-card-elevated: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-glow-green: 0 0 15px rgba(184, 201, 176, 0.6), 0 0 25px rgba(184, 201, 176, 0.3), 0 0 35px rgba(184, 201, 176, 0.1);

  /* Scale transforms */
  --scale-hover: 1.05;
  --scale-hover-subtle: 1.02;

  /* Letter spacing */
  --letter-spacing-accent: 0.5px;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ============================================
   Base Styles
   ============================================ */

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

html {
  min-height: 100vh;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-regular);
  color: var(--ink-dark);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
}

/* Paper texture background - fixed to cover entire viewport */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: none;

  /* Paper texture with dotted pattern */
  background-image:
    radial-gradient(circle, rgba(0,0,0,0.08) 1px, transparent 1px),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='2' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.15'/%3E%3C/svg%3E");
  background-size: 16px 16px, cover;
  background-position: 0 0, center;
  background-color: var(--paper-bg);
  background-repeat: repeat, no-repeat;
  background-attachment: fixed;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  margin-bottom: var(--space-base);
}

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

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

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

h4, h5, h6 {
  font-size: var(--font-size-base);
}

p {
  margin-bottom: var(--space-base);
  line-height: 1.6;
}

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

a {
  color: var(--ink-dark);
  text-decoration: underline;
}

a:hover {
  opacity: 0.8;
}

strong, b {
  font-weight: var(--font-weight-bold);
}

small {
  font-size: var(--font-size-sm);
  color: var(--ink-medium);
}

.text-muted {
  color: var(--ink-medium);
}

.text-xs {
  font-size: var(--font-size-xs);
}

.text-sm {
  font-size: var(--font-size-sm);
}

.text-lg {
  font-size: var(--font-size-lg);
}

/* ============================================
   Notes Section
   ============================================ */

.notes-section {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(250, 245, 237, 0.85) 100%);
  border: var(--border-width-medium) solid var(--parchment-dark);
  border-radius: var(--border-radius-md);
  padding: var(--space-base);
  margin-bottom: var(--space-lg);
}

.notes-title {
  font-family: var(--font-accent);
  font-size: 16px;
  color: var(--ink-medium);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.quill-icon {
  font-size: 18px;
  opacity: 0.7;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-base);
}

.note-item {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--parchment);
  border-radius: var(--border-radius-sm);
  padding: var(--space-sm);
  position: relative;
}

.note-content {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-dark);
  line-height: 1.5;
  padding-right: 24px; /* space for delete button */
}

.note-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-xs);
}

.note-time {
  font-size: 11px;
  color: var(--ink-light);
  opacity: 0.6;
}

.note-delete-btn {
  position: absolute;
  top: var(--space-xs);
  right: var(--space-xs);
  width: 18px;
  height: 18px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--ink-light);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.4;
  transition: opacity var(--transition-fast);
}

.note-delete-btn:hover {
  opacity: 1;
  color: var(--terra-cotta);
}

.note-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  padding: var(--space-sm);
  border: var(--border-width-medium) solid var(--parchment-dark);
  border-radius: var(--border-radius-sm);
  background: rgba(255, 255, 255, 0.9);
  resize: vertical;
  margin-bottom: var(--space-sm);
}

.note-input:focus {
  outline: none;
  border-color: var(--terra-cotta);
  box-shadow: 0 0 0 2px rgba(184, 160, 140, 0.1);
}

/* Week view - day name row with quill icon */
.day-name-row {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
}

.day-name-row .week-quill-icon {
  pointer-events: auto;
}

.day-name-row .day-name {
  margin: 0;
  /* Keep centered as defined in week-view.css */
}

/* Week view quill icon - positioned next to centered day name */
.week-quill-icon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--font-size-base);
  line-height: 1;
  color: var(--ink-medium);
  opacity: 0.7;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  vertical-align: middle;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(0, -50%);
  margin-left: 4.5em;
}

.week-quill-icon:hover {
  opacity: 1;
}

/* Week view - inline notes list */
.week-notes-list {
  background: linear-gradient(135deg, #FFF 0%, #FAF5ED 100%);
  border: var(--border-width-medium) solid var(--parchment-dark);
  border-radius: var(--border-radius-sm);
  padding: var(--space-sm);
  margin: var(--space-md) 0 var(--space-sm) 0;
  font-size: var(--font-size-xs);
}

.week-note-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-2xs);
  margin-bottom: var(--space-xs);
  align-items: flex-start;
}

.week-note-item:last-child {
  margin-bottom: 0;
}

.week-note-time {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  color: var(--ink-medium);
  white-space: nowrap;
  flex-shrink: 0;
}

.week-note-content {
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--ink-dark);
  line-height: 1.4;
}

/* Day header link wrappers */
.day-name-link,
.day-date-link {
  display: block;
  text-decoration: none;
  color: inherit;
  transition: opacity var(--transition-base);
}

.day-name-link:hover,
.day-date-link:hover {
  opacity: 0.8;
}

/* Day view - header with quill icon */
.day-header-with-icon {
  position: relative;
  display: inline-block;
}

.day-view-quill-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--ink-medium);
  opacity: 0.6;
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  vertical-align: middle;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  margin-left: var(--space-xs);
}

.day-view-quill-icon:hover {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
}

/* Note modal */
.note-modal-content {
  max-width: 600px;
  width: 90%;
}
