/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Hide Lisa window chrome in fullscreen (real Fullscreen API or the
   .pseudo-fullscreen fallback class used on iOS, which lacks
   requestFullscreen support for non-video elements). These must beat
   the later body[data-theme="lisa"] frame rules, which share the same
   specificity and would otherwise win by source order. */
:fullscreen .lisa-window-bar,
:fullscreen .lisa-window-bottom-bar,
:-webkit-full-screen .lisa-window-bar,
:-webkit-full-screen .lisa-window-bottom-bar,
html.pseudo-fullscreen .lisa-window-bar,
html.pseudo-fullscreen .lisa-window-bottom-bar {
  display: none !important;
}

:fullscreen .lisa-window-frame,
:-webkit-full-screen .lisa-window-frame,
html.pseudo-fullscreen .lisa-window-frame {
  position: static !important;
  inset: auto !important;
  max-width: none !important;
  max-height: none !important;
  border: none !important;
  box-shadow: none !important;
}

:fullscreen .lisa-window-content,
:-webkit-full-screen .lisa-window-content,
html.pseudo-fullscreen .lisa-window-content {
  display: contents !important;
}

html.pseudo-fullscreen {
  overflow: hidden;
}

/* Lisa theme global overrides */
body[data-theme="lisa"] {
  --bg: #ffffff;
  --green: #000000;
  --dim: #555555;
  --mono: "Geneva", "Charcoal", "Chicago", Arial, sans-serif;
  background-color: #aaaaaa !important;
  background-image: radial-gradient(circle, #888888 1px, transparent 1px) !important;
  background-size: 4px 4px !important;
  color: #000000 !important;
  font-family: "Geneva", "Charcoal", "Chicago", Arial, sans-serif !important;
}

html:has(body[data-theme="lisa"]) {
  background-color: #aaaaaa !important;
  background-image: radial-gradient(circle, #888888 1px, transparent 1px) !important;
  background-size: 4px 4px !important;
}

body[data-theme="lisa"] * {
  color: #000000;
  border-color: #000000;
  text-shadow: none !important;
}

body[data-theme="lisa"] a {
  color: #000000;
}

body[data-theme="lisa"] button,
body[data-theme="lisa"] input[type="submit"],
body[data-theme="lisa"] .btn-tui,
body[data-theme="lisa"] [class*="btn"] {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #000000 !important;
  font-family: "Geneva", "Charcoal", "Chicago", Arial, sans-serif !important;
}

body[data-theme="lisa"] button:hover,
body[data-theme="lisa"] input[type="submit"]:hover,
body[data-theme="lisa"] .btn-tui:hover,
body[data-theme="lisa"] [class*="btn"]:hover {
  background: #000000 !important;
  color: #ffffff !important;
}

body[data-theme="lisa"] .app-version-footer {
  color: #000000;
  background: #ffffff;
}

body[data-theme="lisa"] .app-version-footer a {
  color: #000000;
}

body[data-theme="lisa"] #exit-fs-btn {
  background: #ffffff !important;
  color: #000000 !important;
  border: 1px solid #000000 !important;
}

/* Lisa window frame wrapper */
.lisa-window-frame {
  display: contents;
}

.lisa-window-content {
  display: contents;
}

.lisa-window-bottom-bar {
  display: none;
}

body[data-theme="lisa"] .lisa-window-frame {
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 40px;
  max-width: 900px;
  max-height: 900px;
  margin: auto;
  border: 3px solid #000000;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 4px 4px 0 #888888;
}

body[data-theme="lisa"].home-page .lisa-window-frame {
  display: contents;
  position: static;
  inset: auto;
  border: none;
  box-shadow: none;
}

body[data-theme="lisa"] .lisa-window-content {
  display: block;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px;
}

@media (max-width: 640px) {
  body[data-theme="lisa"].play-page .lisa-window-frame {
    inset: 20px;
  }

  body[data-theme="lisa"].play-page .lisa-window-content {
    padding: 6px;
  }
}

/* Lisa window title bar */
body[data-theme="lisa"] .lisa-window-bar {
  display: flex;
  align-items: center;
  height: 22px;
  min-height: 22px;
  background: #ffffff;
  border-bottom: 2px solid #000000;
  font-family: "Geneva", "Charcoal", "Chicago", Arial, sans-serif;
  font-size: 12px;
  font-weight: bold;
  color: #000000;
  user-select: none;
  flex-shrink: 0;
}

.lisa-window-bar {
  display: none;
}

body[data-theme="lisa"] .lisa-window-bar-stripe {
  flex: 1;
  height: 100%;
  background-image: repeating-linear-gradient(
    180deg,
    #000000 0px, #000000 1px,
    #ffffff 1px, #ffffff 3px
  );
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 4px;
}

body[data-theme="lisa"] .lisa-window-title {
  white-space: nowrap;
  padding: 0 10px;
  background: #ffffff;
  color: #000000;
  flex-shrink: 0;
}

body[data-theme="lisa"] .lisa-window-close {
  width: 14px;
  height: 14px;
  border: 1px solid #000000 !important;
  background: #ffffff !important;
  color: #000000 !important;
  font-size: 9px;
  text-align: center;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

body[data-theme="lisa"] .lisa-window-close:hover {
  background: #000000 !important;
  color: #ffffff !important;
}

/* Lisa window bottom bar */
body[data-theme="lisa"] .lisa-window-bottom-bar {
  display: block;
  height: 18px;
  min-height: 18px;
  border-top: 2px solid #000000;
  background-image: repeating-linear-gradient(
    180deg,
    #000000 0px, #000000 1px,
    #ffffff 1px, #ffffff 3px
  );
  flex-shrink: 0;
}

/* Chess board theming lives in app/views/shared/_board_styles.html.erb,
   the single source of truth shared by the replay and play boards. */

/* Hide footer inside the window frame on non-home Lisa pages */
body[data-theme="lisa"]:not(.home-page) .app-version-footer {
  display: none;
}

/* Hide back links in Lisa theme since the window close replaces them */
body[data-theme="lisa"] .back-link,
body[data-theme="lisa"] header a[href*="games"] {
  display: none !important;
}

/* Arcade theme: the neon "Chess Coins" skin. A third data-theme value alongside
   terminal and lisa. Like terminal, it does not use the Lisa window chrome. */
body[data-theme="arcade"] {
  --bg: #140033;
  --green: #ffd54a;
  --dim: #b39ddb;
  --amber: #ff4ecd;
  --mono: "Courier New", "DejaVu Sans Mono", monospace;
  background-color: #140033 !important;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255, 78, 205, 0.18), transparent 40%),
    radial-gradient(circle at 80% 30%, rgba(0, 229, 255, 0.15), transparent 40%) !important;
  color: #ffd54a !important;
  font-family: "Courier New", "DejaVu Sans Mono", monospace !important;
}

body[data-theme="arcade"] a {
  color: #00e5ff;
}

body[data-theme="arcade"] .btn-tui,
body[data-theme="arcade"] [class*="btn"] {
  color: #ffd54a;
  border-color: #ffd54a;
}

body[data-theme="arcade"] .btn-tui:hover,
body[data-theme="arcade"] [class*="btn"]:hover {
  background: #ffd54a;
  color: #140033;
}
