/* ---------- Aquila Nest design system ----------
   Warm paper background, ink text, hand-drawn shapes,
   flat "hard" offset shadows (no blur/glow), one consistent
   button/card/icon language reused everywhere. */

:root {
  --paper: #fbf1de;
  --paper-alt: #f4e6c8;
  --ink: #2b2117;
  --ink-soft: #5b4c3c;
  --terracotta: #c1502e;
  --terracotta-dark: #973c22;
  --mustard: #e8a33d;
  --mustard-dark: #b97c22;
  --teal: #2f6f6e;
  --teal-dark: #1f4d4c;
  --plum: #7a4a6b;
  --plum-dark: #5a3450;
  --olive: #6d7a3a;
  --olive-dark: #4d5628;
  --sky: #3f7ea6;
  --sky-dark: #2c5c7d;
  --border-width: 3px;
  --radius-blob: 26px 14px 26px 14px/14px 26px 14px 26px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--paper);
  background-image:
    radial-gradient(var(--paper-alt) 1.5px, transparent 1.5px);
  background-size: 26px 26px;
  color: var(--ink);
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
  line-height: 1.45;
}

h1, h2, h3, .brand-text, button, .tab-btn {
  font-family: "Shantell Sans", cursive;
}

/* ---------- Icon utility (shared everywhere) ---------- */
.icon {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  flex: none;
  stroke: currentColor;
  fill: none;
}
.btn .icon, .tab-btn .icon { margin-right: 2px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--terracotta);
  color: var(--paper);
  position: relative;
  padding: 20px 0 26px;
}
.header-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  flex: none;
  background: var(--mustard);
  color: var(--ink);
  border: var(--border-width) solid var(--ink);
  border-radius: 60% 40% 55% 45%/45% 55% 40% 60%;
  transform: rotate(-6deg);
  box-shadow: 3px 3px 0 var(--terracotta-dark);
}
.brand-icon .icon { width: 28px; height: 28px; margin: 0; }
.brand-text { min-width: 0; }
.brand-text h1 {
  margin: 0;
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  letter-spacing: 0.5px;
}
.tagline {
  margin: 2px 0 0;
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.9;
}
.header-edge {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 20px;
  fill: var(--paper);
}

/* ---------- Tabs ---------- */
.tabs {
  max-width: 980px;
  margin: 18px auto 0;
  padding: 0 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.tab-btn {
  display: inline-flex;
  align-items: center;
  font-size: 1.15rem;
  background: var(--paper);
  color: var(--ink);
  border: var(--border-width) solid var(--ink);
  border-radius: 999px;
  padding: 8px 20px;
  cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s ease;
}
.tab-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.tab-btn.is-active {
  background: var(--mustard);
}
.tab-count {
  display: inline-block;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-family: "Quicksand", sans-serif;
  font-size: 0.75rem;
  padding: 1px 8px;
  margin-left: 4px;
}

/* ---------- Main / Panels ---------- */
.app-main {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}
.panel[hidden] { display: none; }

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 20px;
}
.search-wrap {
  position: relative;
  flex: 1 1 320px;
  max-width: 460px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  width: 1.05em;
  height: 1.05em;
}
.search-wrap input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: var(--border-width) solid var(--ink);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
}
.search-wrap input:focus { outline: 3px solid var(--mustard); outline-offset: 1px; }
.hint-text { margin: 0; color: var(--ink-soft); font-size: 0.9rem; }

/* ---------- Card grid ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 22px;
}

.issue-card {
  background: #fff;
  border: var(--border-width) solid var(--ink);
  border-radius: var(--radius-blob);
  box-shadow: 5px 5px 0 var(--ink);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.issue-card:nth-child(3n+1) { transform: rotate(-1.1deg); }
.issue-card:nth-child(3n+2) { transform: rotate(0.8deg); }
.issue-card:nth-child(3n)   { transform: rotate(-0.4deg); }

.issue-cover {
  aspect-ratio: 3/4;
  border-radius: 16px 8px 16px 8px;
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}
.issue-cover img { width: 100%; height: 100%; object-fit: cover; }
.issue-cover .cover-icon { width: 2.6rem; height: 2.6rem; margin: 0; stroke-width: 1.6; }
.issue-cover .cover-title {
  position: absolute;
  inset: auto 0 0 0;
  background: rgba(43,33,23,0.78);
  color: var(--paper);
  font-size: 0.78rem;
  padding: 5px 8px;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  text-align: center;
}

.cover-terracotta { background: var(--terracotta); color: var(--paper); }
.cover-mustard { background: var(--mustard); color: var(--ink); }
.cover-teal { background: var(--teal); color: var(--paper); }
.cover-plum { background: var(--plum); color: var(--paper); }
.cover-olive { background: var(--olive); color: var(--paper); }
.cover-sky { background: var(--sky); color: var(--paper); }

.issue-title {
  font-size: 1.15rem;
  margin: 0;
  line-height: 1.1;
}
.issue-date, .issue-note {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
}
.issue-actions { margin-top: auto; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Buttons (single consistent language) ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: "Shantell Sans", cursive;
  font-size: 1.05rem;
  border: var(--border-width) solid var(--ink);
  border-radius: 999px;
  padding: 7px 16px;
  cursor: pointer;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.08s ease;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn:disabled:active { transform: none; box-shadow: 3px 3px 0 var(--ink); }

.btn-terracotta { background: var(--terracotta); color: var(--paper); }
.btn-mustard { background: var(--mustard); color: var(--ink); }
.btn-teal { background: var(--teal); color: var(--paper); }
.btn-sunny { background: var(--mustard); color: var(--ink); }
.btn-sky { background: var(--sky); color: var(--paper); }
.btn-outline { background: #fff; }
.btn-small { font-size: 0.9rem; padding: 5px 12px; box-shadow: 2px 2px 0 var(--ink); }
.btn-small:active { box-shadow: 1px 1px 0 var(--ink); }
.btn-big { width: 100%; font-size: 1.25rem; padding: 12px; margin-top: 14px; }
.btn-added { background: var(--olive); color: var(--paper); }

/* ---------- Empty states ---------- */
.empty-msg {
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 20px;
  font-size: 1.1rem;
}
.empty-msg .empty-big {
  width: 3.5rem;
  height: 3.5rem;
  margin: 0 auto 10px;
  display: block;
  color: var(--terracotta);
  stroke-width: 1.5;
}

/* ---------- Add form ---------- */
.add-form-card {
  background: #fff;
  border: var(--border-width) solid var(--ink);
  border-radius: var(--radius-blob);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 26px;
  max-width: 460px;
  margin: 0 auto;
}
.add-form-card h2 { margin: 0 0 4px; font-size: 1.7rem; }
.form-sub { margin: 0 0 18px; color: var(--ink-soft); font-size: 0.9rem; }
.field-label {
  display: block;
  font-family: "Shantell Sans", cursive;
  font-size: 1.1rem;
  margin: 14px 0 4px;
}
.field-input {
  width: 100%;
  padding: 9px 12px;
  font-family: "Quicksand", sans-serif;
  font-weight: 600;
  font-size: 1rem;
  border: var(--border-width) solid var(--ink);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
}
.field-input:focus { outline: 3px solid var(--mustard); outline-offset: 1px; }

.photo-picker { margin-top: 6px; }
.photo-preview {
  width: 140px;
  height: 186px;
  object-fit: cover;
  border: var(--border-width) solid var(--ink);
  border-radius: 16px 8px 16px 8px;
  margin: 0 auto 12px;
  display: block;
}
.photo-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(43,33,23,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  background: #fff;
  border: var(--border-width) solid var(--ink);
  border-radius: var(--radius-blob);
  box-shadow: 6px 6px 0 var(--ink);
  padding: 24px;
  max-width: 380px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  text-align: center;
}
.modal-card h3 { margin: 0 0 14px; font-size: 1.5rem; }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
}
.modal-close .icon { margin: 0; width: 1.3em; height: 1.3em; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 22px;
  border-radius: 999px;
  font-family: "Shantell Sans", cursive;
  font-size: 1.1rem;
  box-shadow: 3px 3px 0 var(--terracotta-dark);
  z-index: 60;
  max-width: calc(100vw - 40px);
  text-align: center;
}
.toast[hidden] { display: none; }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center;
  padding: 20px;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .site-header { padding: 16px 0 22px; }
  .brand-icon { width: 44px; height: 44px; }
  .brand-icon .icon { width: 24px; height: 24px; }
  .tagline { font-size: 0.85rem; }
  .tabs { gap: 8px; }
  .tab-btn { font-size: 1rem; padding: 7px 14px; }
  .app-main { padding: 20px 14px 50px; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 14px; }
  .issue-card { padding: 9px; }
  .issue-title { font-size: 1rem; }
  .add-form-card { padding: 20px 16px; }
  .search-wrap input, .field-input { font-size: 16px; } /* prevents iOS auto-zoom on focus */
}

@media (max-width: 380px) {
  .tab-btn span, .tab-count { font-size: 0.85rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
}
