/*
 * Mandala Rails — Application Styles
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f5f5f0;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Nav ── */
.app-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: #1a1a1a;
  color: #f5f5f0;
}
.app-nav-brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.app-nav-user  { font-size: 0.85rem; opacity: 0.6; }

/* ── Buttons ── */
.button {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #1a1a1a;
  color: #f5f5f0;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.button:hover         { background: #333; }
.button-small         { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.button-danger        { background: #c0392b; }
.button-danger:hover  { background: #96281b; }

/* ── App Main ── */
.app-main { padding: 2rem 1.5rem; max-width: 960px; margin: 0 auto; }

/* ── Charts List ── */
.charts-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.charts-header h1 { margin-right: auto; }

.charts-list { display: flex; flex-direction: column; gap: 0.75rem; }

.chart-card {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  background: white;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
}
.chart-card-info  { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.chart-title      { font-weight: 600; font-size: 1rem; }
.chart-goal-preview { font-size: 0.85rem; color: #666; }
.chart-mode       { font-size: 0.8rem; color: #888; text-transform: capitalize; }
.chart-card-actions { display: flex; gap: 0.5rem; }

.empty-state { color: #888; font-style: italic; margin-top: 2rem; }

/* ── Chart Show ── */
.chart-show-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}
.chart-show-header h1 { margin-right: auto; }

/* ── Chart title inline edit ── */
.chart-show-header turbo-frame {
  flex: 1;
  display: block;
}

.chart-title-editable {
  display: inline-block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: border-color 0.15s;
}
.chart-title-editable:hover {
  border-bottom-color: #ccc;
}

.chart-title-form {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
}
.chart-title-input {
  flex: 1;
  font-size: 1.5rem;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid #1a1a1a;
  border-radius: 0;
  padding: 0.1rem 0;
  font-family: inherit;
  background: transparent;
  outline: none;
  min-width: 12ch;
}
.chart-mode-badge {
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  background: #e8e8e0;
  border-radius: 99px;
  text-transform: capitalize;
}

/* ── Mandala Grid ── */
.mandala-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: min(540px, 90vw);
  margin: 0 auto;
}

.mandala-tile {
  aspect-ratio: 1;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
}

.mandala-tile:hover       { border-color: #999; }
.tile-center              { border-color: #1a1a1a; background: #f0f0e8; }
.tile-center:hover        { background: #e8e8dc; }
.tile-has-children        { border-style: dashed; }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  flex: 1;
}
.breadcrumb a       { color: #1a1a1a; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep     { color: #aaa; }
.breadcrumb-current { font-weight: 600; }

/* ── Tile zones: title renames, body writes, arrow drills ── */
.mandala-tile {
  position: relative;
}

.tile-title-zone {
  display: block;
  width: 100%;
  padding: 0.5rem 0.5rem 0.25rem;
  text-align: center;
  text-decoration: none;
  color: #1a1a1a;
  min-height: 1.8rem;
}
.tile-title-zone:hover { background: rgba(0, 0, 0, 0.04); }

.tile-title--placeholder {
  color: #aaa;
  font-style: italic;
  font-weight: 400;
}

.tile-body-zone {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #1a1a1a;
  padding: 0 0.5rem 1.4rem;
  text-align: center;
  gap: 0.25rem;
}
.tile-body-zone:hover { background: rgba(0, 0, 0, 0.02); }

.tile-title {
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-subtitle {
  font-size: 0.75rem;
  color: #888;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.tile-body-preview {
  font-size: 0.75rem;
  color: #aaa;
  line-height: 1.2;
  font-style: italic;
}

/* ── Drill arrow ── */
.mandala-tile form.button_to { display: contents; }

.tile-drill {
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-size: 0.65rem;
  color: #ccc;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
  z-index: 1;
}
.tile-drill:hover { color: #333; }

/* ── In-place rename ── */
.tile-renaming {
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

.tile-rename-form { width: 100%; }

.tile-rename-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  padding: 0;
}

.tile-rename-cancel {
  position: absolute;
  top: 5px;
  right: 8px;
  font-size: 0.65rem;
  color: #ccc;
  text-decoration: none;
  line-height: 1;
}
.tile-rename-cancel:hover { color: #333; }

.tile-document-title-wrap,
.tile-document-subtitle-wrap {
  position: relative;
}

.char-counter {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 0.7rem;
  color: #ccc;
  pointer-events: none;
}

.char-counter--warn  .char-counter { color: #e0a800; }
.char-counter--danger .char-counter { color: #c0392b; }
.char-counter--warn  { color: #e0a800; }
.char-counter--danger { color: #c0392b; }

.tile-edit-cancel {
  font-size: 0.9rem;
  color: #888;
  text-decoration: none;
}
.tile-edit-cancel:hover { color: #1a1a1a; text-decoration: underline; }

/* ── Tile Document Page (full-page editor) ── */
.tile-document-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tile-document-back {
  color: #1a1a1a;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.tile-document-back:hover { text-decoration: underline; }
.tile-document-context {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #888;
}
.tile-document-chart-title { font-weight: 500; }
.tile-document-sep { color: #ccc; }
.tile-document-grid-label { color: #aaa; }

.tile-document-page {
  max-width: 680px;
  margin: 2.5rem auto;
  padding: 0 1.5rem 4rem;
}

.tile-document-form {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.tile-document-title {
  font-size: 1.8rem;
  font-weight: 700;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.25rem 0;
  font-family: inherit;
  width: 100%;
  background: transparent;
  outline: none;
  color: #1a1a1a;
}
.tile-document-title:focus { border-bottom-color: #e0e0e0; }
.tile-document-title::placeholder { color: #ccc; }

.tile-document-subtitle {
  font-size: 1.1rem;
  color: #666;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 0.2rem 0;
  font-family: inherit;
  width: 100%;
  background: transparent;
  outline: none;
}
.tile-document-subtitle:focus { border-bottom-color: #e0e0e0; }
.tile-document-subtitle::placeholder { color: #ddd; }

.tile-document-body {
  margin-top: 1.25rem;
  min-height: 300px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.tile-document-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* ── Forms ── */
.form-wrapper { max-width: 480px; }
.form-wrapper h1 { margin-bottom: 1.5rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 1rem; }
.field label { font-size: 0.85rem; font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: inherit;
}
.field input:focus, .field select:focus { outline: 2px solid #1a1a1a; border-color: transparent; }

.form-actions { display: flex; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.form-errors  { background: #fde; border: 1px solid #fcc; border-radius: 4px; padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; }
