/* ===== WINE JOURNAL — LUXURY EDITORIAL / REFINED DARK CELLAR ===== */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,700;1,400;1,700&family=Lato:wght@400;700&display=swap');

/* ===== DESIGN TOKENS ===== */
:root {
  --wine:       #2d0a14;
  --wine-mid:   #5c1a2e;
  --wine-light: #8b2d4a;
  --gold:       #c9a84c;
  --gold-light: #e6c97a;
  --cream:      #faf6ee;
  --card:       #ffffff;
  --text:       #1a0a0f;
  --text-muted: #7a5c65;
  --danger:     #c0392b;
  --border:     #e8ddd4;
  --shadow:     rgba(45,10,20,.10);
  --radius-card: 16px;
  --radius-input: 10px;
  --radius-btn:   12px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100%;
  font-family: 'Lato', -apple-system, Arial, sans-serif;
  font-size: 16px;
  background: var(--cream);
  color: var(--text);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* ===== HEADER ===== */
header {
  background: var(--wine);
  color: var(--cream);
  padding: 14px 20px;
  padding-top: calc(14px + env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 12px rgba(45,10,20,.30);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .3px;
  color: var(--cream);
}

#me {
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: rgba(250,246,238,.65);
  letter-spacing: .3px;
}

/* ===== NAVIGATION ===== */
nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  bottom: env(safe-area-inset-bottom, 0);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 200;
  box-shadow: 0 -2px 16px rgba(45,10,20,.08);
}

nav button {
  flex: 1;
  padding: 10px 4px 12px;
  background: none;
  border: none;
  border-top: 3px solid transparent;
  font-family: 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--text-muted);
  text-transform: uppercase;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  line-height: 1.2;
}

nav button.active {
  color: var(--gold);
  border-top-color: var(--gold);
}

nav button:hover:not(.active) {
  color: var(--wine-light);
}

/* ===== MAIN CONTENT ===== */
main {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px 12px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 16px var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  cursor: pointer;
  transition: box-shadow .15s, transform .12s;
}

.card:active {
  transform: scale(.99);
  box-shadow: 0 1px 8px var(--shadow);
}

.card.block {
  display: block;
  cursor: default;
}

.card.block:active {
  transform: none;
}

/* ===== THUMBNAILS ===== */
.thumb {
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--wine-mid);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.thumb-placeholder {
  width: 72px;
  height: 72px;
  min-width: 72px;
  border-radius: 12px;
  background: var(--wine-mid);
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb-placeholder svg {
  width: 32px;
  height: 32px;
  opacity: .5;
}

/* ===== CARD CONTENT TYPOGRAPHY ===== */
.wine-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  margin-bottom: 2px;
}

.wine-producer {
  font-family: 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.wine-vintage {
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
}

.wine-notes {
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== STAR RATING ===== */
.star-rating {
  display: flex;
  gap: 2px;
  align-items: center;
  margin: 4px 0;
}

.star-rating.interactive .star-half {
  cursor: pointer;
  transition: opacity .1s;
}

.star-rating.interactive .star-half:hover {
  opacity: .75;
}

.star-wrap {
  display: inline-flex;
  position: relative;
  width: 28px;
  height: 28px;
}

.star-wrap svg {
  width: 28px;
  height: 28px;
}

.star-wrap .star-left,
.star-wrap .star-right {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  cursor: pointer;
}

.star-wrap .star-left  { left: 0; }
.star-wrap .star-right { right: 0; }

/* Static small star display (journal/cellar cards) */
.star-display {
  display: inline-flex;
  gap: 1px;
  align-items: center;
}

.star-display .s {
  font-size: 15px;
  color: #ddd;
  line-height: 1;
}

.star-display .s.full  { color: var(--gold); }
.star-display .s.half  {
  background: linear-gradient(to right, var(--gold) 50%, #ddd 50%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  background: var(--gold);
  color: var(--wine);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 11px;
  font-family: 'Lato', sans-serif;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.badge-bottles {
  background: var(--gold);
  color: var(--wine);
}

/* ===== DRINK SOON ===== */
.drinksoon {
  border-left: 3px solid var(--danger);
  background: #fff8f7;
}

/* ===== FORM ELEMENTS ===== */
label {
  display: block;
  font-family: 'Lato', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--text-muted);
  margin: 14px 0 5px;
}

input,
textarea,
select {
  font-family: 'Lato', sans-serif;
  font-size: 16px;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,76,.15);
}

input[type="number"] {
  height: 48px;
}

input:not([type="checkbox"]):not([type="file"]),
textarea {
  height: auto;
}

input:not([type="checkbox"]):not([type="file"]):not([type="number"]) {
  height: 48px;
}

textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

input[type="file"] {
  height: auto;
  padding: 10px;
  border-style: dashed;
  border-color: var(--wine-light);
  background: rgba(139,45,74,.04);
  cursor: pointer;
}

/* ===== BUTTONS ===== */
button.primary, .btn-primary {
  display: block;
  width: 100%;
  background: var(--wine);
  color: var(--gold);
  border: none;
  border-radius: var(--radius-btn);
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  height: 48px;
  line-height: 48px;
  padding: 0 20px;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
  margin: 8px 0;
}

button.primary:hover, .btn-primary:hover {
  background: var(--wine-mid);
}

button.primary:active, .btn-primary:active {
  background: var(--wine-light);
}

button.secondary, .btn-secondary {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--gold);
  border: 1.5px solid var(--gold);
  border-radius: var(--radius-btn);
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  height: 48px;
  line-height: 44px;
  padding: 0 20px;
  cursor: pointer;
  text-align: center;
  transition: background .15s, color .15s;
  margin: 8px 0;
}

button.secondary:hover, .btn-secondary:hover {
  background: rgba(201,168,76,.08);
}

button.danger {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--danger);
  border: 1.5px solid var(--danger);
  border-radius: var(--radius-btn);
  font-family: 'Lato', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  height: 48px;
  line-height: 44px;
  padding: 0 20px;
  cursor: pointer;
  text-align: center;
  transition: background .15s;
  margin: 8px 0;
}

button.danger:hover {
  background: rgba(192,57,43,.08);
}

/* ===== PILL TOGGLE ===== */
.pill-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
  margin: 12px 0 0;
}

.pill-toggle {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.pill-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.pill-slider {
  position: absolute;
  inset: 0;
  background: #e0d5cc;
  border-radius: 26px;
  transition: background .2s;
  cursor: pointer;
}

.pill-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.pill-toggle input:checked + .pill-slider {
  background: var(--gold);
}

.pill-toggle input:checked + .pill-slider::before {
  transform: translateX(20px);
}

/* ===== TOAST ===== */
#toast {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  max-width: 320px;
  width: calc(100vw - 40px);
  background: var(--wine);
  color: var(--cream);
  border-radius: var(--radius-card);
  padding: 14px 20px;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  box-shadow: 0 4px 24px rgba(45,10,20,.3);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,10,20,.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-end;
}

/* ===== BOTTOM SHEET ===== */
.bottom-sheet {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 20px 32px;
  padding-bottom: calc(32px + env(safe-area-inset-bottom));
  max-height: 90vh;
  overflow-y: auto;
  animation: slide-up .22s ease;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 16px;
}

.sheet-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

@keyframes slide-up {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== LOADING / SPINNER ===== */
.loading-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: 0 2px 16px var(--shadow);
  padding: 48px 32px;
  text-align: center;
  margin: 32px 0;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(201,168,76,.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 18px;
  font-style: italic;
  color: var(--text-muted);
}

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 64px 32px;
  color: var(--text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  opacity: .25;
  margin-bottom: 20px;
}

.empty-state h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-size: 20px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ===== SECTION HEADINGS ===== */
.section-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--wine);
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* ===== WINE DETAIL HERO ===== */
.wine-hero {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--radius-card);
  margin-bottom: 16px;
  display: block;
}

.wine-detail-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  margin-bottom: 4px;
}

.wine-detail-sub {
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.notes-block {
  background: var(--cream);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 12px 16px;
  margin: 12px 0;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.55;
  font-style: italic;
}

/* ===== TASTING HISTORY CARDS ===== */
.tasting-card {
  background: var(--cream);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.tasting-date {
  font-family: 'Lato', sans-serif;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.tasting-comment {
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: var(--text);
  margin-top: 4px;
  line-height: 1.4;
}

/* ===== JOIN / ONBOARDING SCREEN ===== */
.join-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-height: 100vh;
  padding: 48px 24px 32px;
  background: var(--cream);
}

.join-wordmark {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--wine);
  text-align: center;
  margin-bottom: 8px;
}

.join-tagline {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 16px;
  font-style: italic;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

.join-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 auto 28px;
  opacity: .4;
}

.join-divider svg {
  width: 36px;
  height: 36px;
  color: var(--wine);
}

.join-card {
  background: var(--card);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 32px var(--shadow);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 400px;
}

.join-card label {
  margin-top: 8px;
}

/* ===== INVITE LINK INPUT ===== */
.invite-input-wrap {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.invite-input-wrap input {
  flex: 1;
  font-size: 13px;
  padding: 10px 12px;
}

/* ===== STOCK ROW ===== */
.stock-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.stock-row .field-wrap {
  flex: 1;
}

.stock-row button {
  margin: 0;
  height: 48px;
  padding: 0 18px;
  width: auto;
  flex-shrink: 0;
  font-size: 13px;
}

/* ===== VIEW TRANSITIONS ===== */
#app {
  view-transition-name: app;
}

@keyframes slide-in-right {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slide-in-left {
  from { transform: translateX(-100%); opacity: 0; }
  to   { transform: translateX(0);     opacity: 1; }
}

::view-transition-old(app) {
  animation: 160ms ease both slide-in-left;
  animation-direction: reverse;
}

::view-transition-new(app) {
  animation: 160ms ease both slide-in-right;
}

/* ===== CAPTURE SECTION ===== */
.capture-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 24px 0;
}

.capture-hint {
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
}

/* ===== SETTINGS SECTION ===== */
.settings-section {
  margin-bottom: 24px;
}

.settings-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.settings-sub {
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ===== MISC ===== */
* { -webkit-tap-highlight-color: transparent; }
a { color: var(--gold); text-decoration: none; }
