/* ==========================================================================
   Probably Peter: Official Design Language (BE Teach)
   Ref: DESIGN_LANGUAGE.md
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Chewy&family=Zen+Maru+Gothic:wght@500;700;900&display=swap');

:root {
  --yellow: #FEC202;      /* primary buttons (sampled from Canva) */
  --yellow-soft: #FADA69; /* active / current page (sampled) */
  --cream: #FFF1BF;       /* chips, subtle fills */
  --ink: #262626;         /* text, outlines, shadows */
  --muted: #4A4A4A;       /* secondary text */
  --paper: #FFFFFF;       /* page and card background */
  --blue: #34ADDB;        /* bunting accent only */
  --orange: #F2603A;      /* bunting accent only */
  --focus: #1D7FA6;       /* focus ring */

  --border: 3px solid var(--ink);
  --r-btn: 14px;
  --r-tile: 18px;
  --r-card: 28px;
  --r-pill: 99px;
  --border-heavy: 4px solid #000; /* cards only */
  --shadow-btn: 3px 3px 0 #262626, 4px 4px 0 #4E4E4E, 7px 7px 0 #262626; /* stepped "double" shadow */
  --shadow-card: 5px 5px 0 #000;   /* solid block; merges with the outline */
  --shadow-small: 2px 2px 0 #262626, 3px 3px 0 #4E4E4E, 5px 5px 0 #262626;
  --font-display: 'Chewy', 'Zen Maru Gothic', sans-serif;
  --font-body: 'Zen Maru Gothic', system-ui, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--paper);
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Accessibility & Utility */
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Layout container */
.page-wrap {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  box-sizing: border-box;
  padding: 0 24px 60px;
}

/* Decorative background art (rule: grey art, do not lower opacity, place in gutters) */
.deco {
  position: absolute;
  z-index: 0;
  pointer-events: none;
  user-select: none;
}

/* Corner Bunting Garland (exact orientation from Canva BE Teach home slide) */
.deco-bunting--left {
  top: -10px;
  left: -36px;
  width: 28%;
  max-width: 380px;
  transform: rotate(-62deg);
}

.deco-bunting--right {
  top: -10px;
  right: -10px;
  width: 28%;
  max-width: 380px;
  transform: rotate(57deg) scaleX(-1);
}

/* Home Page Bottom Corner Mascots (Anchored to bottom edge, static, home page only) */
.deco-home-mascot--left {
  position: absolute;
  left: 8px;
  bottom: 0;
  width: 105px;
  pointer-events: none;
  z-index: 1;
}

.deco-home-mascot--right {
  position: absolute;
  right: 8px;
  bottom: 0;
  width: 140px;
  pointer-events: none;
  z-index: 1;
}

.deco--rotatable {
  transition: opacity 0.4s ease-in-out, transform 0.4s ease-in-out;
}

.deco--fading {
  opacity: 0 !important;
  transform: scale(0.92);
}

/* Buttons */
.btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 8px 22px;
  box-sizing: border-box;
  background: var(--yellow);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-btn);
  font: 900 17px var(--font-body);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.btn small {
  font-size: 13px;
  font-weight: 500;
}

.btn:hover {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn:active {
  transform: translate(5px, 5px);
  box-shadow: 0 0 0 var(--ink);
}

.btn--hub {
  min-height: 56px;
  padding: 8px 14px;
  font-size: 17px;
  border-radius: 14px;
  box-shadow: 3px 3px 0 #262626, 4px 4px 0 #4E4E4E, 7px 7px 0 #262626;
}

.btn--hub small {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
}

.btn--white, .btn.w {
  background: var(--paper);
}

.btn[aria-current="page"], .btn.is-on, .btn.on {
  background: var(--yellow-soft);
}

/* Go Button */
.go {
  display: inline-block;
  align-self: flex-start;
  min-height: 44px;
  box-sizing: border-box;
  padding: 8px 16px;
  background: var(--yellow);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: var(--shadow-small);
  font: 700 15px/24px var(--font-body);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.go:hover {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* Chips */
.chip {
  display: inline-block;
  padding: 3px 10px;
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: var(--r-pill);
  font: 700 13px var(--font-body);
}

/* Filter Button */
.fb {
  min-height: 44px;
  padding: 8px 18px;
  background: var(--paper);
  border: var(--border);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-btn);
  font: 700 16px var(--font-body);
  color: var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}

.fb:hover {
  transform: translate(2px, 2px);
}

.fb.is-on, .fb.on {
  background: var(--yellow-soft);
}

/* Search Bar (section 4c) */
.search {
  box-sizing: border-box;
  width: 100%;
  max-width: 280px;
  min-height: 50px;
  padding: 8px 20px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--r-btn);
  box-shadow: var(--shadow-btn);
  font: 700 17px var(--font-body);
}

.search::placeholder {
  color: var(--muted);
}

/* Form inputs & textareas (BE Teach aesthetic) */
.form-input, .form-select, .form-textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 10px 16px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--r-btn);
  box-shadow: 2px 2px 0 var(--ink);
  font: 700 15px var(--font-body);
  transition: all .1s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: #FFFBEB;
  box-shadow: 3px 3px 0 var(--ink);
  transform: translateY(-1px);
}

.form-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font: 700 14px var(--font-body);
  color: var(--ink);
  text-align: left;
}

/* Card Component (section 4c: 4px solid #000 + 5px 5px 0 #000 block shadow) */
.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--paper);
  border: var(--border-heavy);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}

.card h3 {
  margin: 0;
  font-size: 21px;
}

.card p {
  margin: 0;
  line-height: 1.5;
}

.shot {
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: var(--r-btn);
  font: 700 14px var(--font-body);
  overflow: hidden;
  padding: 8px;
}

.shot img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}

/* Card screenshot tints */
.shot--orange { background: #FED7AA; }
.shot--purple { background: #E9D5FF; }
.shot--violet { background: #DDD6FE; }
.shot--amber  { background: #FDE68A; }
.shot--sky    { background: #BAE6FD; }
.shot--green  { background: #BBF7D0; }

.meta {
  font: 700 13px var(--font-body);
  color: var(--muted);
}

/* Tile Component (Grids) */
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: var(--paper);
  color: var(--ink);
  border: var(--border);
  border-radius: var(--r-tile);
  box-shadow: var(--shadow-btn);
  font-size: 15px;
  line-height: 1.5;
  text-decoration: none;
  transition: transform .1s, box-shadow .1s;
}

.tile b {
  font-size: 19px;
}

.tile:hover {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 var(--ink);
}

/* Headings and Rows */
.h2 {
  margin: 0 0 14px;
  padding-bottom: 6px;
  border-bottom: var(--border);
  font-size: 26px;
  font-weight: 900;
}

.feed-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 14px 0;
  border-bottom: 2px solid var(--ink);
}

/* Pure CSS Multilingual Cycling Welcome (section 6) */
.cyc {
  position: relative;
  height: 44px;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 44px;
  text-align: center;
}

.cyc span {
  position: absolute;
  inset: 0;
  opacity: 0;
  animation: cyc 24s infinite;
}

@keyframes cyc {
  0% { opacity: 0; transform: translateY(8px); }
  2%, 10% { opacity: 1; transform: none; }
  12.5%, 100% { opacity: 0; }
}

/* Home Compact Layout (Fits screen with no unnecessary vertical scrolling) */
.home-main {
  position: relative;
  max-width: 820px;
  margin: 0 auto;
  padding-top: 20px;
  text-align: center;
}

.home-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.5px;
}

.home-subtitle {
  margin: 4px auto 0;
  max-width: 680px;
  font-size: 14.5px;
  line-height: 1.4;
  color: var(--muted);
  white-space: nowrap;
}

.home-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.home-feed {
  margin-top: 14px;
  text-align: left;
}

.home-feed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  flex-wrap: wrap;
  gap: 8px;
}

.home-feed .h2 {
  margin: 0;
  font-size: 19px;
  padding-bottom: 0;
}

.feed-filters {
  display: flex;
  gap: 5px;
  align-items: center;
}

.feed-filter {
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--r-btn);
  font: 700 11px var(--font-body);
  color: var(--ink);
  padding: 3px 8px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: transform .1s, box-shadow .1s, background .1s;
}

.feed-filter:hover {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--ink);
}

.feed-filter.is-active {
  background: var(--yellow);
}

.feed-row--compact {
  padding: 5px 0;
  gap: 8px 12px;
  font-size: 13px;
  border-bottom: 2px solid var(--ink);
  transition: background .2s;
}

.feed-row--compact.is-hidden {
  display: none !important;
}

/* Maintenance Alert Banner Row */
.feed-row--alert {
  background: #FEF3C7;
  border: 2px solid var(--ink);
  border-radius: var(--r-btn);
  padding: 6px 10px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-btn);
  animation: feedAlertPulse 2s infinite ease-in-out;
}

.feed-row--rebooting {
  background: #FED7AA;
  border: 2px solid var(--ink);
  border-radius: var(--r-btn);
  padding: 6px 10px;
  margin-bottom: 6px;
  box-shadow: var(--shadow-btn);
}

@keyframes feedAlertPulse {
  0%, 100% { box-shadow: 2px 2px 0 var(--ink); }
  50% { box-shadow: 4px 4px 0 var(--ink); transform: translateY(-1px); }
}

/* Category Specific Chips */
.chip--system { background: #FEF08A; }
.chip--alert { background: #FECACA; color: #991B1B; border-color: #991B1B; }
.chip--game { background: #BAE6FD; }
.chip--article { background: #E9D5FF; }
.chip--tool { background: #FED7AA; }

/* Simulation Toolbar for Testing */
.feed-sim-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px dashed var(--ink);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
}

.feed-sim-btn {
  background: var(--paper);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  padding: 2px 8px;
  font: 700 10.5px var(--font-body);
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--ink);
}

.feed-sim-btn:hover {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.feed-row--compact .chip {
  padding: 2px 8px;
  font-size: 11px;
}

.feed-row--compact .go {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12px;
  line-height: 18px;
  border-radius: 8px;
}

@media (max-width: 760px) {
  .home-subtitle {
    white-space: normal;
  }
  .home-nav {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .home-nav {
    grid-template-columns: 1fr;
  }
}

/* Arrow buttons (section 4c: pure CSS arrows) */
.arrow {
  width: 44px;
  height: 96px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.arrow::before {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.arrow--next::before {
  transform: scaleX(-1);
}

/* Persistent Bottom Tab Bar (section 4) */
.tabbar {
  position: sticky;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom, 0px));
  background: var(--cream);
  border-top: none;
}

/* Carousel Stage with Side Arrows (Canva Slides 4, 5, 6) */
.carousel-stage {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.carousel-arrow {
  flex: none;
  width: 44px;
  height: 96px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
  z-index: 10;
  user-select: none;
}

.carousel-arrow img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.carousel-arrow:hover {
  transform: scale(1.1);
}

.carousel-arrow:active {
  transform: scale(0.92);
}

.carousel-arrow--prev:hover {
  transform: translateX(-4px) scale(1.1);
}

.carousel-arrow--next img {
  transform: scaleX(-1);
}

.carousel-arrow--next:hover {
  transform: translateX(4px) scale(1.1);
}

.carousel-track {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 24px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 6px 10px 22px 6px;
  scrollbar-width: none;
}

.carousel-track::-webkit-scrollbar {
  display: none;
}

.carousel-track .card {
  flex: 0 0 min(400px, 80%);
  scroll-snap-align: start;
}

.hdr, header.hdr, header, footer, .site-footer {
  background: transparent !important;
  border: none !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
}

/* Responsive Rules (section 5) */
@media (max-width: 760px) {
  .deco {
    display: none;
  }
  .cyc {
    font-size: 38px;
    height: 60px;
    line-height: 60px;
  }
  .hdr {
    grid-template-columns: 1fr !important;
  }
  .hdr > * {
    justify-self: center !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .tile, .go, .fb {
    transition: none;
  }
  .btn:hover, .btn:active, .tile:hover, .go:hover {
    transform: none;
  }
  .cyc span {
    animation: none;
  }
  .cyc span:first-child {
    opacity: 1;
  }
}
