/*
 * EmotiCue stylesheet
 * Requires: https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&display=swap
 */

/* ── Variables ── */
:root {
  --cream: #faf8f4;
  --ink: #2c2c2c;
  --ink-soft: #6b6b6b;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html {
  background: #dedad3;
  min-height: 100vh;
}

body {
  font-family: 'Lora', serif;
  color: var(--ink);
  display: flex;
  justify-content: center;
  padding: 40px 1rem;
}

.app {
  background: var(--cream);
  width: 100%;
  max-width: 430px;
  overflow-x: hidden;
  border: 1px solid #c8c3bb;
  border-radius: 20px;
}

/* ── Header ── */
header {
  padding: 52px 24px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
header h1 {
  font-family: 'Lora', serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1;
}
header h1 span { font-style: italic; }

.app-description {
  padding: 0 24px 4px;
  font-size: 14px;
  line-height: 1.5;
  color: #6b6560;
  font-family: 'Lora', serif;
  font-style: italic;
}

/* ── View toggle ── */
.toggle-bar {
  margin: 12px 24px 20px;
  display: flex;
  background: #d4cfc7;
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
}
.toggle-btn {
  flex: 1; padding: 9px; border: none; border-radius: 10px;
  font-family: 'Lora', serif; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.2s ease; background: transparent; color: var(--ink-soft);
}
.toggle-btn.active { background: white; color: var(--ink); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* ── Shared ── */
.section-label {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink-soft); margin-bottom: 12px;
}

/* ── Grid view ── */
#grid-view { padding: 0 16px 32px; }

.breadcrumb {
  display: flex; align-items: center; gap: 8px;
  padding: 0 0 16px; flex-wrap: wrap;
}
.breadcrumb-item {
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  cursor: pointer; transition: color 0.15s;
}
.breadcrumb-item:hover { color: var(--ink); }
.breadcrumb-item.current { color: var(--ink); font-weight: 600; }
.breadcrumb-sep { color: #ccc; font-size: 12px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.emotion-tile {
  border-radius: 18px;
  padding: 16px 14px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.emotion-tile:active { transform: scale(0.96); }
.emotion-tile:focus-visible { outline: 3px solid rgba(0,0,0,0.5); outline-offset: 2px; }

.tile-name {
  font-family: 'Lora', serif;
  font-size: 16px; font-weight: 600; line-height: 1.2; color: #1a1a1a;
  position: relative; z-index: 1;
}

/* ── Add buttons ── */
.add-btn {
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; line-height: 1;
  color: #333;
  transition: background 0.15s, transform 0.1s;
  z-index: 2;
  padding: 0;
}
.add-btn:active { transform: scale(0.9); }
.add-btn.added { background: rgba(255,255,255,0.95); color: #2c2c2c; }

.card-add-btn {
  position: absolute;
  top: 20px; right: 20px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1;
  color: #333;
  transition: background 0.15s, transform 0.1s;
  z-index: 20;
  padding: 0;
}
.card-add-btn:active { transform: scale(0.9); }
.card-add-btn.added { background: rgba(255,255,255,0.95); }

/* ── My Emotions section ── */
#my-emotions-section {
  padding: 8px 16px 48px;
}
#my-emotions-section .section-label {
  margin-bottom: 12px;
}

.my-words-slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.word-slot {
  border-radius: 18px;
  min-height: 80px;
  display: flex; flex-direction: column;
  align-items: flex-start; justify-content: flex-end;
  padding: 14px 12px;
  position: relative;
  transition: transform 0.15s;
  overflow: hidden;
}
.word-slot.empty {
  border: 1.5px dashed #ddd;
  background: #faf8f4;
  align-items: center; justify-content: center;
}
.word-slot.filled { border: none; }
.word-slot.filled:active { transform: scale(0.96); }
.slot-placeholder {
  font-size: 11px; color: #ccc; font-style: italic;
  text-align: center; line-height: 1.5;
  font-family: 'Lora', serif;
}
.slot-word {
  font-family: 'Lora', serif;
  font-size: 14px; font-weight: 600;
  color: #1a1a1a; line-height: 1.2;
}
.slot-remove {
  position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.12); border: none;
  cursor: pointer; font-size: 12px; color: #555;
  display: flex; align-items: center; justify-content: center;
  padding: 0; line-height: 1;
}

/* ── Toast notification ── */
.toast {
  position: fixed;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 14px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  z-index: 2000;
}
.toast.show { opacity: 1; }

/* ── Swipe / card view ── */
#swipe-view {
  padding: 0 24px;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.swipe-counter { font-size: 13px; color: var(--ink-soft); font-weight: 500; align-self: flex-end; }
.card-stack { width: 100%; height: 420px; position: relative; }
.swipe-card {
  position: absolute; inset: 0; border-radius: 28px;
  padding: 32px 28px; display: flex; flex-direction: column;
  justify-content: flex-end;
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
  overflow: hidden;
  will-change: transform;
}
.swipe-card.top     { z-index: 10; cursor: grab; }
.swipe-card.top:active { cursor: grabbing; }
.swipe-card.behind-1 { transform: scale(0.95) translateY(12px); z-index: 5; pointer-events: none; opacity: 1; }
.swipe-card.behind-2 { transform: scale(0.90) translateY(24px); z-index: 1; pointer-events: none; opacity: 0.7; }
.swipe-card.animate  { transition: transform 0.25s ease; }

.card-core-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase;
  opacity: 0.45; margin-bottom: 4px;
}
.card-parent-label {
  font-size: 13px; font-weight: 500; opacity: 0.6; margin-bottom: 6px;
}
.card-name {
  font-family: 'Lora', serif;
  font-size: 38px; font-weight: 600; line-height: 1.1; color: #1a1a1a; margin-bottom: 14px;
}
.card-def { font-size: 14px; line-height: 1.65; color: #555; font-weight: 300; }
.card-relations {
  margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px;
}
.relation-chip {
  padding: 5px 11px; border-radius: 20px; font-size: 11px; font-weight: 500;
  background: rgba(255,255,255,0.55); color: #333; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08); transition: background 0.15s;
}
.relation-chip:hover { background: rgba(255,255,255,0.85); }

.swipe-hint { display: flex; gap: 24px; font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.card-nav { display: flex; gap: 12px; width: 100%; }
.nav-btn {
  flex: 1; padding: 13px; border: none; border-radius: 14px;
  font-family: 'Lora', serif; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: transform 0.1s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.nav-btn:active { transform: scale(0.96); }
.nav-btn.prev { background: white; color: var(--ink-soft); }
.nav-btn.next { background: var(--ink); color: white; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(30,30,30,0.4);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  z-index: 100; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  width: 100%; max-width: 430px; margin: 0 auto; background: white;
  border-radius: 28px 28px 0 0; padding: 20px 26px 48px;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
  max-height: 80vh; overflow-y: auto;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle { width: 40px; height: 4px; border-radius: 2px; background: #ddd; margin: 0 auto 22px; }
.modal-badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase;
  margin-bottom: 10px;
}
.modal-name {
  font-family: 'Lora', serif;
  font-size: 34px; font-weight: 600; line-height: 1.15; margin-bottom: 10px;
}
.modal-parent { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }
.modal-def { font-size: 15px; line-height: 1.7; color: var(--ink-soft); font-weight: 300; margin-bottom: 20px; }
.modal-related-label { font-size: 11px; font-weight: 600; letter-spacing: 0.8px; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; }
.modal-related { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.modal-chip {
  padding: 7px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1.5px solid rgba(0,0,0,0.1); transition: all 0.15s;
  background: transparent;
}
.modal-chip:active { transform: scale(0.95); }
.modal-footer { display: flex; gap: 10px; }
.modal-footer .modal-close { flex: 1; }
.modal-close {
  width: 100%; padding: 15px; border: none; border-radius: 14px;
  background: var(--ink); color: white;
  font-family: 'Lora', serif; font-size: 15px; font-weight: 500; cursor: pointer;
}
.modal-add-btn {
  flex-shrink: 0; padding: 15px 20px; border: none; border-radius: 14px;
  background: var(--ink); color: white;
  font-family: 'Lora', serif; font-size: 20px; font-weight: 500; cursor: pointer;
  transition: opacity 0.15s;
}
.modal-add-btn.added { opacity: 0.5; }
