/* ===========================
   Robert Start Player — Global Styles
   =========================== */

/* --- Custom Properties --- */
:root {
  /* Colours */
  --color-bg: #fafafa;
  --color-text: #1a1a1a;
  --color-accent: #c0392b;        /* Red — links, highlights, meeple */
  --color-accent-hover: #922b21;
  --color-muted: #555;
  --color-border: #e0e0e0;
  --color-surface: #ffffff;

  /* Typography */
  --font-body: 'Atkinson Hyperlegible', sans-serif;
  --font-size-base: 1.125rem;     /* 18px */
  --line-height: 1.6;

  /* Spacing */
  --space-xs: 0.5rem;
  --space-sm: 1rem;
  --space-md: 2rem;
  --space-lg: 3rem;
  --space-xl: 5rem;

  /* Layout */
  --max-width: 52rem;
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3 {
  line-height: 1.2;
  margin-bottom: var(--space-sm);
}

h1 {
  font-size: 2.25rem;
}

h2 {
  font-size: 1.5rem;
}

p {
  margin-bottom: var(--space-sm);
}

a {
  color: var(--color-accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover,
a:focus {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* --- Header & Nav --- */
.site-header {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  text-decoration: none;
}

.site-title:hover {
  color: var(--color-accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  gap: var(--space-md);
  list-style: none;
}

.site-nav a {
  font-weight: 500;
}

/* --- Main Content --- */
main {
  flex: 1;
  padding: 1.5rem 0;
}

/* --- Footer --- */
.site-footer {
  padding: var(--space-md) 0;
  border-top: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.875rem;
  text-align: center;
}

/* --- Utility --- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Section Header (title + sort aligned) --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.section-header h2 {
  margin-bottom: 0;
}

/* --- Filter Controls (toggle + sort) --- */
.filter-controls {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.demo-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.demo-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.demo-toggle-label {
  white-space: nowrap;
}

/* --- Sort Dropdown --- */
.sort-dropdown {
  position: relative;
}

.sort-toggle {
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.sort-toggle:hover,
.sort-toggle:focus {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.sort-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 0.35rem);
  min-width: 10rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  list-style: none;
  padding: 0.35rem 0;
  z-index: 10;
}

.sort-menu.open {
  display: block;
}

.sort-menu [role="option"] {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sort-menu [role="option"]:hover {
  background-color: var(--color-bg);
}

.sort-menu [role="option"][aria-selected="true"] {
  font-weight: 700;
  color: var(--color-accent);
}

/* --- Game Grid --- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-top: var(--space-md);
}

@media (max-width: 600px) {
  .game-grid {
    grid-template-columns: 1fr;
  }
}

.game-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface);
  text-decoration: none;
  color: var(--color-text);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.game-card:hover,
.game-card:focus {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  text-decoration: none;
  color: var(--color-text);
}

.game-card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background-color: var(--color-border);
  object-fit: cover;
}

/* --- Demo Banner (top-right corner ribbon) --- */
.game-card[data-demo="true"] {
  position: relative;
}

.game-card[data-demo="true"]::after {
  content: "Demo\a Available";
  position: absolute;
  top: 14px;
  right: -44px;
  width: 170px;
  padding: 7px 0;
  background-color: var(--color-accent);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.4;
  white-space: pre;
  transform: rotate(45deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  z-index: 1;
  pointer-events: none;
}

.game-card-title {
  padding: var(--space-sm) var(--space-sm) 0;
  font-weight: 700;
  text-align: center;
}

.game-card-info {
  padding: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.game-card-info .game-card-title {
  padding: 0;
  text-align: left;
}

.game-card-meta {
  font-size: 0.875rem;
  color: var(--color-muted);
  font-weight: 500;
}

.game-card-theme {
  font-size: 0.875rem;
  line-height: 1.4;
}

/* --- Game Page --- */
.game-page h1 {
  margin-bottom: var(--space-xs);
}

.game-tagline {
  color: var(--color-muted);
  font-size: 1.125rem;
  margin-bottom: var(--space-lg);
}

.game-section {
  margin-bottom: var(--space-lg);
}

.game-section h2 {
  margin-bottom: var(--space-sm);
}

.game-sellsheet {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  border: 1px solid var(--color-border);
}

.game-rules-link {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 2px solid var(--color-accent);
  border-radius: 4px;
  font-weight: 700;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.game-rules-link:hover,
.game-rules-link:focus {
  background-color: var(--color-accent);
  color: #fff;
  text-decoration: none;
}

/* Responsive video/demo embeds */
.video-embed,
.demo-embed {
  position: relative;
  width: 100%;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.video-embed iframe,
.demo-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* --- Game Hero Image --- */
.game-hero {
  margin-bottom: var(--space-lg);
}

.game-hero-image {
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

.game-hero-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: var(--color-border);
  border-radius: 8px;
}

/* --- Play Now Button --- */
.play-button {
  display: inline-block;
  padding: 1rem 2rem;
  background-color: var(--color-accent);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.play-button:hover,
.play-button:focus {
  background-color: var(--color-accent-hover);
  color: #fff;
  text-decoration: none;
  transform: scale(1.02);
}

.play-button-disabled {
  display: inline-block;
  padding: 1rem 2rem;
  background-color: var(--color-border);
  color: var(--color-muted);
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  cursor: not-allowed;
  opacity: 0.7;
}

/* --- About Page --- */
.about-intro {
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
  margin-bottom: var(--space-md);
  text-align: left;
}

.about-avatar {
  width: 10rem;
  height: 10rem;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--color-border);
  flex-shrink: 0;
}

.about-section {
  margin-bottom: var(--space-lg);
}

.about-section h2 {
  margin-bottom: var(--space-sm);
}

.about-links {
  list-style: none;
  padding: 0;
  display: flex;
  gap: var(--space-md);
}

.about-links a {
  font-weight: 700;
}

@media (max-width: 768px) {
  .about-intro {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .about-avatar {
    align-self: center;
  }
}
