/* PetPetLand PWA shell stylesheet.
 * Only loaded by ios/index.html (mobile / browser host). The Electron desktop
 * version never references this file, so desktop rendering is untouched.
 * Loaded AFTER renderer/style.css to layer shell-specific overrides. */

/* Opaque background: the desktop version renders on a transparent window,
 * the browser host needs a real backdrop. Also block page-level gestures. */
html, body {
  background: linear-gradient(180deg, #fdf2f6 0%, #fbe3ec 55%, #f6d0de 100%) fixed;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* Canvas: browser gestures (scroll / pinch / double-tap zoom) are disabled.
 * Touch input is translated into mouse events by touch-adapter.js. */
#petCanvas {
  touch-action: none;
  -webkit-user-drag: none;
}

/* Interactive DOM elements re-enable tap behavior. */
.bubble,
.interact-bar,
.chat-box {
  touch-action: manipulation;
}

/* Coarse pointer (touch) ergonomics. */
@media (pointer: coarse) {
  .interact-btn {
    padding: 9px 16px;
    font-size: 14px;
    border-radius: 14px;
  }
  .interact-bar {
    gap: 8px;
    padding: 7px 10px;
  }
  .bubble {
    font-size: 14px;
  }
  /* iOS auto-zooms the page when an input below 16px receives focus. */
  .chat-input {
    font-size: 16px;
    padding: 8px 10px;
  }
  .chat-send,
  .chat-exit {
    font-size: 14px;
    padding: 8px 12px;
  }
}

/* Touch devices: neutralize sticky :hover states after a tap. */
@media (hover: none) {
  .interact-btn:hover {
    background: linear-gradient(180deg, #fff 0%, #fdf2f5 100%);
    color: #c46a82;
    border-color: #e8b8c8;
    box-shadow: none;
  }
  .interact-btn-highlight:hover {
    background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
    color: #fff;
    border-color: #e88a9f;
  }
}

/* ===== Settings panel (ios/panel-sheet.js) =====
 * Opened by long-press on the pet, the "more" interact button, or a
 * desktop-browser right click.
 * Phones (<880px): bottom sheet with every module stacked.
 * Desktop browsers (>=880px): a centered window that mirrors the Electron
 * settings panel (title bar + sidebar nav + the pink candy palette from
 * renderer/panel/panel.css); one module shows at a time. */

.pet-panel-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Local override only; the rest of the shell does not use .hidden widely. */
.pet-panel-root.hidden,
.pet-panel-toast.hidden {
  display: none;
}

.pet-panel-root,
.pet-panel-toast {
  -webkit-user-select: none;
  user-select: none;
}

.pet-panel-root button {
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pet-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(74, 38, 52, .35);
  opacity: 0;
  transition: opacity .28s ease;
}
.pet-panel-root.is-open .pet-panel-backdrop {
  opacity: 1;
}

.pet-panel-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #fdf6f8 0%, #faf0f3 50%, #f8eef2 100%);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(180, 90, 120, .28);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  transform: translateY(105%);
  transition: transform .3s cubic-bezier(.32, .72, .35, 1);
}
.pet-panel-root.is-open .pet-panel-sheet {
  transform: translateY(0);
}

/* Desktop-window chrome, switched on by the wide-screen media query below. */
.pet-panel-titlebar { display: none; }
.pet-panel-sidebar { display: none; }

.pet-panel-head {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 52px 12px;
}
.pet-panel-grab {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: #f0d7e0;
}
.pet-panel-title {
  font-size: 16px;
  font-weight: 600;
  color: #8a4a5e;
}
.pet-panel-close {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #fbeef3;
  color: #b3627f;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.pet-panel-app {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.pet-panel-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.pet-panel-content {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: 4px 14px 16px;
}

/* Phones: every module stacks (the sidebar is hidden, no switching). */
.pet-panel-module { display: block; }

/* ----- Sections ----- */
.pet-panel-section {
  margin-bottom: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(232, 138, 159, .06), 0 0 0 1px rgba(232, 138, 159, .05);
}
.pet-panel-section:last-child { margin-bottom: 0; }
.pet-panel-section h3 {
  margin: 0 0 12px;
  padding-bottom: 9px;
  border-bottom: 2px solid #f5e8ed;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #c46a82;
}
.pet-panel-section h3::before {
  content: '';
  width: 4px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
}

/* ----- Characters ----- */
.pet-panel-char {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 11px 13px;
  background: linear-gradient(135deg, #fffbfc 0%, #fff8fa 100%);
  border: 1px solid #f5e8ed;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  transition: all .2s ease;
}
.pet-panel-char:last-child { margin-bottom: 0; }
.pet-panel-char:hover {
  border-color: #f0d0dc;
  background: linear-gradient(135deg, #fff8fa 0%, #fff0f5 100%);
}
.pet-panel-char.is-current {
  border-color: #efa9c0;
  background: linear-gradient(135deg, #fff8fa 0%, #fff0f5 100%);
  box-shadow: 0 2px 10px rgba(232, 138, 159, .14);
}
.pet-panel-char-avatar {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f5a5b8 0%, #e88a9f 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(232, 138, 159, .25);
}
.pet-panel-char-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pet-panel-char-name {
  font-size: 14px;
  font-weight: 600;
  color: #5a3542;
}
.pet-panel-char-state {
  font-size: 11px;
  color: #c98a9c;
}

/* ----- Switch rows ----- */
.pet-panel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: linear-gradient(135deg, #fffbfc 0%, #fff8fa 100%);
  border: 1px solid #f5e8ed;
  border-radius: 12px;
  touch-action: manipulation;
  transition: all .2s ease;
}
.pet-panel-row + .pet-panel-row { margin-top: 8px; }
.pet-panel-row:hover {
  border-color: #f0d0dc;
  background: linear-gradient(135deg, #fff8fa 0%, #fff0f5 100%);
}
.pet-panel-row-info { flex: 1; min-width: 0; }
.pet-panel-row-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #5a3542;
  margin-bottom: 3px;
}
.pet-panel-row-desc {
  font-size: 11px;
  color: #a8939c;
  line-height: 1.5;
}

/* Visually hidden checkbox keeps focus/keyboard support; the styled slider
 * is the next sibling, so :checked + .pet-panel-slider drives the visuals. */
.pet-panel-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
  cursor: pointer;
}
.pet-panel-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.pet-panel-slider {
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: #e0d0d6;
  transition: background .3s ease, box-shadow .3s ease;
}
.pet-panel-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  bottom: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
  transition: transform .3s ease;
}
.pet-panel-switch input:checked + .pet-panel-slider {
  background: linear-gradient(135deg, #f5a5b8 0%, #e88a9f 100%);
  box-shadow: 0 2px 8px rgba(232, 138, 159, .3);
}
.pet-panel-switch input:checked + .pet-panel-slider::before {
  transform: translateX(20px);
}
.pet-panel-switch input:focus-visible + .pet-panel-slider {
  box-shadow: 0 0 0 3px rgba(232, 138, 159, .35);
}

/* ----- Clear chat (two-tap confirm) ----- */
.pet-panel-clear {
  display: block;
  width: 100%;
  padding: 10px 20px;
  background: linear-gradient(180deg, #fff 0%, #fff8fa 100%);
  border: 1.5px solid #e8c8d4;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  color: #e88a9f;
  cursor: pointer;
  transition: all .2s ease;
}
.pet-panel-clear:hover {
  border-color: #e88a9f;
  background: linear-gradient(180deg, #fff8fa 0%, #fdf2f5 100%);
  box-shadow: 0 4px 12px rgba(232, 138, 159, .15);
}
.pet-panel-clear.is-armed {
  background: linear-gradient(180deg, #f5a5b8 0%, #e88a9f 100%);
  border-color: #e88a9f;
  color: #fff;
}

/* ----- Hints ----- */
.pet-panel-hint {
  margin-top: 10px;
  padding: 8px 12px;
  background: #faf7f8;
  border-left: 3px solid #f0c8d4;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.6;
  color: #ad95a0;
}
.pet-panel-section .pet-panel-hint:first-child { margin-top: 0; }

/* ----- About ----- */
.pet-panel-about-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 22px 16px 18px;
  margin-bottom: 12px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(232, 138, 159, .06), 0 0 0 1px rgba(232, 138, 159, .05);
}
.pet-panel-about-logo {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(135deg, #f8b8cc 0%, #e888a8 100%);
  box-shadow: 0 6px 20px rgba(232, 136, 168, .3);
  margin-bottom: 14px;
}
.pet-panel-about-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.pet-panel-about-name {
  font-size: 22px;
  font-weight: 700;
  background: linear-gradient(135deg, #c46a82 0%, #e88a9f 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 5px;
}
.pet-panel-about-ver {
  font-size: 12px;
  color: #b08898;
  margin-bottom: 12px;
}
.pet-panel-about-story {
  font-size: 12px;
  color: #8f7580;
  line-height: 2;
  max-width: 460px;
}

/* ----- Toast ----- */
.pet-panel-toast {
  position: fixed;
  left: 50%;
  bottom: calc(12% + env(safe-area-inset-bottom, 0px));
  z-index: 10000;
  max-width: 76vw;
  padding: 9px 18px;
  background: rgba(74, 38, 52, .88);
  color: #fff;
  font-size: 14px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition: opacity .22s ease, transform .22s ease, visibility .22s;
}
.pet-panel-toast.is-show {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* ===== Wide screens: desktop-style window (mirrors renderer/panel) =====
 * The sheet becomes a centered 900x650-ish card with a title bar, a sidebar
 * with app info + module nav, and one visible module - same layout language,
 * palette and switch styling as the Electron settings panel. */
@media (min-width: 880px) {
  .pet-panel-root { align-items: center; }

  .pet-panel-sheet {
    width: min(900px, calc(100vw - 48px));
    max-width: 900px;
    height: min(650px, calc(100vh - 48px));
    max-height: none;
    border-radius: 22px;
    box-shadow: 0 24px 80px rgba(120, 50, 75, .35);
    padding-bottom: 0;
    transform: translateY(18px) scale(.98);
    opacity: 0;
    transition: transform .28s cubic-bezier(.32, .72, .35, 1), opacity .28s ease;
  }
  .pet-panel-root.is-open .pet-panel-sheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  /* Window title bar */
  .pet-panel-titlebar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 44px;
    padding: 0 10px 0 16px;
    background: linear-gradient(180deg, #fff 0%, #fff8fa 100%);
    border-bottom: 1px solid #f5e8ed;
  }
  .pet-panel-titlebar-text {
    font-size: 13px;
    font-weight: 600;
    background: linear-gradient(135deg, #c46a82 0%, #e88a9f 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
  .pet-panel-titlebar-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #b08898;
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: all .2s ease;
  }
  .pet-panel-titlebar-btn:hover {
    background: #ff4d4f;
    color: #fff;
  }

  /* Sidebar + content area */
  .pet-panel-app {
    flex-direction: row;
    gap: 14px;
    padding: 14px;
    min-height: 0;
  }
  .pet-panel-sidebar {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 176px;
    background: linear-gradient(180deg, #fff 0%, #fff8fa 100%);
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(232, 138, 159, .1), 0 0 0 1px rgba(232, 138, 159, .08);
    overflow: hidden;
  }
  .pet-panel-sidebar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px 12px;
    border-bottom: 1px solid #f5e8ed;
    background: linear-gradient(180deg, #fff8fa 0%, transparent 100%);
  }
  .pet-panel-app-icon {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(135deg, #f8b8cc 0%, #e888a8 100%);
    box-shadow: 0 2px 8px rgba(232, 136, 168, .3);
  }
  .pet-panel-app-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }
  .pet-panel-app-info { flex: 1; min-width: 0; }
  .pet-panel-app-name {
    font-size: 13px;
    font-weight: 600;
    color: #c46a82;
    margin-bottom: 2px;
  }
  .pet-panel-app-ver {
    font-size: 10px;
    color: #b08898;
  }
  .pet-panel-nav {
    flex: 1;
    padding: 10px 8px;
    overflow-y: auto;
  }
  .pet-panel-nav-item {
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: #8a7580;
    cursor: pointer;
    transition: all .25s cubic-bezier(.4, 0, .2, 1);
  }
  .pet-panel-nav-item:hover {
    background: rgba(232, 138, 159, .08);
    color: #c46a82;
    transform: translateX(2px);
  }
  .pet-panel-nav-item.is-active {
    background: linear-gradient(135deg, #f5a5b8 0%, #e88a9f 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(232, 138, 159, .35);
    transform: translateX(2px);
  }

  .pet-panel-head { display: none; }
  .pet-panel-main {
    background: linear-gradient(180deg, #fff 0%, #fffbfc 100%);
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(232, 138, 159, .1), 0 0 0 1px rgba(232, 138, 159, .08);
    overflow: hidden;
  }
  .pet-panel-content { padding: 18px 20px; }

  /* One module at a time, switched by the sidebar */
  .pet-panel-module { display: none; }
  .pet-panel-module.is-active { display: block; }

  /* Scrollbars, like the desktop panel */
  .pet-panel-nav::-webkit-scrollbar,
  .pet-panel-content::-webkit-scrollbar { width: 6px; }
  .pet-panel-nav::-webkit-scrollbar-track,
  .pet-panel-content::-webkit-scrollbar-track { background: transparent; }
  .pet-panel-nav::-webkit-scrollbar-thumb,
  .pet-panel-content::-webkit-scrollbar-thumb {
    background: #f0c8d4;
    border-radius: 3px;
  }
}
