/* style.css — paper card theme, tape decorations, step flip, ribbon */

:root {
  --paper: #faf3e7;
  --paper-dark: #f3e8d9;
  --accent: #c4622d;
  --cocoa: #3d2c1e;
  --tape: rgba(196, 98, 45, 0.25);
  --stitch: rgba(61, 44, 30, 0.2);
  --shadow: rgba(61, 44, 30, 0.15);
  --font-head: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

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

body {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.2) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(196,98,45,0.05) 0%, transparent 40%),
    repeating-linear-gradient(45deg, rgba(61,44,30,0.02) 0px, rgba(61,44,30,0.02) 2px, transparent 2px, transparent 6px);
  font-family: var(--font-body);
  color: var(--cocoa);
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1rem;
}

/* Intro 'Open the recipe card' pill — cream/terracotta card styling, kept in view */
.cover-btn {
  position: relative;
  display: block;
  margin: 2.5rem auto 1.25rem;
  padding: 0.8rem 1.6rem;
  background: var(--paper);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--shadow);
  transition: background 0.2s, color 0.2s, opacity 0.3s;
  z-index: 5;
}
.cover-btn:hover {
  background: var(--accent);
  color: white;
}
.cover-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Card */
.card {
  position: relative;
  background: var(--paper);
  border-radius: 18px;
  border: 2px dashed var(--stitch);
  /* keep the intro pill visible above the card while it shows */
  box-shadow: 0 8px 30px var(--shadow), 0 2px 8px rgba(61,44,30,0.1);
  max-width: 680px;
  width: 100%;
  padding: 2rem 2rem 1.5rem;
  margin: 0.75rem auto 0;
  overflow: hidden;
}

/* Stitched border effect */
.card::before {
  content: '';
  position: absolute;
  inset: 8px;
  border: 2px solid var(--stitch);
  border-radius: 10px;
  pointer-events: none;
  opacity: 0.4;
}

/* Tape decoration */
.tape {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 120px;
  height: 30px;
  background: var(--tape);
  border-left: 4px dashed rgba(255,255,255,0.3);
  border-right: 4px dashed rgba(255,255,255,0.3);
  box-shadow: 0 2px 6px rgba(61,44,30,0.2);
  z-index: 2;
}

.tape::after {
  content: '';
  position: absolute;
  top: 5px;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.3);
}


/* Ingredient list */
.ing-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ing {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.8rem;
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--stitch);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.ing:hover {
  background: rgba(255,255,255,0.9);
  transform: translateX(2px);
}

.ing input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.ing .ing-text {
  flex: 1;
  font-weight: 500;
}

.ing .ing-amt {
  font-size: 0.85em;
  color: var(--muted, #8a7a6d);
  opacity: 0.85;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .ing .ing-amt { white-space: normal; }
}

.ing.done {
  background: rgba(196,98,45,0.08);
}

.ing.done .ing-text {
  text-decoration: line-through;
  opacity: 0.6;
}

/* Circular checkbox on each ingredient row */
.ing .check {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: white;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  transition: background 0.2s, transform 0.1s;
  cursor: pointer;
}

.ing:hover .check {
  box-shadow: 0 0 0 3px rgba(196, 98, 45, 0.2);
}

.ing:active .check {
  transform: scale(0.9);
}

.ing.done .check {
  background: var(--accent);
  border-color: var(--accent);
}

/* New markup: label.ing > input[type=checkbox] + .ing-text; .checked mirrors .done */
.ing {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.ing:active {
  transform: scale(0.985);
}
.ing input[type="checkbox"] {
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}
.ing input[type="checkbox"]::after {
  content: '✓';
  color: white;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  opacity: 0;
}
.ing input[type="checkbox"]:checked {
  background: var(--accent);
}
.ing input[type="checkbox"]:checked::after {
  opacity: 1;
}
.ing:hover input[type="checkbox"] {
  box-shadow: 0 0 0 3px rgba(196, 98, 45, 0.2);
}
.ing:active input[type="checkbox"] {
  transform: scale(0.9);
}
.ing.checked {
  background: rgba(196,98,45,0.08);
}
.ing.checked .ing-text {
  text-decoration: line-through;
  opacity: 0.6;
}
/* Add ingredient row */
.ing-add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

.add-row input,
.ing-add-row input {
  flex: 1;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  min-height: 46px;
  border: 2px solid var(--stitch);
  border-radius: 10px;
  padding: 0.55rem 0.8rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--cocoa);
  background: white;
}

.method-section {
  margin-top: 2rem;
}

.add-row input:focus,
.ing-add-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 98, 45, 0.2);
}

.add-row button,
.ing-add-row button {
  min-width: 46px;
  min-height: 46px;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: white;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
}

.add-row button:active,
.ing-add-row button:active {
  transform: scale(0.95);
}

.add-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.8rem;
}

@media (max-width: 560px) {
  .add-row button {
    width: 46px;
    flex-shrink: 0;
  }
}

/* Step list */
.step-list {
  list-style: none;
  margin: 1.5rem 0 0;
  padding-left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.step {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: rgba(255,255,255,0.5);
  border: 2px solid var(--stitch);
  border-radius: 12px;
  padding: 1rem 1rem 1rem 0.8rem;
  opacity: 0;
  animation: flipIn 0.5s ease-out forwards;
}

.step.done {
  background: rgba(196,98,45,0.05);
}

.step.done .step-text {
  text-decoration: line-through;
  opacity: 0.6;
}

.step-number {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-family: var(--font-head);
  margin-left: 0;
  box-shadow: 0 4px 8px rgba(196,98,45,0.3);
}

.step-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.step-text {
  font-size: 1rem;
  line-height: 1.5;
}

.step-art {
  margin-top: 0.6rem;
  max-width: 200px;
  height: auto;
  border-radius: 8px;
}

.step-check {
  width: 20px;
  height: 20px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.step-check::after {
  content: '✓';
  color: white;
  font-size: 14px;
  opacity: 0;
}

.step.done .step-check {
  background: var(--accent);
}

.step.done .step-check::after {
  opacity: 1;
}

/* Step flip animation */
@keyframes flipIn {
  0% {
    opacity: 0;
    transform: perspective(600px) rotateX(40deg) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: perspective(600px) rotateX(0deg) scale(1);
  }
}

.step.enter {
  animation: flipIn 0.45s ease-out both;
}

/* Ribbon (all done) */
.ribbon {
  position: relative;
  display: none;
  margin-top: 2rem;
  text-align: center;
  background: var(--accent);
  color: white;
  padding: 1rem;
  border-radius: 10px;
  font-family: var(--font-head);
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(196,98,45,0.4);
  animation: pop 0.4s ease-out;
}

.ribbon.visible {
  display: block;
}

@keyframes pop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Footer buttons */
.footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--stitch);
}

.footer button {
  background: none;
  border: 2px solid var(--accent);
  color: var(--accent);
  padding: 0.5rem 1.2rem;
  border-radius: 30px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.footer button:hover {
  background: var(--accent);
  color: white;
}

.footer .sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: none;
  background: transparent;
  color: var(--cocoa);
}

.footer .sound-toggle .icon {
  font-size: 1.2rem;
}

/* Responsive single column under 560px */
@media (max-width: 560px) {
  .card {
    padding: 1.2rem;
    margin: 1rem auto;
  }

  .ing-add-row {
    flex-direction: column;
  }

  .ing-add-row button {
    width: 100%;
  }

  .step-number {
    margin-left: 0;
  }

  .step-list {
    padding-left: 1.5rem;
  }

  .footer {
    flex-direction: column;
    gap: 0.8rem;
  }
}

/* Keep everything inside the viewport, even in the pre-open state */
.card.hidden {
  display: none;
}

.card {
  max-width: 100%;
  box-sizing: border-box;
}

.step {
  min-width: 0;
  overflow: hidden;
}

.step-content {
  min-width: 0;
}

.step-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.step-art {
  max-width: 100%;
}

.cover-btn {
  max-width: calc(100% - 2rem);
  box-sizing: border-box;
}
