/* Shared by the homepage (index.html) and /routines/: Japanese phrase wrapping,
   public routine tiles (same look as the app's routine cards) and the routine preview dialog. */

.routine-tile {
  --cat: #f5d74d;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 22px;
  border: 1px solid #ffffff14;
  border-radius: 20px;
  background: #121415;
  color: #f5f4ed;
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .18s, border-color .18s, transform .18s;
}
.routine-tile[data-category="cardio"] { --cat: #75d9b7; }
.routine-tile[data-category="strength"] { --cat: #75aef2; }
.routine-tile[data-category="mobility"] { --cat: #ad96ed; }
.routine-tile[data-category="sleep_recovery"] { --cat: #8fb4ff; }
.routine-tile:hover,
.routine-tile:focus-visible { background: #17191a; border-color: color-mix(in srgb, var(--cat) 40%, transparent); transform: translateY(-2px); }
.routine-tile:focus-visible { outline: 2px solid var(--cat); outline-offset: 3px; }
.routine-tile-top { display: flex; align-items: center; gap: 12px; }
.routine-tile-symbol { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 14px; background: color-mix(in srgb, var(--cat) 14%, transparent); color: var(--cat); }
.routine-tile-symbol svg { width: 22px; height: 22px; }
.routine-tile-heading { display: block; min-width: 0; }
.routine-tile-category { display: block; color: var(--cat); font-size: 11px; font-weight: 700; line-height: 1.5; }
.routine-tile-title { display: block; margin: 2px 0 0; color: #f5f4ed; font-size: 17px; font-weight: 800; line-height: 1.45; letter-spacing: -.02em; }
.routine-tile-description { display: block; margin-top: 14px; color: #a3a6a2; font-size: 13px; line-height: 1.7; }
.routine-tile-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.routine-tile-meta > span { padding: 4px 11px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; background: rgba(255, 255, 255, .03); color: #cfd3d1; font-size: 12px; line-height: 1.5; }
.routine-tile-action { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: 18px; color: #f5f4ed; font-size: 13px; font-weight: 700; }
.routine-tile-action svg { width: 18px; height: 18px; color: var(--cat); transition: transform .18s; }
.routine-tile:hover .routine-tile-action svg { transform: translateX(3px); }

/* /routines/: tiles grouped by category. */
.routine-group { margin-top: 40px; }
.routine-group-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 1.15rem; letter-spacing: -.02em; }
.routine-group-count { padding: 2px 9px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; color: #a3a6a2; font-size: .75rem; font-weight: 700; }
.routine-tile-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.routine-preview-dialog {
  --preview-line: rgba(255, 255, 255, .09);
  --preview-muted: #a3a6a2;
  --preview-accent: #f5d74d;
  inset: 0;
  position: fixed;
  width: calc(100% - 36px);
  max-width: 620px;
  max-height: min(88vh, 780px);
  margin: auto;
  padding: 0;
  border: 1px solid var(--preview-line);
  border-radius: 22px;
  background: #121415;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .35);
  color: #f5f4ed;
}
.routine-preview-dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(8px); }
.routine-preview-sheet { max-height: min(88vh, 780px); overflow: auto; padding: 24px; }
.routine-preview-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.routine-preview-head h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.75rem); line-height: 1.25; }
.routine-preview-head p { margin: 8px 0 0; color: var(--preview-muted); line-height: 1.7; }
.routine-preview-close { padding: 2px 5px; border: 0; background: transparent; color: var(--preview-muted); font: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer; }
.routine-preview-close:hover,
.routine-preview-close:focus-visible { color: var(--preview-accent); }
.routine-preview-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.routine-preview-button { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 22px; border: 0; border-radius: 999px; background: var(--preview-accent); color: #111; font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; }
.routine-preview-button:hover,
.routine-preview-button:focus-visible { background: #d5b52d; }
.routine-preview-button.is-secondary { border: 1px solid var(--preview-line); background: #1b1d1f; color: #f5f4ed; }

@media (max-width: 900px) {
  .routine-tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .routine-tile { padding: 20px; }
  .routine-tile-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .routine-preview-dialog { inset: auto 0 0; width: 100%; max-width: none; max-height: 90vh; margin: 0; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .routine-preview-sheet { max-height: 90vh; padding: 20px 18px 24px; }
  .routine-preview-actions { justify-content: stretch; }
  .routine-preview-actions > * { flex: 1 1 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .routine-tile, .routine-tile-action svg { transition: none; }
}
