/* --- AQUA OS X VARIABLES --- */
:root {
  --font: 'Lucida Grande', 'Lucida Sans Unicode', Helvetica, Arial, sans-serif;
  --mc-border: #a1a1a1;            
  --mc-bg: rgba(255, 255, 255, 0.9); 
  --mc-text: #222222;        
  --mc-link: #2c3e50;          /* Deep charcoal/slate instead of bright blue */
  --mc-link-hover: #000000;
  
  --gel-border: #6880a6;
  --gel-top: #e6f0fa;
  --gel-mid-dark: #9bc0ea;
  --gel-mid-light: #adccee;
  --gel-bottom: #cbe0f5;
}

/* Ensure all regular text links use the dark tone */
a {
  color: var(--mc-link);
  text-decoration: none;
}

a:hover {
  color: var(--mc-link-hover);
  text-decoration: underline;
}

/* Ensure player profile links inside table cells do not turn blue */
.player-cell a {
  color: var(--mc-text) !important;
  font-weight: bold;
}

.player-cell a:hover {
  color: #000000 !important;
  text-decoration: underline;
}

body {
  font-family: var(--font);
  /* Classic OS X Pinstripe Background */
  background: repeating-linear-gradient(
    0deg,
    #e8e8e8,
    #e8e8e8 2px,
    #f4f4f4 2px,
    #f4f4f4 4px
  );
  background-attachment: fixed;
  color: var(--mc-text);
  margin: 0;
  padding: 2rem 1rem;
  font-size: 14px; /* Scaled down slightly to match legacy desktop UIs */
  -webkit-font-smoothing: subpixel-antialiased;
}

/* --- LAYOUT GRID --- */
.site-wrapper {
    width: 100%; 
    max-width: 900px;
    margin: 0 auto;
    padding: 10px;
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) 200px; 
    grid-template-rows: auto 1fr;
    gap: 15px;
    align-items: start;
}

#left-col, #center-col, #right-col {
    display: flex;
    flex-direction: column;
}

#left-col, #right-col {
    position: sticky;
    top: 20px; 
}

/* --- OS X WINDOW PANELS --- */
.box {
  border: 1px solid var(--mc-border);
  background-color: var(--mc-bg);
  color: var(--mc-text);
  padding: 15px;
  margin-bottom: 15px;
  border-radius: 8px; /* Rounded window corners */
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8); 
  backdrop-filter: blur(4px);
}

.box p {
  margin: 8px 0;
  line-height: 1.5;
}

main, #main-content {
  width: 100%;
}

h1, h2 {
  color: #333333;
  margin-top: 0;
  font-size: 22px;
  text-shadow: 0 1px 0 #ffffff;
  font-weight: bold;
}

/* --- NAVIGATION ALIGNMENT --- */
nav {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
  /* Removed the old bottom border since we are using pill buttons now */
}

/* --- LICKABLE AQUA BUTTONS & LINKS --- */
.toggle {
  display: flex;
  gap: 10px;
  margin-bottom: 1.5rem;
}

/* Apply the gel effect to buttons, nav links, and left column links */
button, nav a, #left-col a {
  font-family: var(--font);
  font-size: 13px;
  font-weight: normal;
  text-decoration: none;
  text-align: center;
  padding: 4px 18px;
  border: 1px solid #888888;
  border-radius: 12px; /* Pill shape */
  color: #333333;
  display: inline-block;
  box-sizing: border-box;
  
  /* Gray Gel Gradient for standard state */
  background: linear-gradient(to bottom, #ffffff 0%, #e0e0e0 45%, #cccccc 50%, #f0f0f0 100%);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.9), 0 1px 3px rgba(0,0,0,0.15);
  cursor: pointer;
  text-shadow: 0 1px 0 rgba(255,255,255,0.8);
}

/* Make the left column buttons stack vertically */
#left-col a {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 6px 12px;
}

/* Clicked down state */
button:active, nav a:active, #left-col a:active {
  background: #cccccc;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

/* The signature OS X Blue Gel Gradient for active toggles */
button[aria-pressed="true"] {
  border-color: var(--gel-border);
  color: #000000;
  background: linear-gradient(
    to bottom, 
    var(--gel-top) 0%, 
    var(--gel-mid-light) 45%, 
    var(--gel-mid-dark) 50%, 
    var(--gel-bottom) 100%
  );
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.8), 0 1px 3px rgba(0,0,0,0.2);
}

/* --- DATA TABLES (iTunes Style) --- */
.wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 5px;
}

th, td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid #d9d9d9;
}

th {
  color: #555555;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);
  border-top: 1px solid #cccccc;
  border-bottom: 1px solid #a1a1a1;
}

/* Subtle alternating row colors */
tbody tr:nth-child(even) {
  background-color: #f1f5fa;
}

td.won { color: #1f801f; font-weight: bold; }

.badge {
  font-size: 11px;
  padding: 2px 8px;
  border: 1px solid #a1a1a1;
  color: #555555;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* --- AVATARS (Cleaned up for OS X) --- */
.player-cell { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px;
  height: 30px;
  border: 1px solid #cccccc;
  border-radius: 4px; /* Slightly rounded, like iChat buddy icons */
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, #e6e6e6, #cccccc);
  color: #555;
  font-size: 12px;
  font-weight: bold;
  border-radius: 4px;
  border: 1px solid #aaa;
}
.avatar-pair { display: flex; flex-shrink: 0; }
.avatar-pair .avatar:last-child { margin-left: -10px; }

#error {
  background: linear-gradient(to bottom, #ffcccc, #ff9999);
  border: 1px solid #cc0000;
  color: #990000;
  padding: 10px;
  margin-bottom: 1rem;
  border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.5);
}

/* --- BRACKETS --- */
.tournament-tree {
  display: flex;
  gap: 2rem;
  overflow-x: auto;
  padding-bottom: 2rem;
  align-items: center;
}

.round {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  min-width: 210px;
}

.match {
  border: 1px solid var(--mc-border);
  background: #ffffff;
  padding: 6px;
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.team {
  display: flex;
  justify-content: space-between;
  padding: 4px;
  align-items: center;
  border-bottom: 1px solid #eeeeee;
}
.team:last-child { border-bottom: none; }

.team.won {
  color: var(--mc-link);
  background-color: #f1f5fa;
  border-radius: 4px;
}

.champ-marquee {
  font-size: 18px;
  color: #333333;
  background: linear-gradient(to bottom, #ffffff, #e8e8e8);
  border: 1px solid var(--mc-border);
  padding: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}


/* --- MOBILE RESPONSIVENESS --- */
/* =========================================
   MOBILE RESPONSIVENESS OVERHAUL (max-width: 768px)
   ========================================= */
@media (max-width: 768px) {
  /* Stack 3-column desktop layout into a single vertical stream */
  .site-wrapper {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px !important;
    box-sizing: border-box !important;
  }

  #left-col,
  #center-col,
  #right-col {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 0 14px 0 !important;
    box-sizing: border-box !important;
  }

  /* Keep right sidebar info visible below main content without clutter */
  #right-col {
    order: 3;
  }

  /* Make containers fit edge-to-edge with comfy padding */
  .box {
    padding: 12px !important;
    margin-bottom: 12px !important;
    box-sizing: border-box !important;
  }

  /* Navigation: wrap buttons cleanly so they don't squash */
  nav {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    justify-content: center !important;
    margin-bottom: 15px !important;
  }

  nav a {
    flex: 1 1 calc(50% - 6px) !important;
    text-align: center !important;
    padding: 6px 10px !important;
    font-size: 13px !important;
  }

  /* Tables: allow smooth horizontal swipe with visible borders */
  .wrap {
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px !important;
    display: block !important;
  }

  #board {
    min-width: 480px; /* Prevents text crunching; lets table scroll cleanly */
    font-size: 12px !important;
  }

  #board th,
  #board td {
    padding: 6px 8px !important;
    white-space: nowrap !important;
  }

  /* Player Profile specific fixes */
  .profile-header,
  div[style*="display: flex; gap: 20px; flex-wrap: wrap"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Infobox takes full mobile width */
  div[style*="flex: 0 0 200px"] {
    flex: 1 1 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Rating cards stack neatly 1x1 on mobile instead of squishing side-by-side */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="display: grid; grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* Photo galleries adjust to two tidy columns */
  #p-gallery,
  #event-gallery-container div[style*="display: grid"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
}