/* ============================================
   SENIOR FAMILY COOKBOOK — PWA Styles
   Earthy + Clean Modern
   ============================================ */

:root {
  --green:       #3D5A3E;
  --green-dark:  #2A3E2B;
  --green-light: #5A7A5C;
  --brown:       #8B6914;
  --brown-light: #C4A35A;
  --cream:       #F5F0E8;
  --cream-dark:  #EDE8DC;
  --text-dark:   #2C2C2C;
  --text-mid:    #5A4A35;
  --text-light:  #8B7B65;
  --white:       #FFFFFF;
  --shadow-sm:   0 1px 4px rgba(44,44,44,0.10);
  --shadow-md:   0 4px 16px rgba(44,44,44,0.12);
  --shadow-lg:   0 8px 32px rgba(44,44,44,0.16);
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Source Sans 3', 'Helvetica Neue', sans-serif;
  --header-h:    64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--cream);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--cream);
  transform: translateX(100%);
  transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.screen.active {
  transform: translateX(0);
}

.screen.slide-out {
  transform: translateX(-30%);
}

/* ============ HEADER ============ */
.app-header {
  background: var(--green);
  color: var(--white);
  height: var(--header-h);
  flex-shrink: 0;
  padding: 0 16px;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  z-index: 10;
}

.header-content {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.header-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.header-title h1 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--white);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.last-updated {
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  font-weight: 300;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-back-label {
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,0.85);
}

.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: var(--white);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:active { background: rgba(255,255,255,0.28); }

/* ============ HOME MAIN ============ */
.home-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px;
  padding-bottom: calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ============ STATUS BAR ============ */
.status-bar {
  background: var(--cream-dark);
  border-left: 4px solid var(--brown);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-mid);
}

.status-bar.hidden { display: none; }

/* ============ RESTORE BANNER ============ */
.restore-banner {
  background: #FFF8E7;
  border: 1.5px solid var(--brown-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  color: var(--brown);
}

.restore-banner.hidden { display: none; }

.restore-banner button {
  background: var(--brown);
  color: var(--white);
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

/* ============ SEARCH BOX ============ */
.search-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.search-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 14px;
  color: var(--text-light);
  pointer-events: none;
  flex-shrink: 0;
}

#search-input {
  width: 100%;
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-md);
  padding: 12px 40px 12px 40px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(61,90,62,0.15);
}

#search-input::placeholder {
  color: var(--text-light);
}

.clear-btn {
  position: absolute;
  right: 12px;
  background: var(--cream-dark);
  border: none;
  color: var(--text-mid);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 1px;
  -webkit-tap-highlight-color: transparent;
}

.clear-btn.hidden { display: none; }

/* ============ FILTER SECTION ============ */
.filter-section,
.recipe-select-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--green);
}

.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--white);
  border: 1.5px solid var(--cream-dark);
  border-radius: var(--radius-md);
  padding: 12px 40px 12px 14px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--text-dark);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-wrapper select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(61,90,62,0.15);
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  pointer-events: none;
}

/* ============ BUTTONS ============ */
.btn-primary {
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
}

.btn-primary:active:not(:disabled) {
  background: var(--green-dark);
  transform: scale(0.98);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  background: #B5C4B5;
  box-shadow: none;
  cursor: not-allowed;
}

/* ============ LOADING ============ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245,240,232,0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
  font-size: 15px;
  color: var(--text-mid);
}

.loading-overlay.hidden { display: none; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--cream-dark);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ RECIPE MAIN ============ */
.recipe-main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 calc(32px + var(--safe-bottom));
}

/* ============ RECIPE HERO ============ */
.recipe-hero {
  background: var(--green);
  padding: 20px 16px 24px;
  color: var(--white);
}

.recipe-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--white);
  margin-bottom: 12px;
}

.recipe-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.tag-pill {
  background: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
}

.servings-card {
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.servings-base {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  flex-shrink: 0;
}

.servings-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.servings-label {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  white-space: nowrap;
}

.servings-input {
  width: 64px;
  background: rgba(255,255,255,0.2);
  border: 1.5px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--white);
  text-align: center;
}

.servings-input:focus {
  outline: none;
  border-color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.25);
}

.servings-input::placeholder { color: rgba(255,255,255,0.5); }

.btn-scale {
  background: var(--brown-light);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s;
}

.btn-scale:active { background: var(--brown); }

.scale-factor {
  font-size: 13px;
  color: var(--brown-light);
  font-weight: 600;
  white-space: nowrap;
}

/* ============ RECIPE SECTIONS ============ */
.recipe-body {
  padding: 0 16px;
}

.section {
  margin-top: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 8px;
  border-bottom: 2px solid var(--green);
  margin-bottom: 4px;
}

.section-header h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-header svg {
  color: var(--green);
  flex-shrink: 0;
}

/* ============ INGREDIENT / STEP ITEMS ============ */
.item-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.item:active { background: var(--cream-dark); }

.item.checked {
  background: rgba(61,90,62,0.06);
}

.item-check {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--cream-dark);
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  background: var(--white);
}

.item.checked .item-check {
  background: var(--green);
  border-color: var(--green);
}

.item.checked .item-check::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid var(--white);
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}

.item-text {
  flex: 1;
  font-size: 15px;
  color: var(--text-dark);
  line-height: 1.45;
  transition: color 0.2s, opacity 0.2s;
}

.item.checked .item-text {
  color: var(--text-light);
  text-decoration: line-through;
  opacity: 0.7;
}

/* Step numbers */
.step-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background 0.2s;
}

.item.checked .step-number {
  background: var(--text-light);
}

/* ============ STORY / NUTRITION ============ */
.prose-section {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 4px;
  box-shadow: var(--shadow-sm);
}

.prose-section p {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.65;
}

.nutrition-text {
  font-size: 14px;
  color: var(--text-mid);
  line-height: 1.7;
  font-family: var(--font-body);
}

/* ============ STORY HEADER ============ */
.section-header.story-header { border-bottom-color: var(--brown); }
.section-header.story-header h2 { color: var(--brown); }
.section-header.story-header svg { color: var(--brown); }

.section-header.nutrition-header { border-bottom-color: var(--brown-light); }
.section-header.nutrition-header h2 { color: var(--brown); }
.section-header.nutrition-header svg { color: var(--brown-light); }

/* ============ SPACER ============ */
.bottom-spacer { height: 32px; }

/* ============ INSTALL PROMPT ============ */
.install-prompt {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  background: var(--green-dark);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.3s ease;
}

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

.install-prompt p {
  flex: 1;
  font-size: 14px;
  line-height: 1.3;
}

.install-prompt strong { color: var(--brown-light); }

.install-btn {
  background: var(--brown-light);
  color: var(--white);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
}

.install-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cream-dark); border-radius: 2px; }

/* ============ INGREDIENT QTY HIGHLIGHT ============ */
.qty { 
  font-weight: 600; 
  color: var(--green-dark); 
}

.unit { color: var(--text-mid); }

.ing-name { color: var(--text-dark); }

.ing-note {
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
}

/* ============ UPDATE BANNER ============ */
.update-banner {
  position: fixed;
  bottom: calc(16px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  background: var(--green-dark);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: slideUp 0.3s ease;
}

.update-banner.hidden { display: none; }

.update-banner span {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
}

#btn-update {
  background: var(--brown-light);
  color: var(--white);
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}

.dismiss-update {
  background: none;
  border: none;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
