/* ============================
   Scratch Project Card — Styles
   ============================ */

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

:root {
  --scratch-blue: #4D97FF;
  --scratch-blue-dark: #3373CC;
  --scratch-green: #59C059;
  --scratch-orange: #FF8C1A;
  --scratch-purple: #9966FF;
  --scratch-red: #FF6680;
  --scratch-yellow: #FFCE3B;
  --card-bg: #FFFFFF;
  --card-radius: 20px;
  --text: #333;
  --text-light: #666;
  --input-bg: #F0F4FF;
  --input-border: #D0DBF5;
  --section-bg: #F8FAFF;
}

body {
  font-family: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  background: linear-gradient(135deg, #E8F0FE 0%, #F0E6FF 50%, #E6F7EE 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 48px;
  color: var(--text);
}

/* ---- Toolbar ---- */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.btn:active { transform: scale(0.96); }

.btn--save {
  background: var(--scratch-green);
  color: #fff;
}
.btn--save:hover { background: #4aad4a; box-shadow: 0 6px 20px rgba(89,192,89,0.35); }

.btn--print {
  background: var(--scratch-blue);
  color: #fff;
}
.btn--print:hover { background: var(--scratch-blue-dark); box-shadow: 0 6px 20px rgba(77,151,255,0.35); }

.btn--clear {
  background: #fff;
  color: var(--scratch-red);
  border: 2px solid var(--scratch-red);
  box-shadow: none;
}
.btn--clear:hover { background: #FFF0F3; }

/* ---- Card ---- */
.card {
  width: 100%;
  max-width: 640px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 8px 40px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}

/* Header */
.card__header {
  background: linear-gradient(135deg, var(--scratch-blue) 0%, var(--scratch-purple) 100%);
  padding: 32px 32px 28px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.card__header::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}
.card__header::after {
  content: '';
  position: absolute;
  bottom: -30px; left: -20px;
  width: 100px; height: 100px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.card__header-cat {
  margin-bottom: 8px;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,0.2));
  animation: catBounce 2s ease-in-out infinite;
}
@keyframes catBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.card__title {
  font-size: 32px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: relative;
  z-index: 1;
}

.card__badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 16px;
  background: rgba(255,255,255,0.22);
  color: #fff;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
  backdrop-filter: blur(4px);
}

/* Sections */
.card__section {
  padding: 24px 32px;
}
.card__section:nth-child(even) {
  background: var(--section-bg);
}

.card__section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 800;
  color: var(--scratch-blue-dark);
  margin-bottom: 16px;
}
.card__section-title svg { flex-shrink: 0; }

/* Divider */
.card__divider {
  height: 3px;
  margin: 0 32px;
  background: linear-gradient(90deg, var(--scratch-blue) 0%, var(--scratch-purple) 50%, var(--scratch-green) 100%);
  border-radius: 2px;
}

/* Fields */
.card__field {
  margin-bottom: 18px;
}
.card__field:last-child { margin-bottom: 0; }

.card__label {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.card__label--rule {
  min-width: 130px;
  margin-bottom: 0;
}

.card__input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s ease;
  outline: none;
}
.card__input::placeholder {
  color: #B0BEC5;
  font-weight: 600;
}
.card__input:focus {
  border-color: var(--scratch-blue);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(77,151,255,0.15);
}

.card__input--rule {
  background: transparent;
  border: none;
  border-bottom: 2px dashed var(--input-border);
  border-radius: 0;
  padding: 4px 0;
  font-size: 15px;
}
.card__input--rule:focus {
  border-bottom-color: var(--scratch-blue);
  box-shadow: none;
  background: transparent;
}

/* Inline field (rules) */
.card__field--inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.card__field--inline .card__input--rule {
  flex: 1;
  min-width: 180px;
}

/* Radio buttons */
.card__field--radio {
  margin-top: 4px;
}
.card__radios {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.card__radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  transition: all 0.2s ease;
  user-select: none;
}
.card__radio input { display: none; }
.card__radio:hover {
  border-color: var(--scratch-blue);
  background: #EDF3FF;
}
.card__radio:has(input:checked) {
  border-color: var(--scratch-blue);
  background: #D6E8FF;
  color: var(--scratch-blue-dark);
}
.card__radio-mark {
  width: 18px; height: 18px;
  border: 2px solid #B0BEC5;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.card__radio:has(input:checked) .card__radio-mark {
  border-color: var(--scratch-blue);
}
.card__radio:has(input:checked) .card__radio-mark::after {
  content: '';
  width: 10px; height: 10px;
  background: var(--scratch-blue);
  border-radius: 50%;
}

/* Checkboxes */
.card__checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 10px;
}
.card__check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--input-border);
  border-radius: 12px;
  background: var(--input-bg);
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  transition: all 0.2s ease;
  user-select: none;
}
.card__check input { display: none; }
.card__check:hover {
  border-color: var(--scratch-blue);
  background: #EDF3FF;
}
.card__check:has(input:checked) {
  border-color: var(--scratch-green);
  background: #E8F8E8;
  color: #2E7D32;
}
.card__check-box {
  width: 22px; height: 22px;
  border: 2px solid #B0BEC5;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  background: #fff;
}
.card__check:has(input:checked) .card__check-box {
  background: var(--scratch-green);
  border-color: var(--scratch-green);
}
.card__check:has(input:checked) .card__check-box::after {
  content: '';
  display: block;
  width: 6px; height: 10px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Footer */
.card__footer {
  padding: 20px 32px 28px;
  border-top: 2px dashed var(--input-border);
}
.card__footer-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 10px;
}
.card__footer-line:last-child { margin-bottom: 0; }

.card__footer-blank {
  flex: 1;
  min-height: 1.4em;
  border-bottom: 2px dashed var(--input-border);
  padding: 2px 4px;
  outline: none;
  color: var(--text);
  font-weight: 700;
  transition: border-color 0.2s;
}
.card__footer-blank:focus {
  border-bottom-color: var(--scratch-blue);
}
.card__footer-blank:empty::before {
  content: attr(data-placeholder);
  color: #B0BEC5;
}

/* Toast notification */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 14px 28px;
  background: #333;
  color: #fff;
  border-radius: 14px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 1000;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 500px) {
  body { padding: 16px 10px 40px; }
  .card__header { padding: 24px 20px 20px; }
  .card__title { font-size: 26px; }
  .card__section { padding: 20px; }
  .card__divider { margin: 0 20px; }
  .card__footer { padding: 16px 20px 24px; }
  .card__checks { grid-template-columns: 1fr 1fr; }
  .card__field--inline { flex-direction: column; align-items: stretch; }
  .card__label--rule { min-width: auto; }
  .btn { padding: 10px 18px; font-size: 14px; }
}

/* ---- Print ---- */
@media print {
  .no-print { display: none !important; }
  body {
    background: #fff;
    padding: 0;
  }
  .card {
    box-shadow: none;
    border-radius: 0;
    max-width: 100%;
    border: 2px solid #ddd;
  }
  .toast { display: none !important; }
}