/* =====================================================================
   Shopping List - Styles
   CobbleWorks の Cream 背景に、買い物らしいグリーンのアクセントを合わせた配色。
   ===================================================================== */

:root {
  --bg:            #FAF4EC;
  --card:          #FFFFFF;
  --border:        #EDE2D4;
  --divider:       #F4EBDF;

  --ink:           #3D3229;
  --text-2:        #6B5F51;
  --muted:         #8C7F70;
  --faint:         #B5A794;

  --accent:        #2E9E54;
  --accent-hover:  #24803F;
  --accent-tint:   #E3F4E9;
  --accent-line:   #BEE6CB;

  --warm:          #E8A23D;

  --error:         #C0392B;
  --error-tint:    #FBEAE6;

  --shadow-card:   0 6px 20px rgba(60, 40, 20, 0.06);
  --focus-ring:    0 0 0 3px rgba(46, 158, 84, 0.18);

  --radius:        20px;
  --radius-sm:     10px;
}

* {
  box-sizing: border-box;
}

/* hidden 属性は display 指定より優先させる（.list-actions の flex に負けないように） */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  padding: 28px 16px 40px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Yu Gothic", Meiryo, sans-serif;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

header,
main {
  max-width: 620px;
  margin: 0 auto;
}

/* ---------- Header / title ---------- */

header {
  margin-bottom: 24px;
}

.app-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.app-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: 14px;
  background: var(--accent-tint);
  color: var(--accent);
}

.app-title-text {
  display: inline-block;
}

/* レシートを切り取ったようなギザギザの下線 */
.app-title-text::after {
  content: "";
  display: block;
  height: 6px;
  margin-top: 4px;
  background-image:
    linear-gradient(135deg, var(--accent-line) 25%, transparent 25%),
    linear-gradient(225deg, var(--accent-line) 25%, transparent 25%);
  background-position: 0 0;
  background-size: 12px 12px;
  background-repeat: repeat-x;
}

.app-title-accent {
  color: var(--accent);
}

.subtitle {
  margin: 0;
  color: var(--text-2);
  font-size: 15px;
}

/* ---------- Cards & sections ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

/* ---------- Progress ---------- */

.progress-card {
  background: linear-gradient(180deg, #F2FAF4 0%, var(--card) 70%);
}

.progress-text {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  background: var(--divider);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--accent);
  transition: width 220ms ease;
}

.progress-note {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- Form ---------- */

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
}

.form-group small {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
select {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

input[aria-invalid="true"] {
  border-color: var(--error);
  background: var(--error-tint);
}

.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--error);
}

/* ---------- Buttons ---------- */

button {
  font-family: inherit;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  padding: 13px 20px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  transition: background 180ms ease;
}

.primary-btn:hover {
  background: var(--accent-hover);
}

.ghost-btn {
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-hover);
  background: var(--card);
  border: 1px solid var(--accent-line);
  border-radius: 999px;
}

.ghost-btn:hover {
  background: var(--accent-tint);
}

.ghost-btn.danger {
  color: var(--error);
  border-color: #E6CAC4;
}

.ghost-btn.danger:hover {
  background: var(--error-tint);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- List ---------- */

.list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.list-head h2 {
  margin: 0;
}

.list-actions {
  display: flex;
  gap: 8px;
}

.category-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.category-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.category-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--faint);
  text-transform: none;
  letter-spacing: 0;
}

.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.item-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--divider);
}

.item-row:first-child {
  border-top: none;
}

.item-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  font-size: 16px;
  cursor: pointer;
  font-weight: 400;
  margin: 0;
}

.item-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
}

.item-name {
  word-break: break-word;
}

.item-row.is-bought .item-name {
  color: var(--faint);
  text-decoration: line-through;
}

.delete-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  background: transparent;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
}

.delete-btn:hover {
  color: var(--error);
  background: var(--error-tint);
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
}

.empty-art {
  width: 190px;
  max-width: 100%;
  height: auto;
  margin-bottom: 8px;
}

.empty-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
}

.empty-text {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

.storage-note {
  margin: 4px 0 24px;
  font-size: 12px;
  color: var(--faint);
  text-align: center;
}

/* ---------- How to use ---------- */

.how-to-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.how-to-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--divider);
  font-size: 15px;
  color: var(--text-2);
}

.how-to-list li:first-child {
  border-top: none;
}

.how-to-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--accent-tint);
  color: var(--accent-hover);
}

.how-to-icon svg {
  width: 18px;
  height: 18px;
}

/* ---------- Utilities ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Wider screens ---------- */

@media (min-width: 600px) {
  body {
    padding: 40px 20px 56px;
  }

  .app-title {
    font-size: 34px;
  }

  .card,
  .category-group {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
