@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root{
  --bg1:#edf1f5;
  --bg2:#dde3ea;
  --bg3:#cfd6de;

  --panel:#ffffff;
  --panel2:#e8edf3;
  --panel3:#f6f8fb;

  --text:#1b1c1f;
  --muted:#5c6470;

  --line:rgba(0,0,0,.10);
  --line2:rgba(0,0,0,.16);

  --red:#df0000;
  --red2:#ff2a2a;
  --redGlow:0 0 10px rgba(255,0,0,.18);

  --max:1500px;
  --gap:6px;

  --shadow:0 10px 28px rgba(0,0,0,.08);
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
  color:var(--text);
  background:linear-gradient(180deg,var(--bg1),var(--bg2),var(--bg1));
}

body{
  font-size:14px;
  text-rendering:optimizeLegibility;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

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

img{
  max-width:100%;
  display:block;
}

/* =========================================================
   HERO / HEADER BLOCK
   ========================================================= */
.masthead-shell{
  max-width:var(--max);
  margin:12px auto 10px;
  padding:0 12px;
}

.masthead-box{
  padding:14px;
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line2);
  box-shadow:var(--shadow);
}

.masthead-topline{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  gap:14px;
  align-items:start;
}

.masthead-titlebox{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
  gap:10px;
  min-width:0;
  width:100%;
}

.masthead-title{
  display:block;
  width:100%;
  margin:0;
  padding:0;
  font-size:26px;
  font-weight:900;
  line-height:1.08;
  max-width:100%;
  color:var(--red);
  text-transform:uppercase;
  white-space:normal;
  overflow-wrap:anywhere;
  word-break:break-word;
  text-wrap:balance;
}

.masthead-copy{
  margin-top:10px;
}

.masthead-text{
  margin:0;
  max-width:900px;
  font-size:12px;
  line-height:1.55;
  color:var(--muted);
}

/* =========================================================
   BUTTONS / CHIPS
   ========================================================= */
.sorting-strip{
  margin-top:12px;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.sorting-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:40px;
  padding:8px 14px;
  background:linear-gradient(180deg,#fff,#e5ebf2);
  border:1px solid var(--line2);
  font-size:12px;
  font-weight:800;
  line-height:1;
  white-space:nowrap;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease, background .14s ease;
}

.sorting-chip:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

/* =========================================================
   LANGUAGE SWITCHER
   ========================================================= */
.locale-switcher{
  position:relative;
  width:auto;
  max-width:100%;
}

.locale-switcher summary{
  list-style:none;
}

.locale-switcher summary::-webkit-details-marker{
  display:none;
}

.locale-toggle{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:42px;
  padding:8px 12px;
  max-width:100%;
  white-space:nowrap;
  background:linear-gradient(180deg,#fff,#e5ebf2);
  border:1px solid var(--line2);
  font-size:12px;
  font-weight:800;
  cursor:pointer;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.locale-toggle:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

.locale-flag{
  width:18px;
  height:18px;
  object-fit:cover;
  flex:0 0 18px;
}

.locale-code{
  overflow:hidden;
  text-overflow:ellipsis;
}

.locale-caret{
  flex:0 0 auto;
  font-size:14px;
  line-height:1;
}

.locale-panel{
  position:absolute;
  right:0;
  top:calc(100% + 8px);
  width:560px;
  max-width:min(560px, calc(100vw - 24px));
  max-height:70vh;
  overflow:auto;
  -webkit-overflow-scrolling:touch;
  padding:10px;
  background:linear-gradient(180deg,#fff,#e7edf4);
  border:1px solid var(--line2);
  box-shadow:var(--shadow);
  display:none;
  z-index:9999;
}

.locale-switcher[open] .locale-panel{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:8px;
}

.locale-item{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-height:74px;
  padding:8px 6px;
  background:linear-gradient(180deg,#fff,#eef2f7);
  border:1px solid var(--line);
  font-size:11px;
  font-weight:800;
  text-align:center;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.locale-item:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

.locale-item img{
  width:24px;
  height:24px;
  object-fit:cover;
}

.locale-item span{
  max-width:100%;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* =========================================================
   MAIN GRID AREA
   ========================================================= */
.content-frame{
  max-width:var(--max);
  margin:14px auto 0;
  padding:0 12px;
}

.media-matrix{
  list-style:none;
  margin:0;
  padding:0;
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:var(--gap);
}

.tile-unit{
  margin:0;
  padding:0;
  min-width:0;
}

/* =========================================================
   THUMB CARD
   .thumb and .thumb-video preserved for JS
   ========================================================= */
.thumb{
  background:linear-gradient(180deg,var(--panel),var(--panel2));
  border:1px solid var(--line2);
  overflow:hidden;
  contain:layout paint;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.thumb:hover{
  transform:translateY(-1px);
  border-color:var(--red2);
  box-shadow:var(--redGlow);
}

.tile-link{
  position:relative;
  display:block;
  aspect-ratio:16/10;
  background:#d5dce4;
  overflow:hidden;
}

.tile-poster,
.thumb-video{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
}

.tile-poster{
  transition:opacity .14s ease;
}

.thumb-video{
  opacity:0;
  pointer-events:none;
  transition:opacity .14s ease;
}

.thumb:hover .tile-poster{
  opacity:0;
}

.thumb:hover .thumb-video{
  opacity:1;
}

.tile-time{
  position:absolute;
  top:6px;
  right:6px;
  padding:4px 7px;
  background:rgba(255,255,255,.92);
  border:1px solid var(--line2);
  color:#111;
  font-size:10px;
  font-weight:800;
  line-height:1;
}

.tile-playmark{
  position:absolute;
  bottom:6px;
  left:6px;
  width:34px;
  height:34px;
  background:rgba(255,255,255,.9);
  border:1px solid var(--line2);
  opacity:0;
  pointer-events:none;
  transition:opacity .14s ease, border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.tile-playmark::before{
  content:"";
  position:absolute;
  left:12px;
  top:9px;
  width:0;
  height:0;
  border-left:11px solid #111;
  border-top:7px solid transparent;
  border-bottom:7px solid transparent;
}

.thumb:hover .tile-playmark{
  opacity:1;
  transform:translateY(-1px);
  border-color:var(--red2);
  box-shadow:var(--redGlow);
}

.tile-meta{
  padding:8px 8px 9px;
  display:grid;
  gap:6px;
}

.tile-name{
  font-size:12px;
  font-weight:800;
  line-height:1.2;
  min-height:2.4em;
  max-height:2.4em;
  overflow:hidden;
  display:-webkit-box;
  -webkit-line-clamp:2;
  -webkit-box-orient:vertical;
}

.tile-taxonomy{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}

.tile-tag{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:24px;
  padding:4px 7px;
  background:linear-gradient(180deg,#fff,#eef2f7);
  border:1px solid var(--line);
  font-size:10px;
  font-weight:800;
  line-height:1;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.tile-tag:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

/* no preview fallback */
.thumb.no-preview .thumb-video{display:none!important}
.thumb.no-preview:hover .tile-poster{opacity:1!important}
.thumb.no-preview:hover .tile-playmark{opacity:0!important}

@media(hover:none) and (pointer:coarse){
  .thumb-video{display:none}
  .tile-playmark{display:none}
  .thumb:hover .tile-poster{opacity:1}
}

/* =========================================================
   PLAYER
   ========================================================= */
.player-section{
  max-width:var(--max);
  margin:10px auto 14px;
  padding:0 12px;
}

.player-box{
  position:relative;

  max-width:720px;      /* Ð±Ñ‹Ð»Ð¾ 980 â†’ ÑÑ‚Ð°Ð»Ð¾ ~Ð² 2 Ñ€Ð°Ð·Ð° Ð¼ÐµÐ½ÑŒÑˆÐµ */
  width:100%;

  margin:0 auto;

  aspect-ratio:16 / 9;

  background:linear-gradient(180deg,#f7f9fb,#dde3ea);
  border:1px solid var(--line2);
  box-shadow:var(--shadow);

  overflow:hidden;
}
@supports not (aspect-ratio: 16 / 9){
  .player-box{
    height:auto;
  }
  .player-box::before{
    content:"";
    display:block;
    padding-top:56.25%;
  }
  .player-box .player-video{
    position:absolute;
    inset:0;
  }
}

.player-video,
.player-box video{
  display:block;
  width:100%;
  height:100%;
  object-fit:contain;
  background:#d7dde4;
}

.player-tags{
  max-width:720px;
  margin:10px auto 0;
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

/* =========================================================
   PAGINATION
   ========================================================= */
.page-switcher{
  max-width:var(--max);
  margin:18px auto 8px;
  padding:0 12px;
}

.page-switcher-nav{
  display:flex;
  justify-content:center;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}

.page-switcher-btn{
  min-width:42px;
  height:42px;
  padding:0 12px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(180deg,#fff,#e5ebf2);
  border:1px solid var(--line2);
  font-size:13px;
  font-weight:800;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.page-switcher-btn:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

.page-switcher-btn.is-current{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
}

/* =========================================================
   BOTTOM TAG CLOUD
   ========================================================= */
.topic-cloud-wrap{
  max-width:var(--max);
  margin:14px auto 28px;
  padding:0 12px;
}

.topic-cloud{
  display:flex;
  flex-wrap:wrap;
  justify-content:center;
  gap:8px;
  padding:12px;
  background:linear-gradient(180deg,var(--panel3),var(--panel2));
  border:1px solid var(--line2);
}

.topic-cloud-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:28px;
  padding:6px 10px;
  background:linear-gradient(180deg,#fff,#eef2f7);
  border:1px solid var(--line);
  font-size:12px;
  font-weight:800;
  line-height:1;
  transition:border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.topic-cloud-link:hover{
  border-color:var(--red2);
  box-shadow:var(--redGlow);
  transform:translateY(-1px);
}

/* =========================================================
   LEGACY COMPATIBILITY
   ========================================================= */
.site-title-block,
.tag-hero,
.player-hero,
.hero,
.bottom-pagination,
.bottom-tags,
main[aria-label="Gallery list"],
main[aria-label="Tag videos"],
main[aria-label="More videos"]{
  max-width:var(--max);
  margin-left:auto;
  margin-right:auto;
}

.hero-title,
.tag-h1,
.video-h1,
.site-title-text{
  display:block;
  white-space:normal;
  word-break:break-word;
  overflow-wrap:anywhere;
  line-height:1.12;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width:1100px){
  .media-matrix{
    grid-template-columns:repeat(4,minmax(0,1fr));
  }

  .player-box,
  .player-tags{
    max-width:900px;
  }
}

@media (max-width:920px){
  .masthead-topline{
    grid-template-columns:1fr;
  }

  .locale-switcher{
    width:100%;
  }

  .locale-toggle{
    width:100%;
    justify-content:space-between;
  }

  .locale-panel{
    position:static;
    width:100%;
    max-width:100%;
    margin-top:8px;
    max-height:none;
  }

  .locale-switcher[open] .locale-panel{
    grid-template-columns:repeat(4,minmax(0,1fr));
    gap:8px;
  }

  .media-matrix{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }

  .masthead-title{
    font-size:23px;
  }
}

@media (max-width:640px){
  .masthead-box{
    padding:12px;
  }

  .masthead-title{
    font-size:20px;
    line-height:1.08;
  }

  .sorting-chip{
    min-height:38px;
    padding:8px 12px;
    font-size:11px;
  }

  .sorting-strip{
    gap:6px;
  }

  .locale-switcher[open] .locale-panel{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }

  .player-box,
  .player-tags{
    max-width:100%;
  }

  .media-matrix{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

@media (max-width:420px){
  .locale-switcher[open] .locale-panel{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .media-matrix{
    grid-template-columns:1fr;
  }
}