/* ===========================================================
   MyPet — visual identity: "the pet passport"
   Every pet gets a page that looks like a vet record / ID card.
   Vaccine status reads as ink stamps. Dates and IDs run in mono.
   =========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --ink: #1F3630;
  --ink-soft: #3C5750;
  --paper: #F6F1E4;
  --paper-card: #FFFDF7;
  --gold: #E3A93F;
  --gold-deep: #B8801F;
  --clay: #C1573F;
  --sage: #4F7D63;
  --line: rgba(31, 54, 48, 0.14);
  --shadow: 0 8px 24px rgba(31, 54, 48, 0.10);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 1px 1px, rgba(31,54,48,0.06) 1px, transparent 0);
  background-size: 22px 22px;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

a { color: inherit; }

/* ---------- Layout shells ---------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 40px 36px;
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: repeating-linear-gradient(90deg, var(--gold) 0 10px, transparent 10px 20px);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-mark .paw { font-size: 28px; }
.brand-mark span {
  font-family: 'Fraunces', serif;
  font-size: 22px;
  font-weight: 700;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 600;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 14.5px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold-deep);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 18px;
  border: none;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}

.btn:hover { background: var(--ink-soft); }
.btn:active { transform: scale(0.98); }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border: 1.5px solid var(--line);
}
.btn-secondary:hover { background: rgba(31,54,48,0.05); }

.btn-small {
  width: auto;
  padding: 8px 14px;
  font-size: 13px;
}

.switch-link {
  text-align: center;
  margin-top: 18px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.switch-link button {
  background: none;
  border: none;
  color: var(--gold-deep);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: 13.5px;
  padding: 0;
}

.error-banner {
  background: #FBEAE5;
  border: 1px solid var(--clay);
  color: var(--clay);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------- App shell ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--paper-card);
}

.topbar .brand-mark { margin-bottom: 0; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-chip .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-family: 'Fraunces', serif;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-head h2 { font-size: 24px; }
.eyebrow {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-deep);
  font-weight: 700;
  margin-bottom: 4px;
  display: block;
}

/* ---------- Pet passport cards ---------- */

.pet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.pet-card {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.pet-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(31,54,48,0.16);
}

.pet-card-top {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.pet-emoji {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px dashed var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}

.pet-card h3 { font-size: 19px; }
.pet-card .breed { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }

.status-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.stamp {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1.5px solid;
  transform: rotate(-1.5deg);
  white-space: nowrap;
}

.stamp.ok { color: var(--sage); border-color: var(--sage); background: rgba(79,125,99,0.08); }
.stamp.soon { color: var(--gold-deep); border-color: var(--gold-deep); background: rgba(184,128,31,0.08); }
.stamp.overdue { color: var(--clay); border-color: var(--clay); background: rgba(193,87,63,0.08); transform: rotate(1.5deg); }
.stamp.neutral { color: var(--ink-soft); border-color: var(--line); background: transparent; }

.add-pet-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px;
  min-height: 140px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.add-pet-card:hover { border-color: var(--gold-deep); color: var(--gold-deep); }
.add-pet-card .plus { font-size: 30px; font-family: 'Fraunces', serif; line-height: 1; margin-bottom: 6px; }

/* ---------- Pet detail page ---------- */

.detail-header {
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 28px;
  position: relative;
}

.detail-header::after {
  content: '';
  position: absolute;
  inset: 8px;
  border: 1.5px dashed var(--line);
  border-radius: 8px;
  pointer-events: none;
}

.detail-emoji {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px dashed var(--line);
  display: flex; align-items: center; justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
}

.detail-meta { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 8px; font-size: 13.5px; color: var(--ink-soft); }
.detail-meta .mono { color: var(--ink); }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1.5px solid var(--line);
  margin-bottom: 22px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -1.5px;
  flex-shrink: 0;
  white-space: nowrap;
}

.tab.active { color: var(--ink); border-color: var(--gold-deep); }

.record-list { display: flex; flex-direction: column; gap: 12px; }

.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 18px;
}

.record-row .record-main strong { font-size: 15px; }
.record-row .record-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.record-row .record-dates { text-align: right; font-size: 12.5px; }
.record-row .record-dates .mono { display: block; font-size: 13px; }

.icon-btn {
  background: none;
  border: none;
  color: var(--clay);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.7;
}
.icon-btn:hover { opacity: 1; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-soft);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ---------- Nearby finder ---------- */

.nearby-list { display: flex; flex-direction: column; gap: 12px; }

.nearby-row {
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.nearby-type {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1.5px solid var(--sage);
  color: var(--sage);
  white-space: nowrap;
}
.nearby-type.pet_store { border-color: var(--gold-deep); color: var(--gold-deep); }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(31,54,48,0.35);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
  max-width: 480px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 30px;
}

.modal h3 { font-size: 20px; margin-bottom: 20px; }

.modal-actions { display: flex; gap: 10px; margin-top: 8px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.hint { font-size: 12px; color: var(--ink-soft); margin-top: -10px; margin-bottom: 16px; }

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }

  .container { padding: 20px 14px 50px; }

  /* Topbar: wrap into two rows instead of squeezing everything onto one */
  .topbar {
    padding: 12px 14px;
    flex-wrap: wrap;
    row-gap: 10px;
  }
  .topbar > div[style*="display:flex"] {
    gap: 12px !important;
    flex-wrap: wrap;
  }
  .user-chip span#user-name { display: none; } /* avatar + logout is enough on a phone */
  .user-chip { gap: 8px; }

  /* Auth card: less padding, still centered */
  .auth-card { padding: 28px 20px; }

  /* Pet detail header: stack instead of cramming a row */
  .detail-header {
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 20px;
  }
  .detail-header > div[style*="margin-left:auto"] {
    margin-left: 0 !important;
    width: 100%;
  }
  .detail-header > div[style*="margin-left:auto"] button { width: 100%; }
  .detail-meta { gap: 12px 16px; }

  /* Record rows (vaccines/medications/appointments): stack instead of 3-across */
  .record-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .record-row .record-dates { text-align: left; }
  .record-row .record-dates .mono { display: inline; }

  /* Modals: less padding, fits small screens without feeling cramped */
  .modal { padding: 22px 18px; max-height: 92vh; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }

  /* Nearby page map: a bit shorter so the list is reachable without excess scrolling */
  #map { height: 260px; }

  /* Notification dropdown: never wider than the viewport allows */
  #notif-dropdown { width: min(300px, 88vw) !important; }

  /* iOS Safari auto-zooms on any input under 16px font-size when focused — this stops that */
  .field input, .field select, .field textarea { font-size: 16px; }

  /* Section headers with a button (nearby page, tab panels): wrap instead of squeezing */
  .section-head { flex-wrap: wrap; gap: 12px; align-items: flex-start; }
  .section-head h2 { font-size: 20px; }
  .section-head > div:last-child,
  .section-head > button { width: 100% !important; }
  .section-head > div[style*="display:flex"] { width: 100%; flex-wrap: wrap; }
  .section-head > div[style*="display:flex"] > a,
  .section-head > div[style*="display:flex"] > button { flex: 1; text-align: center; }
}

@media (max-width: 400px) {
  .pet-grid { grid-template-columns: 1fr; }
  .stamp { font-size: 10px; padding: 4px 8px; }
}

@media (max-width: 640px) {
  .field[style*="max-width:280px"] { max-width: 100% !important; }
}
