/* learning-jar/style.css */

/* ---------------------------------------------------------------------------
   Design tokens
--------------------------------------------------------------------------- */
:root {
  --bg: #faf6f1;
  --slip-light: #e8ddd3;
  --slip-dark: #d4c4a8;
  --text: #4a3f35;
  --text-muted: #9b8b7b;
  --accent: #8B7355;
  --tag-book: #8B7355;
  --tag-course: #7B8B6F;
  --tag-video: #B07856;
  --tag-podcast: #9B8B6B;
}

/* ---------------------------------------------------------------------------
   Reset + base
--------------------------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

h1, h2, h3 {
  font-family: 'Playfair Display', Georgia, serif;
}

/* Views: hidden by default via [hidden] attribute; flex when visible */
.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
}

.view[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   Jar view
--------------------------------------------------------------------------- */
#view-jar {
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
  position: relative;
}

/* Gear button — top-right corner */
.btn-gear {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.35rem;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}
.btn-gear:hover {
  color: var(--accent);
  background: var(--slip-light);
}

/* Page title */
.jar-title {
  font-size: 1.6rem;
  color: var(--text);
  margin-bottom: 2.5rem;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------------------------
   Jar + slips wrapper — the tappable unit
--------------------------------------------------------------------------- */
.jar-tap-area {
  position: relative;
  width: 200px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

@keyframes jar-wobble {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

.jar-tap-area:hover .jar-svg {
  animation: jar-wobble 0.6s ease;
}

.jar-svg {
  display: block;
  width: 200px;
  transition: transform 0.18s ease;
}

/* ---------------------------------------------------------------------------
   Slips peeking out of jar top
--------------------------------------------------------------------------- */
.slips-container {
  position: absolute;
  /* Sit just above the jar opening — tune with jar SVG geometry */
  bottom: calc(100% - 58px);
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 70px;
  pointer-events: none;
}

.slip {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform-origin: bottom center;
  width: 32px;
  height: 44px;
  border-radius: 3px 3px 1px 1px;
  background: var(--slip-light);
  border: 1px solid var(--slip-dark);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4px 3px 0;
  overflow: hidden;
}

.slip-text {
  font-size: 6px;
  line-height: 1.3;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  overflow: hidden;
  max-height: 100%;
}

/* Alternate slip shade for variety */
.slip:nth-child(even) {
  background: var(--slip-dark);
}

/* ---------------------------------------------------------------------------
   Tap prompt
--------------------------------------------------------------------------- */
.jar-prompt {
  margin-top: 1.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------------------
   Empty state
--------------------------------------------------------------------------- */
.jar-empty {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.jar-empty p {
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.btn-add {
  background: var(--accent);
  color: #faf6f1;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.6rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.18s;
}
.btn-add:hover {
  opacity: 0.88;
}

/* ---------------------------------------------------------------------------
   Drawn view
--------------------------------------------------------------------------- */
#view-drawn {
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
}

@keyframes slip-rise {
  0%   { transform: translateY(100px) scale(0.8) rotate(-5deg); opacity: 0; }
  100% { transform: translateY(0)     scale(1)   rotate(0deg);  opacity: 1; }
}

@keyframes slip-shake {
  0%,  100% { transform: rotate(0);    }
  25%        { transform: rotate(-5deg); }
  75%        { transform: rotate(5deg);  }
}

.drawn-slip {
  max-width: 320px;
  width: 100%;
  background: var(--slip-light);
  border-radius: 16px;
  padding: 2.5rem 2rem 2rem;
  box-shadow: 0 8px 32px rgba(74, 63, 53, 0.14), 0 2px 8px rgba(74, 63, 53, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  animation: slip-rise 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.drawn-slip.shaking {
  animation: slip-shake 0.35s ease;
}

.drawn-type-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.tag-book    { background: #8B7355; color: #faf6f1; }
.tag-course  { background: #7B8B6F; color: #faf6f1; }
.tag-video   { background: #B07856; color: #faf6f1; }
.tag-podcast { background: #9B8B6B; color: #faf6f1; }

.drawn-name {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.4rem;
  color: var(--text);
  text-align: center;
  line-height: 1.4;
}

.drawn-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
}

.btn-start {
  width: 100%;
  text-align: center;
}

.btn-redraw {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  transition: color 0.18s, background 0.18s;
}

.btn-redraw:hover {
  color: var(--accent);
  background: var(--slip-dark);
}

/* ---------------------------------------------------------------------------
   Timer view
--------------------------------------------------------------------------- */
#view-timer {
  justify-content: center;
  padding: 2rem 1.5rem 3rem;
  position: relative;
}

.timer-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.timer-item-name {
  font-size: 0.85rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.timer-ring-wrapper {
  position: relative;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#timer-ring {
  transition: stroke-dashoffset 0.4s ease;
}

.timer-display {
  position: relative;
  font-family: 'Inter', sans-serif;
  font-size: 3.5rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: 0.02em;
}

.timer-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  max-width: 240px;
}

.btn-pause {
  width: 100%;
  text-align: center;
}

.btn-done-secondary {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  transition: color 0.18s, background 0.18s;
}

.btn-done-secondary:hover {
  color: var(--accent);
  background: var(--slip-dark);
}

/* ---------------------------------------------------------------------------
   Timer completion overlay
--------------------------------------------------------------------------- */
.timer-complete-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(250, 246, 241, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
}

.timer-complete-overlay[hidden] {
  display: none;
}

.timer-complete-card {
  background: var(--slip-light);
  border-radius: 16px;
  padding: 2.5rem 2rem 2rem;
  box-shadow: 0 8px 32px rgba(74, 63, 53, 0.14), 0 2px 8px rgba(74, 63, 53, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: 300px;
  width: 100%;
}

.timer-complete-msg {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 1.6rem;
  color: var(--text);
}

.timer-complete-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}

/* ---------------------------------------------------------------------------
   List view
--------------------------------------------------------------------------- */
#view-list {
  padding: 2rem 1.5rem 3rem;
  position: relative;
  align-items: stretch;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* Back button — top-left, mirrors gear button style */
.btn-back {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.35rem;
  border-radius: 50%;
  transition: color 0.2s, background 0.2s;
}
.btn-back:hover {
  color: var(--accent);
  background: var(--slip-light);
}

.list-title {
  font-size: 1.6rem;
  color: var(--text);
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

/* Add form — inline flex */
.list-add-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.list-add-form input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--slip-dark);
  border-radius: 8px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s;
}
.list-add-form input:focus {
  border-color: var(--accent);
}

.list-add-form select {
  padding: 0.5rem 0.4rem;
  border: 1.5px solid var(--slip-dark);
  border-radius: 8px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.list-add-form .btn-add {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

/* List items */
.list-items {
  display: flex;
  flex-direction: column;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--slip-light);
}

.list-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.list-row-name {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-row.completed .list-row-name {
  text-decoration: line-through;
  color: var(--text-muted);
}

.list-row-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.list-row-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.18s, background 0.18s;
  flex-shrink: 0;
}
.list-row-delete:hover {
  color: var(--accent);
  background: var(--slip-light);
}

/* Completed section */
.list-completed-section {
  margin-top: 1.5rem;
}

.list-completed-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  padding: 0.4rem 0;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.18s;
}
.list-completed-toggle:hover {
  color: var(--accent);
}

.list-completed-toggle .chevron {
  display: inline-block;
  transition: transform 0.2s;
  font-size: 1rem;
}
.list-completed-toggle.open .chevron {
  transform: rotate(90deg);
}

.list-completed-items {
  display: flex;
  flex-direction: column;
}

.list-completed-items[hidden] {
  display: none;
}

/* List footer */
.list-footer {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--slip-light);
}

/* Import modal */
.import-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.import-modal[hidden] {
  display: none;
}

.import-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(74, 63, 53, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.import-card {
  position: relative;
  background: var(--bg);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(74, 63, 53, 0.18);
  width: 90%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.import-card textarea {
  width: 100%;
  min-height: 160px;
  padding: 0.75rem;
  border: 1.5px solid var(--slip-dark);
  border-radius: 8px;
  background: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  resize: vertical;
  outline: none;
}
.import-card textarea:focus {
  border-color: var(--accent);
}

.import-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  animation: toast-up 2s ease forwards;
}

.toast[hidden] {
  display: none;
}

@keyframes toast-up {
  0%   { opacity: 0; transform: translateX(-50%) translateY(20px); }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  80%  { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

/* ---------------------------------------------------------------------------
   View transitions
--------------------------------------------------------------------------- */
@keyframes view-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.view:not([hidden]) {
  animation: view-fade-in 0.25s ease;
}

/* ---------------------------------------------------------------------------
   Button press feedback
--------------------------------------------------------------------------- */
button:active {
  transform: scale(0.97);
}

/* ---------------------------------------------------------------------------
   Empty state hidden rule
--------------------------------------------------------------------------- */
.jar-empty[hidden] {
  display: none;
}

/* ---------------------------------------------------------------------------
   Drawn view: vertically centered even on tall screens
--------------------------------------------------------------------------- */
#view-drawn {
  min-height: 100dvh;
  justify-content: center;
}

/* ---------------------------------------------------------------------------
   List view: scrollable for long lists
--------------------------------------------------------------------------- */
#view-list {
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
   Responsive: tiny screens (320px)
--------------------------------------------------------------------------- */
@media (max-width: 360px) {
  .jar-tap-area,
  .jar-svg {
    width: 160px;
  }

  .slips-container {
    width: 96px;
  }

  .jar-title,
  .list-title {
    font-size: 1.3rem;
  }
}

/* Responsive timer digits */
.timer-display {
  font-size: clamp(2.5rem, 10vw, 3.5rem);
}

/* ---------------------------------------------------------------------------
   Responsive: wider screens (>600px)
--------------------------------------------------------------------------- */
@media (min-width: 600px) {
  #view-jar {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }

  #view-drawn {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }

  #view-timer {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
  }
}
