/* Magazine style layout */
:root {
  --mag-gap: 14px;
}

/* Smooth scroll behavior */
html.magazine-theme {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

@media (prefers-reduced-motion: reduce) {
  html.magazine-theme {
    scroll-behavior: auto;
  }
  .magazine *, .magazine *::before, .magazine *::after { 
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.magazine {
  background: #fff;
  color: #1a1a1a;
}

/* Base tokens, resets and utilities */
.magazine {
  --mag-fg: #111827;
  --mag-muted: #4a5568;
  --mag-card: #fff;
  --mag-card-border: rgba(0,0,0,.08);
  --mag-soft: #f2f2f2;
  --mag-radius: 12px;
  --mag-shadow: 0 6px 18px rgba(0,0,0,0.08);
  --mag-ring: 0 0 0 3px rgba(59,130,246,0.35);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Dark mode support */
.chakra-ui-dark .magazine {
  background: #0f1115;
  color: #e8eaf0;
  --mag-fg: #e8eaf0;
  --mag-muted: #a0aec0;
  --mag-card: #1a1d29;
  --mag-card-border: rgba(255,255,255,0.12);
  --mag-soft: #1a1f29;
  --mag-shadow: 0 6px 18px rgba(0,0,0,0.3);
}
.magazine *, .magazine *::before, .magazine *::after { box-sizing: border-box; }
.magazine img { max-width: 100%; display: block; }
.magazine a { color: inherit; text-decoration: none; transition: color .18s ease, background .18s ease, transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
.magazine a:focus-visible, .magazine button:focus-visible { outline: none; box-shadow: var(--mag-ring); border-radius: 8px; }
.magazine .muted { color: var(--mag-muted); }
.magazine .visually-hidden { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }

/* Two thin bars with club colors at the very top */
.mag-bars { height: 6px; display: grid; grid-template-columns: 1fr 1fr; }
.mag-bars .c1 { background: var(--primary); }
.mag-bars .c2 { background: var(--secondary); }

/* Centered container leaving corners empty */
.mag-container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }

/* Header area: colors + logo + name + nav */
.mag-header { display: flex; flex-direction: column; gap: 10px; padding: 16px 0 8px; }
.mag-header .club-colors { display: flex; gap: 6px; }
.mag-header .club-colors .swatch { width: 28px; height: 6px; border-radius: 999px; display: inline-block; }
.mag-header .brand { display: flex; align-items: center; gap: 12px; }
.mag-header .brand .logo { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: var(--bg-soft, #f2f2f2); border: 2px solid var(--primary); }
.mag-header .brand .name { margin: 0; font-size: 1.8rem; letter-spacing: .4px; }

/* Nav in club color */
.mag-nav { display: flex; gap: 8px; flex-wrap: wrap; background: var(--primary); color: var(--text-on-primary, #fff); border-radius: 10px; padding: 8px; }
.mag-nav .link { color: var(--text-on-primary, #fff); text-decoration: none; padding: 6px 10px; border-radius: 6px; transition: background .18s ease, transform .18s ease; }
.mag-nav .link:hover { background: color-mix(in srgb, var(--primary) 85%, #000); transform: translateY(-1px); }
.mag-nav .link:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(255,255,255,0.6); }

/* Hero: 3 cards with first larger */
.mag-hero { display: grid; grid-template-columns: 2fr 1fr; grid-auto-rows: 220px; gap: var(--mag-gap); margin: 16px 0 22px; }
.mag-card { 
  position: relative; 
  border-radius: var(--mag-radius); 
  overflow: hidden; 
  background: var(--mag-card); 
  min-height: 180px; 
  text-decoration: none; 
  color: inherit; 
  border: 1px solid var(--mag-card-border); 
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04); 
  transition: transform .25s ease-out, box-shadow .25s ease-out, border-color .25s ease-out;
  /* GPU acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
}
.mag-card:hover { 
  transform: translateY(-4px) scale(1.01) translateZ(0); 
  box-shadow: 0 16px 36px rgba(0,0,0,0.15), 0 6px 12px rgba(0,0,0,0.08); 
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}
.mag-card:focus-visible { 
  outline: 3px solid var(--primary); 
  outline-offset: 2px;
}
.mag-card.large { grid-row: span 2; }
.mag-card .bg { position: absolute; inset: 0; background-position: center; background-size: cover; filter: brightness(.85); }
.mag-card .overlay { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px; background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.3) 40%, rgba(0,0,0,0.75) 100%); color: var(--text-on-primary, #fff); transition: background 0.3s ease; }
.mag-card:hover .overlay { background: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.4) 40%, rgba(0,0,0,0.85) 100%); }
.mag-card .overlay .cat { opacity: .9; font-size: .85rem; }
.mag-card .overlay .title { 
  margin: 4px 0 0; 
  font-size: 1.35rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

@media (max-width: 960px) {
  .mag-hero { grid-template-columns: 1fr; grid-auto-rows: 200px; }
  .mag-card.large { grid-row: auto; }
}

/* Upcoming matches section */
.mag-upcoming { margin: 8px 0 20px; }
.mag-upcoming .head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.mag-upcoming .head h3 { margin: 0; }
.mag-upcoming .tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.mag-upcoming .tabs button {
  padding: 8px 14px;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  transition: all .3s ease;
  position: relative;
  overflow: hidden;
}
.mag-upcoming .tabs button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 85%, var(--secondary)));
  opacity: 0;
  transition: opacity .3s ease;
}
.mag-upcoming .tabs button:hover::before { opacity: 1; }
.mag-upcoming .tabs button:hover {
  color: var(--text-on-primary, #fff);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 30%, transparent);
}
.mag-upcoming .tabs button span { position: relative; z-index: 1; }
.mag-upcoming .tabs button:focus-visible { outline: none; box-shadow: var(--mag-ring); }
.mag-upcoming .tabs button.active {
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 85%, var(--secondary)));
  color: var(--text-on-primary, #fff);
  box-shadow: 0 4px 16px color-mix(in srgb, var(--primary) 35%, transparent);
}
.mag-upcoming .tabs button.active::before { opacity: 0; }

/* Categories switcher */
.mag-cats { margin: 8px 0 12px; }
.mag-cats .cats { display:flex; gap:8px; flex-wrap:wrap; background: color-mix(in srgb, var(--primary) 10%, transparent); padding: 8px; border-radius: 10px; }
.mag-cats .cat { padding:6px 10px; border:2px solid var(--primary); background: transparent; color: var(--primary); border-radius:999px; font-weight:800; cursor:pointer; transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease; }
.mag-cats .cat:hover { background: color-mix(in srgb, var(--primary) 12%, #fff); transform: translateY(-1px); }
.mag-cats .cat.active { background: var(--primary); color: var(--text-on-primary, #fff); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }

/* Slider: show two items by default on desktop */
.match-slider { 
  display: flex; 
  gap: 14px; 
  overflow-x: auto; 
  overflow-y: hidden;
  padding: 6px 2px 6px; 
  scroll-snap-type: x proximity; /* Changed from mandatory to proximity for smoother scrolling */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.match-slider::-webkit-scrollbar { height: 8px; }
.match-slider::-webkit-scrollbar-thumb { background: var(--light-gray, rgba(0,0,0,.2)); border-radius: 999px; }
.match-slider { scrollbar-width: thin; scrollbar-color: var(--light-gray, rgba(0,0,0,.2)) transparent; }
.match-tile { 
  flex: 0 0 calc(50% - 7px); 
  min-width: 320px; 
  background: var(--mag-card); 
  border: 1px solid var(--mag-card-border); 
  border-radius: var(--mag-radius); 
  text-decoration: none; 
  color: inherit; 
  padding: 14px 16px; 
  scroll-snap-align: start;
  /* Optimized transitions - only transform and box-shadow */
  transition: transform .25s ease-out, box-shadow .25s ease-out, border-color .25s ease-out;
  /* GPU acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
}
.match-tile:hover { 
  transform: translateY(-4px) translateZ(0); 
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06); 
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
}
.match-tile:focus-visible { 
  outline: 3px solid var(--primary); 
  outline-offset: 2px;
}
.match-tile .row { display: flex; align-items: center; justify-content: space-between; }
.match-tile .row.top .meta { font-size: .9rem; color: var(--mag-muted); }
.match-tile .row.teams { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; margin-top: 6px; }
.match-tile .row.teams .team { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.match-tile .row.teams .team img { width: 36px; height: 36px; border-radius: 50%; background: var(--mag-soft); object-fit: cover; }
.match-tile .row.teams .vs { font-weight: 800; color: var(--dark-gray, #4a5568); }

@media (max-width: 900px) { .match-tile { flex-basis: 85%; } }

/* Main content grid */
.mag-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin: 10px 0 24px; }
.mag-grid .col.left h3, .mag-grid .col.right h3 { margin-top: 0; }
.mag-grid .left .list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.mag-grid .left .item { 
  display: grid; 
  grid-template-columns: 160px 1fr; 
  gap: 12px; 
  border: 1px solid var(--mag-card-border); 
  border-radius: var(--mag-radius); 
  background: var(--mag-card); 
  padding: 12px; 
  text-decoration: none; 
  color: inherit; 
  transition: transform .25s ease-out, box-shadow .25s ease-out, border-color .25s ease-out, background .25s ease-out;
  position: relative;
  overflow: hidden;
  /* GPU acceleration */
  transform: translateZ(0);
  backface-visibility: hidden;
}
.mag-grid .left .item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}
.mag-grid .left .item:hover::before {
  transform: scaleY(1);
}
.mag-grid .left .item:hover { 
  transform: translateY(-3px) translateZ(0); 
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 4px 12px rgba(0,0,0,0.06); 
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  background: color-mix(in srgb, var(--primary) 3%, var(--mag-card)); 
}
.mag-grid .left .item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.mag-grid .left .item .thumb { width: 100%; height: 110px; background: var(--bg-soft, #f2f2f2); border-radius: 8px; background-position: center; background-size: cover; }
.mag-grid .left .item .meta h4 { margin: 0 0 4px 0; font-size: 1rem; }
.mag-grid .left .item .meta .excerpt { color: var(--mag-muted); font-size: .9rem; }
.mag-grid .left .more { margin-top: 10px; }

.mag-grid .right .widget { border: 1px solid var(--mag-card-border); border-radius: var(--mag-radius); padding: 12px; background: var(--mag-card); }
.mag-grid .right .tabs { display:flex; gap:8px; flex-wrap:wrap; margin-bottom: 8px; }
.mag-grid .right .tabs button {
  padding:8px 14px;
  border:2px solid var(--mag-card-border);
  border-radius:8px;
  background: var(--mag-card);
  cursor:pointer;
  font-weight: 700;
  transition: all .3s ease;
  position: relative;
  overflow: hidden;
}
.mag-grid .right .tabs button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--secondary), color-mix(in srgb, var(--secondary) 85%, var(--primary)));
  opacity: 0;
  transition: opacity .3s ease;
}
.mag-grid .right .tabs button:hover::before { opacity: 0.2; }
.mag-grid .right .tabs button:hover {
  background: color-mix(in srgb, var(--secondary) 15%, var(--mag-card));
  color: var(--primary);
  border-color: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.mag-grid .right .tabs button span { position: relative; z-index: 1; }
.mag-grid .right .tabs button.active {
  background: linear-gradient(135deg, var(--secondary), color-mix(in srgb, var(--secondary) 85%, var(--primary)));
  color: var(--primary);
  border-color: var(--secondary);
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}
.mag-grid .right .tabs button.active::before { opacity: 0; }
.mag-grid .right .widget + .widget { margin-top: 12px; }
.mag-grid .right .row-table { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--light-gray, rgba(0,0,0,.12)); }
.mag-grid .right .muted { color: var(--mag-muted); }

@media (max-width: 960px) {
  .mag-grid { grid-template-columns: 1fr; }
  .mag-grid .left .item { grid-template-columns: 120px 1fr; }
}

/* Motion preferences */
@media (prefers-reduced-motion: reduce) {
  .magazine *, .magazine *::before, .magazine *::after { transition: none !important; animation: none !important; }
}
/* ===================== */
/* Magazine UX Enhancements */
/* ===================== */

/* Layout helpers */
.magazine .container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.magazine .section { margin: 20px 0; }
@media (max-width: 640px){ .magazine .container { padding: 0 12px; } .magazine .section { margin: 16px 0; } }

/* Typography refinements */
.magazine h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 800; color: var(--mag-fg); }
.magazine h2 { font-size: clamp(22px, 3.5vw, 28px); font-weight: 800; color: var(--mag-fg); }
.magazine h3 { font-size: clamp(18px, 3vw, 20px); font-weight: 800; color: var(--mag-fg); }
.magazine .lead { font-size: clamp(16px, 2.5vw, 18px); color: var(--mag-muted); line-height: 1.6; }
.magazine small, .magazine .caption { font-size: 12px; opacity: .85; }

/* Links */
.magazine a:hover { color: var(--primary); }
.magazine a.underline:hover { text-decoration: underline; }

/* Buttons */
.magazine .btn { cursor: pointer; user-select: none; }
.magazine .btn.primary { background: var(--primary); color: var(--text-on-primary, #fff); border: 1px solid transparent; border-radius: 10px; padding: 10px 14px; font-weight: 800; }
.magazine .btn.primary:hover { filter: brightness(0.95); box-shadow: var(--mag-shadow); transform: translateY(-1px); }
.magazine .btn.secondary { background: var(--mag-soft); color: var(--mag-fg); border:1px solid var(--mag-card-border); border-radius: 10px; padding: 10px 14px; font-weight: 800; }
.magazine .btn.secondary:hover { background: #eaeaea; box-shadow: var(--mag-shadow); transform: translateY(-1px); }
.magazine .btn.ghost { background: transparent; color: var(--primary); border:1px solid var(--mag-card-border); border-radius: 10px; padding: 10px 14px; font-weight: 800; }
.magazine .btn.ghost:hover { background: rgba(0,0,0,0.035); }
.magazine .btn[disabled], .magazine .btn.disabled { opacity: .6; pointer-events: none; filter: grayscale(10%); }

/* Form fields */
.magazine .field { display:flex; flex-direction: column; gap: 6px; }
.magazine label { font-weight: 700; font-size: 12px; color: var(--mag-muted); }
.magazine input.input, .magazine select.select, .magazine textarea.textarea {
  width: 100%; padding: 10px 12px; color: var(--mag-fg);
  background: #fff; border:1px solid var(--mag-card-border); border-radius: 10px;
  outline: none; transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.magazine input.input::placeholder, .magazine textarea.textarea::placeholder { color: rgba(17,24,39,0.6); }
.magazine input.input:hover, .magazine select.select:hover, .magazine textarea.textarea:hover { border-color: rgba(0,0,0,0.18); }
.magazine input.input:focus, .magazine select.select:focus, .magazine textarea.textarea:focus { box-shadow: var(--mag-ring); background: #fff; }
.magazine .helper { font-size: 12px; color: var(--mag-muted); }
.magazine .error { color: #b91c1c; font-size: 12px; }

/* Chips / badges */
.magazine .chip, .magazine .badge, .magazine .tag { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border-radius:999px; border:1px solid var(--mag-card-border); background: #fff; color: var(--mag-fg); font-weight:700; font-size:12px; }
.magazine .badge.success { border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.12); }
.magazine .badge.warn { border-color: rgba(234,179,8,0.4); background: rgba(234,179,8,0.12); }
.magazine .badge.info { border-color: rgba(59,130,246,0.4); background: rgba(59,130,246,0.12); }

/* Grid helpers */
.magazine .grid { display:grid; gap: 12px; }
.magazine .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.magazine .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.magazine .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px){ .magazine .grid.cols-3, .magazine .grid.cols-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px){ .magazine .grid.cols-2, .magazine .grid.cols-3, .magazine .grid.cols-4 { grid-template-columns: 1fr; } }

/* Empty state */
.magazine .empty-state { text-align:center; padding: 16px; border-radius: var(--mag-radius); background: var(--mag-soft); border:1px solid var(--mag-card-border); }
.magazine .empty-state .icon { width: 48px; height: 48px; margin: 0 auto 8px; opacity: .9; }

/* Skeleton loader */
.magazine .skeleton { position: relative; overflow: hidden; background: var(--mag-soft); border-radius: var(--mag-radius); }
.magazine .skeleton::after { content: ""; position:absolute; inset:0; background: linear-gradient(90deg, transparent, rgba(0,0,0,0.05), transparent); animation: mag-shimmer 1.6s infinite; }
@keyframes mag-shimmer { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Hero card entrance */
.mag-hero .mag-card { opacity: 0; transform: translateY(8px); animation: mag-fade-up .6s ease forwards; }
.mag-hero .mag-card:nth-child(1) { animation-delay: .05s; }
.mag-hero .mag-card:nth-child(2) { animation-delay: .12s; }
.mag-hero .mag-card:nth-child(3) { animation-delay: .18s; }
@keyframes mag-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* Tables: sticky header option */
.magazine .tables.sticky .head { position: sticky; top: 0; z-index: 1; backdrop-filter: blur(4px); background: rgba(255,255,255,0.75); border-bottom: 1px solid var(--mag-card-border); }

/* Glass utility */
.magazine .glass { background: rgba(255,255,255,0.75); border:1px solid var(--mag-card-border); backdrop-filter: blur(6px); border-radius: var(--mag-radius); }

/* Accessibility */
.magazine [role="button"], .magazine button, .magazine .btn { -webkit-tap-highlight-color: transparent; }
.magazine ::selection { background: rgba(59,130,246,0.25); color: #000; }

/* Responsive adjustments */
@media (max-width: 560px){
  .magazine .btn, .magazine .btn.secondary, .magazine .btn.ghost, .magazine .btn.primary { padding: 10px 12px; }
  .mag-grid { gap: 14px; }
  .mag-grid .left .item { grid-template-columns: 100px 1fr; }
}

/* Print adjustments */
@media print {
  .magazine { background: #fff !important; color: #111827 !important; }
  .magazine a { color: #111827 !important; text-decoration: underline; }
  .mag-hero .mag-card .overlay { background: transparent !important; }
}
