/* Bear Resort skeuomorphic layer — load after style.css; do not edit style.css */

/* ── Light source: top-left (~135deg) ── */
:root {
  --skeuo-light: rgba(255, 255, 255, 0.45);
  --skeuo-shadow-contact: 0 1px 2px rgba(0, 0, 0, 0.45);
  --skeuo-shadow-ambient: 0 4px 14px rgba(0, 0, 0, 0.18);
  --skeuo-shadow-lifted: 0 6px 18px rgba(0, 0, 0, 0.22);
  --skeuo-inset: inset 0 2px 5px rgba(0, 0, 0, 0.25);
  --skeuo-rim: inset 0 1px 0 var(--skeuo-light);
}

/* ── Default layout: responsive content images ── */
body:has(.topnav-corner) #content img:not(.app-icon):not(.meme-image):not(.sister-site-icon) {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Section hero logos (mathland, archive, etc.) — keep natural proportions */
#content h1 img {
  width: auto;
  max-width: min(100%, 340px);
  height: auto;
  max-height: 250px;
  object-fit: contain;
  display: inline-block;
  vertical-align: middle;
}

.topnav.topnav-corner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  right: auto;
  width: auto;
  margin: 0;
  max-height: none;
  overflow: visible;
}

.topnav.topnav-corner a {
  padding: 4px 8px;
}

body:has(.topnav-corner) #login {
  top: 0;
  right: 3px;
  border-radius: 10px;
}

body:has(.topnav-corner) #day-night {
  bottom: 0;
  left: 3px;
  border-radius: 10px;
}

body:has(.topnav-corner) #lang {
  bottom: 0;
  right: 3px;
  border-radius: 10px;
}

body:has(.topnav-corner) #content:not(:has(.register-page)):not(:has(.rush-page)):not(:has(.emoji-page)) {
  box-sizing: border-box;
  padding: 56px 52px 52px;
  max-width: 100%;
}

/* Full-page immersive tools (register, bear rush) */
body:has(.register-page) #content:has(.register-page) {
  position: fixed;
  top: var(--register-top, 49px);
  bottom: var(--register-bottom, 37px);
  left: 3px;
  right: 3px;
  max-width: none;
  margin: 0;
  padding: 0 4px;
  overflow: hidden;
}

body:has(.rush-page) #content:has(.rush-page) {
  position: fixed;
  top: var(--rush-top, 49px);
  bottom: var(--rush-bottom, 37px);
  left: 3px;
  right: 3px;
  max-width: none;
  margin: 0;
  padding: 0 4px;
  overflow: hidden;
}

body:has(.emoji-page) #content:has(.emoji-page) {
  position: fixed;
  top: var(--register-top, 49px);
  bottom: var(--register-bottom, 37px);
  left: 3px;
  right: 3px;
  max-width: none;
  margin: 0;
  padding: 0 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body:has(.emoji-page) .emoji-page {
  flex: 1;
  min-height: 0;
}

body:has(.register-page) #content:has(.register-page) > br,
body:has(.rush-page) #content:has(.rush-page) > br,
body:has(.rush-page) #content:has(.rush-page) #ttl {
  display: none;
}

html:has(.register-page),
html:has(.rush-page),
html:has(.emoji-page),
body:has(.register-page),
body:has(.rush-page),
body:has(.emoji-page) {
  overflow: hidden;
  height: 100%;
}

/* Exam layout images */
body:has(#exam-container) #content img {
  max-width: 75%;
  height: auto;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* ── Utility classes ── */
.skeuo-raised {
  box-shadow:
    var(--skeuo-rim),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
}

.skeuo-inset {
  box-shadow:
    var(--skeuo-inset),
    inset 0 -1px 0 var(--skeuo-light);
}

.skeuo-card {
  background: linear-gradient(
    165deg,
    var(--background-light) 0%,
    var(--background-color) 100%
  );
  border: 1px solid var(--secondary-light);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow:
    var(--skeuo-rim),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
}

.img-shadow {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35))
    drop-shadow(0 6px 12px rgba(0, 0, 0, 0.15));
}

/* ── Buttons (enhance style.css) ── */
button {
  position: relative;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
}

button:hover:not(:disabled) {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.45),
    var(--skeuo-shadow-lifted);
}

button:active:not(:disabled) {
  box-shadow:
    inset 0 3px 6px rgba(0, 0, 0, 0.45),
    inset 0 -1px 0 rgba(255, 255, 255, 0.15),
    0 1px 2px rgba(0, 0, 0, 0.35);
}

#close-modal-btn {
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

#close-modal-btn:active {
  box-shadow: var(--skeuo-inset);
  transform: translateY(1px);
}

.choice-item button {
  background: linear-gradient(to bottom, #f5f5f5 0%, #e8e8e8 100%);
  border: 1px solid #ccc;
  color: var(--text-color-dark);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.15);
}

.choice-item button:hover:not(:disabled) {
  background: linear-gradient(to bottom, #fff 0%, #eee 100%);
}

.choice-item button.active,
.choice-item button:active:not(:disabled) {
  background: linear-gradient(to bottom, #6abf69 0%, #4a9a49 100%);
  border-color: #3d8040;
  color: #fff;
  box-shadow: var(--skeuo-inset);
}

/* ── Inputs & textarea (recessed) ── */
input:not([type='checkbox']):not([type='radio']):not([type='range']),
textarea {
  border: 1px solid var(--secondary-light);
  box-shadow:
    var(--skeuo-inset),
    0 1px 0 var(--skeuo-light);
  background: linear-gradient(to bottom, #eee 0%, var(--background-light) 12%);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--main-color-light);
  box-shadow:
    var(--skeuo-inset),
    0 0 0 2px rgba(226, 207, 114, 0.35);
}

/* ── Toggle switches ── */
.switch .slider {
  background: linear-gradient(to bottom, #a8a6a5 0%, #bebdbc 40%, #d4d2d1 100%);
  box-shadow:
    var(--skeuo-inset),
    0 1px 0 var(--skeuo-light);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.switch .slider:before {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    0 2px 5px rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(0, 0, 0, 0.2);
}

input:checked + .slider {
  background: linear-gradient(to bottom, #c9b44a 0%, #e2cf72 45%, #edd98a 100%);
}

/* ── Alert modal ── */
#result-modal {
  backdrop-filter: blur(4px);
  background: rgba(0, 0, 0, 0.45);
}

#result-box {
  border: 2px solid var(--secondary-light);
  box-shadow:
    inset 0 1px 0 var(--skeuo-light),
    0 12px 40px rgba(0, 0, 0, 0.35),
    0 4px 12px rgba(0, 0, 0, 0.2);
  background: linear-gradient(
    165deg,
    var(--background-light) 0%,
    var(--background-color) 100%
  );
}

/* ── Fixed chrome ── */
#login,
#lang,
#day-night,
#dynamic-island,
#timer {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
}

.topnav a.active {
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 -1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(1px);
}

/* ── Category tabs (apps, chars) ── */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.category-tab {
  font-family: var(--font-family);
  font-size: 0.9rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--secondary-light);
  background: linear-gradient(to bottom, var(--background-light) 0%, var(--background-color) 100%);
  color: var(--text-color);
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 var(--skeuo-light),
    0 2px 4px rgba(0, 0, 0, 0.12);
  transition: all 0.15s ease;
}

.category-tab:hover {
  background: linear-gradient(to bottom, var(--secondary-light) 0%, var(--background-light) 100%);
}

.category-tab.active {
  background: linear-gradient(to bottom, var(--main-color-light) 0%, var(--main-color) 100%);
  border-color: var(--main-color);
  color: var(--secondary-color);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.25),
    0 1px 2px rgba(0, 0, 0, 0.2);
  transform: translateY(1px);
}

/* ── App store ── */
.app-store-shell {
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.app-store-header {
  text-align: center;
  margin-bottom: 1rem;
}

.app-search-wrap {
  margin-bottom: 1.25rem;
}

.app-search {
  box-sizing: border-box;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--secondary-light);
  border-radius: 10px;
  background: var(--background-light);
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.95rem;
}

.app-store {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.app-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 0.75rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--secondary-light);
  border-radius: 10px;
  width: 100%;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.app-row:hover {
  transform: translateY(-1px);
  box-shadow:
    inset 0 1px 0 var(--skeuo-light),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
  background: linear-gradient(
    165deg,
    rgba(255, 255, 255, 0.04) 0%,
    transparent 100%
  );
}

.app-row:last-child {
  border-bottom: none;
}

.app-row[hidden] {
  display: none;
}

.app-no-results {
  display: none;
  text-align: center;
  color: var(--text-color);
  opacity: 0.75;
  margin: 1.5rem 0 0;
  font-size: 0.95rem;
}

.app-no-results.visible {
  display: block;
}

.app-row-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
}

.app-icon {
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  flex-shrink: 0;
  display: block;
  margin: 0;
  object-fit: cover;
  border-radius: 12px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35))
    drop-shadow(0 5px 10px rgba(0, 0, 0, 0.12));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.app-icon-frame {
  width: 56px;
  height: 56px;
  min-width: 56px;
  max-width: 56px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--secondary-light) 0%, var(--background-color) 100%);
  box-shadow:
    var(--skeuo-rim),
    var(--skeuo-shadow-contact),
    var(--skeuo-shadow-ambient);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.app-icon-frame .app-icon-photo {
  width: 100%;
  height: 100%;
  min-width: 0;
  max-width: 100%;
  object-fit: contain;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 0;
  box-shadow: none;
  filter: none;
  background: transparent;
}

.app-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.app-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text-color);
  margin: 0 0 0.2rem;
  line-height: 1.3;
}

.app-desc {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.75;
  margin: 0;
  line-height: 1.35;
  text-align: left;
}

.app-open {
  flex-shrink: 0;
  align-self: center;
  padding: 0.35rem 1.1rem;
  border-radius: 999px;
  background: linear-gradient(to bottom, var(--secondary-color) 0%, var(--secondary-light) 100%);
  color: var(--main-color);
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  text-align: center;
  min-width: 56px;
  border: 1px solid var(--secondary-light);
  transition: all 0.15s ease;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    var(--skeuo-shadow-contact),
    0 2px 6px rgba(0, 0, 0, 0.12);
}

.app-open:hover {
  background: linear-gradient(to bottom, var(--secondary-light) 0%, var(--secondary-color) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 3px 8px rgba(0, 0, 0, 0.2);
}

.app-open:active {
  transform: translateY(2px);
  box-shadow: var(--skeuo-inset);
}

.app-open.external-link::after {
  content: ' ↗';
  font-size: 0.75em;
  opacity: 0.7;
}

/* ── Sister sites (archive) ── */
.sister-sites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.sister-site-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease;
}

.sister-site-card:hover {
  transform: translateY(-2px);
}

.sister-site-card .skeuo-card {
  height: 100%;
}

.sister-site-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.sister-site-name {
  font-weight: 600;
  margin: 0;
}

.sister-site-desc {
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 0;
}

@media (max-width: 500px) {
  .app-row {
    gap: 0.75rem;
  }

  .app-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    max-width: 48px;
    border-radius: 10px;
  }

  .app-icon-frame {
    width: 48px;
    height: 48px;
    min-width: 48px;
    max-width: 48px;
    border-radius: 10px;
  }

  .app-icon-frame .app-icon-photo {
    padding: 4px;
  }

  .app-name {
    font-size: 0.95rem;
  }

  .app-desc {
    font-size: 0.8rem;
  }

  .app-open {
    padding: 0.3rem 0.85rem;
    font-size: 0.8rem;
    min-width: 48px;
  }
}
