/* myrock.app — minimal, mobile-first, rock-colored */
:root {
  /* Defaults; overwritten per-rock via JS */
  --rock-1: #2a2118;          /* darker tone (background) */
  --rock-2: #5a4738;          /* lighter tone (accents) */
  --rock-text: #ecede7;       /* readable foreground over rock-1 */
  --rock-dim: rgba(236, 237, 231, 0.72);
  --rock-muted: rgba(236, 237, 231, 0.5);
  --rock-line: rgba(236, 237, 231, 0.14);

  --bg: #0a0a0f;
  --accent: #ff7a59;
  --accent-deep: #b03a1a;
  --radius: 14px;
  --radius-lg: 22px;
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.75);
  --serif: ui-serif, "Iowan Old Style", "Georgia", "Cambria", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;

  /* Keep top controls visually stable between rock/palette changes */
  --ctl-bg: rgba(245, 240, 234, 0.1);
  --ctl-bg-hover: rgba(245, 240, 234, 0.16);
  --ctl-border: rgba(245, 240, 234, 0.28);
  --ctl-text: #f2ebe2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { scroll-behavior: smooth; }

body {
  background: var(--rock-1);
  color: var(--rock-text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  transition: background-color 0.9s ease, color 0.9s ease;
  overflow-x: hidden;
}

/* ───── Interactive background canvas ───── */
#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse at var(--ptr-x, 30%) var(--ptr-y, 20%), var(--rock-2) 0%, transparent 55%),
    radial-gradient(ellipse at calc(100% - var(--ptr-x, 30%)) calc(100% - var(--ptr-y, 20%)), var(--rock-2) 0%, transparent 60%),
    var(--rock-1);
  transition: background 0.9s ease;
}

#app {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  min-height: 100svh;
  padding: 1.25rem 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.top-actions {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  gap: 0.55rem;
  align-items: center;
  flex-wrap: nowrap;
  width: 100%;
}

.top-btn {
  width: 100%;
  flex: 1 1 0;
  padding: 0.7rem 1rem;
  min-height: 2.55rem;
}

/* Share button sits between New Rock and Enable Shake, equal width with them */
.top-share-btn {
  flex: 1 1 0;
}

.top-actions .mini-btn:hover { filter: none; }
.top-actions .mini-btn:active { transform: translateY(0); }

/* ───── Hero image ───── */
.hero { margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }

.img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: transparent;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--rock-line);
}

#rock-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#rock-img.loaded { opacity: 1; }

.img-fallback {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--rock-muted);
  font-size: clamp(4rem, 18vw, 7rem);
  background: transparent;
}
.img-fallback[hidden] { display: none; }

.credit {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--rock-muted);
  padding-right: 0.25rem;
}
.credit a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.credit a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ───── Card ───── */
.card {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid var(--rock-line);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}

.card-head { display: flex; flex-direction: column; gap: 0.75rem; }

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
}

.title-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.55rem 0.8rem;
  min-width: 0;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--rock-text);
}

.icon-btn {
  flex: 0 0 auto;
  min-width: 2.8rem;
  min-height: 2.8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--rock-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--rock-text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, background 0.2s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  border-color: var(--rock-2);
  background: rgba(255, 255, 255, 0.1);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.icon-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.mini-btn {
  min-height: 2.55rem;
  border: 1px solid var(--ctl-border);
  border-radius: 999px;
  background: var(--ctl-bg);
  color: var(--ctl-text);
  padding: 0.7rem 1rem;
  font-family: var(--mono);
  font-size: 0.83rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.mini-btn:hover {
  transform: translateY(-1px);
  border-color: var(--rock-2);
  color: var(--rock-text);
}

.mini-btn.is-enabled {
  border-color: rgba(124, 201, 152, 0.75);
  background: rgba(86, 150, 107, 0.28);
  color: #ebfff1;
}

.mini-btn:disabled {
  cursor: default;
  opacity: 0.9;
}

.mini-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Prevent sticky hover visuals on touch screens and keep taps crisp */
@media (hover: hover) and (pointer: fine) {
  .top-actions .btn:hover,
  .top-actions .mini-btn:hover {
    border-color: rgba(245, 240, 234, 0.5);
    background: var(--ctl-bg-hover);
  }
}

.top-actions .btn,
.top-actions .mini-btn {
  -webkit-tap-highlight-color: transparent;
}

.pronunciation {
  font-family: var(--mono);
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  text-transform: none;
  color: var(--rock-dim);
  padding-top: 0.2rem;
  white-space: nowrap;
}

.pronunciation[hidden] {
  display: none;
}

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--rock-dim);
  border: 1px solid var(--rock-line);
  white-space: nowrap;
}

.tag-class {
  background: var(--rock-2);
  color: var(--rock-text);
  border-color: transparent;
}

.lede {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  line-height: 1.6;
  color: var(--rock-text);
  border-left: 3px solid var(--rock-2);
  padding: 0.1rem 0 0.1rem 0.95rem;
}

/* ───── Facts list ───── */
.facts {
  display: flex; flex-direction: column; gap: 0;
  border-top: 1px solid var(--rock-line);
}
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.2rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rock-line);
  color: var(--rock-muted);
}
dt {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  color: var(--rock-muted);
}
dd { color: var(--rock-dim); font-size: 0.95rem; }

/* ───── Actions ───── */
.actions {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.25rem;
}

.bottom-share-wrap {
  margin-top: auto;
  display: flex;
  justify-content: center;
  flex-direction: row;
  align-items: stretch;
  gap: 0.6rem;
  padding-top: 0.35rem;
  width: 100%;
}

@media (max-width: 420px) {
  .title-row {
    gap: 0.5rem;
  }

  .title-main {
    gap: 0.3rem 0.6rem;
  }

  .icon-btn {
    min-width: 2.55rem;
    min-height: 2.55rem;
  }

  .mini-btn {
    min-height: 2.35rem;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    padding: 0.56rem 0.72rem;
  }

  .top-btn {
    min-height: 2.35rem;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    padding: 0.56rem 0.72rem;
  }

  .bottom-share-btn {
    min-height: 2.35rem;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    padding: 0.56rem 0.72rem;
  }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.6rem;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: white;
  font: 600 0.95rem/1 var(--sans);
  letter-spacing: 0.01em;
  padding: 0.95rem 1.4rem;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  width: 100%;
  transition: transform 0.15s ease, filter 0.2s ease;
  box-shadow: 0 10px 30px -10px rgba(255, 122, 89, 0.55);
}
@media (min-width: 540px) { .btn { width: auto; } }
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn.is-enabled {
  background: linear-gradient(135deg, #5d9b6e 0%, #3f7150 100%);
  box-shadow: 0 10px 30px -10px rgba(86, 150, 107, 0.5);
}
.btn:disabled { cursor: default; }
.btn:disabled:hover { transform: none; filter: none; }
.btn-arrow { transition: transform 0.2s ease; }
.btn:hover .btn-arrow { transform: translateX(3px); }

/* Keep bottom share button sizing aligned with top controls */
.bottom-share-btn {
  width: 100%;
  flex: 1 1 auto;
  padding: 0.7rem 1rem;
  min-height: 2.55rem;
}

.bottom-all-rocks-btn {
  width: 100%;
  flex: 1 1 auto;
  min-height: 2.55rem;
  padding: 0.7rem 1rem;
  text-decoration: none;
}

.link {
  color: var(--rock-dim);
  text-decoration: none;
  font-size: 0.9rem;
  border-bottom: 1px dashed var(--rock-line);
  padding-bottom: 2px;
  text-align: center;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.link:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ───── Shake hints ───── */
.hint {
  text-align: center;
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--rock-muted);
  letter-spacing: 0.04em;
}
.hint-btn {
  background: transparent;
  border: 1px dashed var(--rock-line);
  color: var(--rock-dim);
  font-family: inherit;
  font-size: inherit;
  letter-spacing: inherit;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.hint-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Shake flash */
body.shaking #app {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  #rock-img { opacity: 1; transition: none; }
}
