/*
  ======================================================================
  BVVS Polytechnic CSE | Software Portal | v3 "Mobile First" Upgrade
  ======================================================================
  Key Upgrades (v3):
  - Mobile Card Redesign: Solved icon sizing and layout issues on mobile.
  - Highlighted Details: File size and platform info are now prominent tags.
  - "Alive" Animations: New keyframes for glowing borders and shimmering buttons.
  - Ultimate Mobile UI: Completely redesigned header/toolbar for mobile.
  - Dynamic Sizing: Perfected spacing and font sizes for all screen widths.
  - Accessibility: Clearer focus states for better keyboard navigation.
  ======================================================================
*/

/* ========== Base & Theming ========== */
:root {
  --brand-primary: #2a5d9f;
  --brand-primary-dark: #1b4173;
  --brand-gradient: linear-gradient(45deg, #3a7bd5, #2a5d9f);
  --brand-glow: 0 0 12px 2px rgba(42, 93, 159, 0.3);

  --bg-primary: #f8faff;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f3f6fb;
  --bg-highlight: #eef4ff;

  --text-primary: #2c3e50;
  --text-secondary: #596573;
  --text-muted: #8a96a5;

  --line-color: #dfe6f0;
  --success-color: #33B249;
  --success-gradient: linear-gradient(45deg, #33B249, #28a745);

  --shadow-sm: 0 4px 12px rgba(42, 93, 159, 0.08);
  --shadow-md: 0 8px 24px rgba(42, 93, 159, 0.12);
  --shadow-lg: 0 16px 32px rgba(38, 100, 169, 0.18);

  --radius-md: 16px;
  --radius-lg: 24px;
  --transition-fast: 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-slow: 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== NEW & Enhanced Keyframe Animations ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes subtlePulse {
  0% { box-shadow: var(--brand-glow); }
  50% { box-shadow: 0 0 18px 4px rgba(42, 93, 159, 0.2); }
  100% { box-shadow: var(--brand-glow); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ========== Header ========== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line-color);
  padding: 1rem 1.5rem;
  animation: fadeIn 0.5s ease-out;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.brand {
  font-size: clamp(1.2rem, 1.5vw + 0.5rem, 1.75rem);
  font-weight: 700;
  color: var(--brand-primary);
  text-shadow: 1px 1px 2px rgba(0,0,0,0.05);
}

/* Toolbar (Search + Filter) */
.toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-grow: 1;
  max-width: 600px;
}

.toolbar input[type="search"],
.toolbar select {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 2px solid transparent;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-size: 1rem;
  transition: all var(--transition-fast);
  color: var(--text-primary);
}

.toolbar input[type="search"] {
  flex-grow: 1;
  padding-left: 2.5rem; /* Space for icon */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a96a5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 1rem center;
}

.toolbar select {
  width: auto;
  flex-shrink: 0;
  max-width: 180px;
  cursor: pointer;
}

.toolbar input::placeholder {
  color: var(--text-muted);
}

.toolbar input:focus,
.toolbar select:focus,
.toolbar input:hover,
.toolbar select:hover {
  outline: none;
  border-color: var(--brand-primary);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 4px rgba(42, 93, 159, 0.1);
}

/* ========== Main Layout ========== */
.container {
  max-width: 1200px;
  margin: 2.5rem auto 4rem;
  padding: 0 1.5rem;
}

.section-title {
  text-align: center;
  color: var(--brand-primary);
  font-weight: 700;
  font-size: clamp(1.5rem, 2vw + 1rem, 2.2rem);
  margin-bottom: 2.5rem;
  animation: fadeInUp 0.6s ease-out 0.1s forwards;
  opacity: 0;
}

.software-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr));
}

/* ========== Upgraded Card ========== */
.software-item {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--line-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: transform var(--transition-slow), box-shadow var(--transition-slow), border-color var(--transition-slow);
  will-change: transform, box-shadow;
}

.software-item.in {
  animation: fadeInUp 0.5s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}

.software-item:hover,
.software-item:focus-within {
  transform: translateY(-8px) scale(1.02);
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-primary);
  background-color: var(--bg-highlight);
}

.software-icon {
  flex: 0 0 64px;
  height: 64px;
  display: grid;
  place-items: center;
  transition: transform var(--transition-slow);
}

.software-item:hover .software-icon {
  transform: rotate(-5deg) scale(1.1);
}

.software-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.software-details {
  flex: 1 1 auto;
  min-width: 0;
}

.software-details .title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  align-items: center;
}

.platform {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.platform img {
  width: 18px;
  height: 18px;
}

.software-download {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.download-btn {
  background: var(--success-gradient);
  color: #fff;
  text-decoration: none;
  padding: 0.6rem 1.3rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 10px rgba(40, 167, 69, 0.25);
  position: relative;
  overflow: hidden;
}

.download-btn:hover, .download-btn:focus {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(40, 167, 69, 0.35);
}

/* NEW: Shimmer animation on hover */
.download-btn:hover::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(100deg, rgba(255,255,255,0) 20%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 80%);
    animation: shimmer 1.5s infinite;
}

.download-btn:active {
  transform: translateY(0px) scale(0.98);
  filter: brightness(0.95);
}

.download-btn[aria-disabled="true"] {
    background: #aeb8c4;
    cursor: not-allowed;
    box-shadow: none;
    filter: none;
    transform: none;
}

.download-btn[aria-disabled="true"]::after {
    display: none;
}

.file-size {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-secondary);
  border: 2px dashed var(--line-color);
  border-radius: var(--radius-lg);
  background-color: var(--bg-secondary);
  display: none; /* Controlled by JS */
  animation: fadeIn 0.5s;
}

/* ========== Footer ========== */
.site-footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--line-color);
  padding: 2.5rem 1.5rem 1.5rem;
  margin-top: auto;
  clip-path: polygon(0 5%, 100% 0, 100% 100%, 0 100%);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
  justify-content: space-between;
}

.footer-section {
  flex: 1 1 260px;
  min-width: 220px;
}

.footer-section h3, .footer-section h4 {
  color: var(--brand-primary);
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.footer-section p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.footer-bottom {
  max-width: 1200px;
  margin: 2rem auto 0;
  text-align: center;
  border-top: 1px solid var(--line-color);
  padding-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ========== Back FAB ========== */
#universal-back-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: grid;
  place-items: center;
  transition: all var(--transition-fast);
  animation: subtlePulse 3s infinite;
}

#universal-back-button:hover, #universal-back-button:focus {
  transform: scale(1.1) rotate(10deg);
  box-shadow: var(--shadow-lg);
  animation-play-state: paused;
}

#universal-back-button svg {
  width: 26px;
  height: 26px;
  stroke: #fff;
}

/* ========== General Accessibility ========== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

:focus-visible {
    outline: 3px solid var(--brand-primary);
    outline-offset: 3px;
    box-shadow: none;
}


/*
  ==============================================================
  ULTIMATE MOBILE & RESPONSIVE UPGRADES
  ==============================================================
*/

/* For tablets and smaller devices */
@media (max-width: 768px) {
  .site-header {
    padding: 1rem;
  }

  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .toolbar {
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.75rem;
  }

  .toolbar select {
    max-width: 150px;
  }
  
  /* ============================================== */
  /* === NEW: MOBILE CARD REDESIGN & ANIMATIONS === */
  /* ============================================== */

  .software-item {
    /* Changed from flex to grid for precise layout control on mobile */
    display: grid;
    grid-template-columns: auto 1fr; /* Icon column, details column */
    grid-template-rows: auto auto; /* Two rows for content */
    grid-template-areas: 
      "icon details"
      "download download";
    gap: 0.5rem 1rem; /* row-gap column-gap */
    align-items: center; /* Vertically center items in their grid cells */
    padding: 1.2rem;
  }

  .software-icon {
    grid-area: icon;
    /* SOLVED: Perfectly sized icon for mobile */
    flex-basis: 56px;
    width: 56px;
    height: 56px;
  }

  .software-details {
    grid-area: details;
    width: 100%;
  }

  .software-download {
    grid-area: download;
    /* Redesigned for clarity */
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line-color);
  }

  /* NEW: Highlighted File Size Badge */
  .file-size {
    font-weight: 600;
    color: var(--brand-primary-dark);
    background-color: var(--bg-highlight);
    padding: 0.25rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
  }

  .site-footer {
     clip-path: none;
  }
}

/* For small mobile phones */
@media (max-width: 480px) {
  .brand {
    font-size: 1.15rem;
  }

  .toolbar input[type="search"],
  .toolbar select {
    font-size: 0.95rem;
    padding-top: 0.7rem;
    padding-bottom: 0.7rem;
  }

  .toolbar input[type="search"] {
      padding-left: 2.2rem;
      background-size: 16px;
      background-position: 0.7rem center;
  }

  .container {
    padding: 0 1rem;
  }
  
  .section-title {
    margin-bottom: 2rem;
  }

  .software-item {
      padding: 1rem;
      column-gap: 0.8rem;
  }

  .software-icon {
    /* Further refinement for smallest screens */
    width: 48px;
    height: 48px;
  }

  .software-details .title {
    font-size: 1.1rem;
  }
  
  .meta-info {
      font-size: 0.85rem;
  }
}

/*
  ==============================================================
  CARD V2 - DROPDOWN STYLES
  ==============================================================
*/

/* This wrapper is needed to position the dropdown menu 
  relative to the download button area.
*/
.software-download .download-dropdown-wrapper {
  position: relative;
  display: inline-block;
  /* Align to the right, matching other cards */
  margin-left: auto; 
}

/* Style for the new dropdown-enabled button.
  It builds on your existing .download-btn class.
*/
.download-btn-v2 {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* Space between "Download" and arrow */
}

/* The SVG arrow icon */
.download-btn-v2 .dropdown-arrow {
  width: 16px;
  height: 16px;
  stroke: #ffffff;
  transition: transform 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Rotate the arrow when the dropdown is active */
.download-btn-v2.active .dropdown-arrow {
  transform: rotate(180deg);
}

/* The dropdown menu itself (hidden by default) */
.download-options {
  display: none; /* Hidden by default, JS will show it */
  position: absolute;
  top: calc(100% + 8px); /* Position 8px below the button */
  right: 0;
  min-width: 220px;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--line-color);
  box-shadow: var(--shadow-md);
  padding: 0.5rem;
  z-index: 10;
  animation: fadeInUp 0.2s ease-out; /* Reuse your existing animation */
}

/* This class is added by JS to show the menu */
.download-options.active {
  display: block;
}

/* A single item (link) in the dropdown */
.download-option-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 12px; /* Slightly smaller radius for items */
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.2s ease-out;
}

.download-option-item:hover {
  background-color: var(--bg-tertiary);
  color: var(--brand-primary);
}

.download-option-item .option-label {
  font-weight: 600;
  font-size: 0.95rem;
}

.download-option-item .option-size {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* On mobile, make the file-size badge for v2 cards invisible
   since the size info is now in the dropdown. */
@media (max-width: 768px) {
  .software-item-v2 .file-size {
    display: none;
  }
}

.software-item-v2.active {
  position: relative; /* Creates a new stacking context */
  z-index: 20;       /* Lifts it above other items (default is z-index: auto) */
}