/* Scoped styles for the Cozy Village Ranch UI */

dialog.ranch-panel:not([open]) {
  display: none !important;
}

dialog.ranch-panel[open] {
  --primary: var(--green);
  --primary-dark: var(--green-dark);
  --text: var(--ink);
  --text-muted: var(--muted);
  --border: rgba(69, 91, 75, .15);
  width: calc(100vw - 32px);
  max-width: 480px;
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.2));
  border-radius: 26px;
  background: var(--glass-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-shadow);
  color: var(--text, #333);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ranch-panel::backdrop {
  background: rgba(15, 33, 24, .14);
}

.ranch-panel .drawer-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.1));
}

.ranch-panel .drawer-heading h2 {
  margin: 0;
  font-size: 1.25em;
  font-weight: 700;
}

.ranch-header-info {
  padding: 12px 20px;
  background: rgba(255,255,255,0.4);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranch-gold {
  font-weight: 700;
  color: var(--primary, #dfb754);
  font-size: 1.2em;
}

.ranch-loop-hint {
  font-size: 0.85em;
  color: var(--text-muted, #666);
}

.ranch-close-btn { font-size: 1.5em; cursor: pointer; color: var(--text-muted, #666); }

.ranch-content {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

.ranch-tabs { display: flex; border-bottom: 1px solid var(--border, rgba(0, 0, 0, 0.1)); }

.ranch-tab { flex: 1; background: transparent; border-bottom: 3px solid transparent; font-weight: 600; cursor: pointer; color: var(--text-muted, #666); transition: color 0.2s, border-color 0.2s, background 0.2s; }

.ranch-tab:hover {
  background: rgba(255, 255, 255, 0.2);
}

.ranch-tab.active { border-bottom-color: var(--primary, #dfb754); }

.ranch-tab-content {
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.ranch-compact-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--glass-card);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
  border-radius: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.4);
}
.ranch-compact-btn:hover {
  background: rgba(255, 255, 255, 0.9);
}
.ranch-compact-btn:active {
  transform: scale(0.98);
}

.ranch-compact-icon {
  width: 32px;
  height: 32px;
  display: inline-block;
}
.ranch-compact-icon.chicken { background: #d2bd95; }
.ranch-compact-icon.sheep { background: #ecf0f1; border: 1px solid #ccc; }
.ranch-compact-icon.moonchick { background: #8a9a86; }
.ranch-growth { color: var(--muted); font-size: .85em; }
.ranch-buy-btn { display: flex; align-items: center; gap: 6px; }
.ranch-buy-btn [data-animal-icon] { flex: 0 0 32px; height: 32px; }

.ranch-compact-name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  font-size: 1.05em;
  color: var(--text, #333);
}
.ranch-compact-bond {
  color: #89533f;
  font-weight: 600;
}

.ranch-card {
  background: var(--glass-card);
  border: 1px solid var(--border, rgba(0, 0, 0, 0.05));
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}
.ranch-card.selected {
  border: 1px solid rgba(80,108,91,.48);
  box-shadow: 0 4px 18px rgba(41,62,47,.06);
}

.ranch-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.ranch-species {
  font-weight: 700;
  font-size: 1.1em;
  color: var(--primary, #dfb754);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ranch-species::before {
  content: '';
  display: inline-block;
  width: 16px; height: 16px;
  border-radius: 50%;
}
.ranch-species.chicken::before { background: #f4d03f; }
.ranch-species.sheep::before { background: #ecf0f1; border: 1px solid #ccc; }
.ranch-species.moonchick::before { background: #9b59b6; }

.ranch-name-editor {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ranch-name-input {
  border: 1px solid var(--border, rgba(0,0,0,0.1));
  background: rgba(255,255,255,0.5);
  font-size: 1.1em;
  font-weight: 700;
  color: inherit;
  text-align: center;
  width: 100px;
  transition: border-color 0.2s, background 0.2s;
  border-radius: 6px;
  padding: 4px 8px;
}
.ranch-name-input:focus {
  outline: none;
  border-color: var(--primary, #dfb754);
  background: var(--glass-card);
}

.ranch-btn-small {
  padding: 6px 10px;
  font-size: 0.85em;
}

.ranch-animal-meta {
  font-size: 0.9em;
  color: var(--text-muted, #666);
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ranch-bond {
  color: #89533f;
  letter-spacing: 2px;
  font-size: 1.1em;
}

.ranch-animal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.ranch-btn {
  background: var(--glass-card);
  border: 1px solid var(--border, #dcdcdc);
  color: var(--text, #333);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9em;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, opacity 0.2s;
}

.ranch-btn:active {
  transform: scale(0.97);
}

.ranch-btn:hover:not(:disabled) {
  background: var(--glass-bg-hover);
}

.ranch-btn:disabled {
  opacity: .7;
  cursor: not-allowed;
  transform: none;
  background: transparent;
}

.ranch-btn-danger {
  color: #8a3e36;
  border-color: rgba(255, 107, 107, 0.3);
}

.ranch-btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.05);
}

.ranch-btn-special {
  background: var(--primary, #dfb754);
  color: #fff;
  border: none;
  width: 100%;
  padding: 14px;
  font-size: 1.05em;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(36, 67, 49, .14);
}

.ranch-btn-special:hover:not(:disabled) {
  background: var(--primary-dark, #c5a045);
}

.ranch-buy-section {
  margin-top: 32px;
  border-top: 1px dashed var(--border, rgba(0, 0, 0, 0.1));
  padding-top: 20px;
}

.ranch-buy-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.ranch-socket-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ranch-socket-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--glass-card);
  border-radius: 8px;
  border: 1px solid var(--border, rgba(0, 0, 0, 0.05));
}

.ranch-socket-item span {
  flex: 1;
  font-weight: 500;
}

.ranch-info {
  font-size: 0.9em;
  color: var(--text-muted, #666);
  line-height: 1.5;
  margin-bottom: 16px;
}
.ranch-info.error {
  color: #8a3e36;
}
.ranch-info.success {
  color: var(--green);
  font-weight: bold;
}

.ranch-empty {
  text-align: center;
  color: var(--text-muted, #666);
  padding: 40px 0;
  font-style: italic;
}

.ranch-obs-card h4 {
  margin: 0 0 8px 0;
  font-size: 1.1em;
}

.ranch-obs-card p {
  margin: 0;
  font-size: 0.95em;
  color: var(--text-muted, #666);
  line-height: 1.5;
}

.ranch-obs-card.locked {
  opacity: 1;
  background: transparent;
  border-style: dashed;
}

.ranch-cost {
  color: var(--primary, #dfb754);
  font-weight: 700;
  font-size: 1.1em;
}

.ranch-desc {
  margin: 8px 0 4px 0;
  font-size: 0.95em;
  line-height: 1.4;
}

.ranch-behavior {
  margin: 0 0 16px 0;
  font-size: 0.9em;
  color: var(--text-muted, #666);
  font-style: italic;
}

.ranch-tabs { gap: 4px; margin: 0 20px; padding: 4px; border: 1px solid var(--glass-border); border-radius: 14px; background: rgba(44,76,56,.06); }
.ranch-tab { min-height: 44px; padding: 10px 8px; border: 1px solid transparent; border-radius: 10px; box-shadow: none; }
.ranch-tab.active { color: var(--white); background: var(--green); border-color: var(--green); }
.ranch-tab.active:hover { background: var(--green-dark); }
.ranch-name-input { min-height: 44px; min-width: 0; }
.ranch-animal-meta { flex-wrap: wrap; gap: 8px; line-height: 1.6; }
.ranch-close-btn { width: 44px; flex: 0 0 44px; padding: 0; background: var(--glass-card); border: 1px solid var(--glass-border); }
@media (max-width: 380px) {
  .ranch-tabs { margin: 0 12px; }
  .ranch-tab-content { padding: 16px 12px; }
  .ranch-header { padding: 16px; }
  .ranch-animal-actions { grid-template-columns: 1fr; }
  .ranch-compact-btn { flex-wrap: wrap; }
}
