/* ITN Campus Results Portal - style.css
   results.itncampus.edu.lk */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

/* Design Tokens */
:root {
    --primary:       #262E81;
    --secondary:     #007BC1;
    --text:          #565756;
    --accent:        #EE2D2B;
    --white:         #FFFFFF;
    --black:         #000000;
    --dark:          #2C2C2C;
    --primary-dark:  #3C438E;
    --primary-deeper:#1E2567;
    --light-blue:    #E6F2F9;
    --off-white:     #FAFCFE;

    /* Derived */
    --primary-10:    rgba(38, 46, 129, 0.08);
    --primary-20:    rgba(38, 46, 129, 0.18);
    --secondary-10:  rgba(0, 123, 193, 0.10);
    --accent-10:     rgba(238, 45, 43, 0.10);
    --shadow-sm:     0 1px 4px rgba(38,46,129,0.08);
    --shadow-md:     0 4px 20px rgba(38,46,129,0.12);
    --shadow-lg:     0 12px 40px rgba(38,46,129,0.16);
    --radius-sm:     6px;
    --radius-md:     12px;
    --radius-lg:     20px;
    --transition:    0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.65;
    color: var(--text);
    background: var(--off-white);
    min-height: 100vh;
}

/* HEADER */
.site-header {
    background: linear-gradient(135deg, var(--primary-deeper) 0%, var(--primary) 50%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
}

.site-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 80% 20%, rgba(0,123,193,0.25) 0%, transparent 50%),
        radial-gradient(circle at 10% 80%, rgba(60,67,142,0.3) 0%, transparent 45%);
    pointer-events: none;
}

.site-header::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent) 0%, #ff6b6b 50%, var(--secondary) 100%);
}

/* Geometric grid pattern */
.header-pattern {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.header-inner {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Top bar */
.header-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0 16px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 16px;
    text-decoration: none;
}

.logo-wrap img {
    height: 54px;
    width: auto;
    filter: brightness(0) invert(1);
}

.logo-divider {
    width: 1px;
    height: 36px;
    background: rgba(255,255,255,0.25);
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.logo-text .portal-label {
    font-family: 'DM Sans', sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.55);
}

.logo-text .portal-name {
    font-family: 'DM Serif Display', serif;
    font-size: 17px;
    color: var(--white);
    letter-spacing: 0.3px;
}

.header-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.10);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 100px;
    padding: 5px 14px 5px 10px;
    font-size: 11.5px;
    font-weight: 500;
    color: rgba(255,255,255,0.80);
    backdrop-filter: blur(4px);
}

.header-badge .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 0 2px rgba(74,222,128,0.3);
    animation: pulse-dot 2s ease infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 2px rgba(74,222,128,0.3); }
    50%       { box-shadow: 0 0 0 5px rgba(74,222,128,0.15); }
}

/* Hero section */
.header-hero {
    padding: 40px 0 48px;
    text-align: center;
}

.header-hero .eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
    margin-bottom: 16px;
}

.header-hero .eyebrow::before,
.header-hero .eyebrow::after {
    content: '';
    flex: 1;
    min-width: 24px;
    height: 1px;
    background: rgba(255,255,255,0.2);
}

.header-hero h1 {
    font-family: 'DM Serif Display', serif;
    font-size: clamp(28px, 5vw, 48px);
    color: var(--white);
    font-weight: 400;
    line-height: 1.15;
    margin-bottom: 12px;
}

.header-hero h1 em {
    font-style: italic;
    color: rgba(255,255,255,0.75);
}

.header-hero p {
    font-size: 15px;
    color: rgba(255,255,255,0.60);
    max-width: 480px;
    margin: 0 auto;
}

/* FILTER / SEARCH BAR */
.filters-section {
    background: var(--white);
    border-bottom: 1px solid rgba(38,46,129,0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.filters-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-wrap .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary);
    opacity: 0.4;
    pointer-events: none;
}

#search-input {
    width: 100%;
    height: 42px;
    padding: 0 14px 0 42px;
    border: 1.5px solid rgba(38,46,129,0.15);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--dark);
    background: var(--off-white);
    transition: var(--transition);
    outline: none;
}

#search-input:focus {
    border-color: var(--secondary);
    background: var(--white);
    box-shadow: 0 0 0 3px var(--secondary-10);
}

#search-input::placeholder { color: rgba(86,87,86,0.5); }

.filter-select {
    height: 42px;
    padding: 0 36px 0 14px;
    border: 1.5px solid rgba(38,46,129,0.15);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13.5px;
    color: var(--dark);
    background: var(--off-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23262E81' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    appearance: none;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
    white-space: nowrap;
    min-width: 140px;
}

.filter-select:focus {
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px var(--secondary-10);
}

.btn-clear {
    height: 42px;
    padding: 0 18px;
    border: 1.5px solid rgba(238,45,43,0.25);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--accent);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-clear:hover {
    background: var(--accent-10);
    border-color: var(--accent);
}

/* Results count */
.results-count-bar {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 24px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.results-count-bar .count-text {
    font-size: 13px;
    color: var(--text);
    opacity: 0.75;
}

.results-count-bar .count-text strong {
    color: var(--primary);
    font-weight: 600;
}

/* MAIN LAYOUT */
.main-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}

/* YEAR GROUP / ACCORDION */
.year-group {
    margin-bottom: 32px;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    background: var(--white);
    border: 1px solid rgba(38,46,129,0.07);
    animation: fadeUp 0.4s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.year-group:nth-child(2) { animation-delay: 0.05s; }
.year-group:nth-child(3) { animation-delay: 0.10s; }
.year-group:nth-child(4) { animation-delay: 0.15s; }

.year-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    user-select: none;
    transition: opacity var(--transition);
}

.year-header:hover { opacity: 0.92; }

.year-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.15);
    border: 1.5px solid rgba(255,255,255,0.25);
    flex-shrink: 0;
}

.year-badge svg { color: var(--white); }

.year-info { flex: 1; }

.year-info .year-number {
    font-family: 'DM Serif Display', serif;
    font-size: 22px;
    color: var(--white);
    line-height: 1;
}

.year-info .year-sub {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    margin-top: 2px;
}

.year-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.year-count {
    background: rgba(255,255,255,0.18);
    border-radius: 100px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--white);
}

.year-chevron {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--transition);
    color: rgba(255,255,255,0.7);
}

.year-group.collapsed .year-chevron { transform: rotate(-90deg); }

/* Results grid inside year group */
.year-body {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    transition: var(--transition);
}

.year-group.collapsed .year-body {
    display: none;
}

/* RESULT CARD */
.result-card {
    border: 1.5px solid rgba(38,46,129,0.09);
    border-radius: var(--radius-md);
    padding: 20px;
    background: var(--white);
    position: relative;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.result-card::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--secondary) 0%, var(--primary) 100%);
    border-radius: 0 2px 2px 0;
    transition: width var(--transition);
}

.result-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: rgba(0,123,193,0.25);
}

.result-card:hover::before { width: 5px; }

.card-top {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--primary-10);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}

.result-card:hover .card-icon {
    background: var(--secondary-10);
}

.card-icon svg { color: var(--primary); transition: color var(--transition); }
.result-card:hover .card-icon svg { color: var(--secondary); }

.card-titles { flex: 1; min-width: 0; }

.card-title {
    font-size: 14.5px;
    font-weight: 600;
    color: var(--primary-deeper);
    line-height: 1.35;
    margin-bottom: 4px;
}

.card-subtitle {
    font-size: 12.5px;
    color: var(--text);
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 500;
}

.tag-semester {
    background: var(--secondary-10);
    color: var(--secondary);
}

.tag-course {
    background: var(--primary-10);
    color: var(--primary);
}

.card-footer {
    margin-top: auto;
    padding-top: 4px;
    border-top: 1px solid rgba(38,46,129,0.06);
}

.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 40px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    text-decoration: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.2px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-download::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--secondary) 0%, var(--primary) 100%);
    opacity: 0;
    transition: opacity var(--transition);
}

.btn-download:hover::after { opacity: 1; }

.btn-download span, .btn-download svg {
    position: relative;
    z-index: 1;
}

.btn-download:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(38,46,129,0.35); }
.btn-download:active { transform: translateY(0); }

/* STATES: LOADING / EMPTY / ERROR */
#results-container { min-height: 300px; }

.state-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 80px 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--primary-10);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.state-loading p {
    font-size: 14px;
    color: var(--text);
    opacity: 0.65;
}

.state-empty, .state-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 24px;
    text-align: center;
}

.state-empty .icon-wrap, .state-error .icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.state-empty .icon-wrap { background: var(--light-blue); color: var(--secondary); }
.state-error .icon-wrap { background: var(--accent-10); color: var(--accent); }

.state-empty h3, .state-error h3 {
    font-family: 'DM Serif Display', serif;
    font-size: 20px;
    color: var(--primary);
    font-weight: 400;
}

.state-empty p, .state-error p {
    font-size: 14px;
    color: var(--text);
    opacity: 0.7;
    max-width: 360px;
}

.btn-retry {
    margin-top: 4px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--white);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-retry:hover { background: var(--primary-dark); }

/* SKELETON LOADING */
.skeleton-group { margin-bottom: 28px; }

.skeleton-header {
    height: 72px;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    opacity: 0.18;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    padding: 20px;
    background: var(--white);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    border: 1px solid rgba(38,46,129,0.07);
    border-top: none;
}

.skeleton-card {
    height: 150px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg,
        rgba(38,46,129,0.05) 0%,
        rgba(38,46,129,0.10) 50%,
        rgba(38,46,129,0.05) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease infinite;
}

@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position:  200% 0; }
}

/* PAGINATION */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 0 0;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    border: 1.5px solid rgba(38,46,129,0.15);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--primary);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-10);
    border-color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    font-weight: 700;
}

.page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* FOOTER */
.site-footer {
    border-top: 1px solid rgba(38,46,129,0.08);
    background: var(--white);
    padding: 28px 24px;
    text-align: center;
}

.site-footer .footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.footer-logo img {
    height: 32px;
    width: auto;
    opacity: 0.55;
    filter: grayscale(1);
}

.footer-copy {
    font-size: 12.5px;
    color: var(--text);
    opacity: 0.55;
    text-align: center;
}

.footer-link {
    font-size: 12.5px;
    color: var(--secondary);
    text-decoration: none;
    opacity: 0.8;
    transition: opacity var(--transition);
}

.footer-link:hover { opacity: 1; }

/* PDF MODAL / VIEWER */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 37, 103, 0.65);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 780px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.25s ease;
}

@keyframes slideUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }

.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(38,46,129,0.08);
    background: var(--off-white);
}

.modal-header h2 {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary-deeper);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.modal-btn {
    height: 34px;
    padding: 0 14px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    border: none;
}

.modal-btn-dl {
    background: var(--primary);
    color: var(--white);
}
.modal-btn-dl:hover { background: var(--primary-dark); }

.modal-btn-close {
    background: rgba(238,45,43,0.08);
    color: var(--accent);
    border: 1px solid rgba(238,45,43,0.15);
}
.modal-btn-close:hover { background: rgba(238,45,43,0.15); }

.modal-body {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.modal-body iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
    display: block;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .header-topbar { flex-wrap: wrap; gap: 10px; }
    .header-badge { display: none; }
    .filters-section { position: static; }
    .filters-inner { flex-direction: column; align-items: stretch; }
    .search-wrap { min-width: 100%; }
    .filter-select { width: 100%; }
    .btn-clear { justify-content: center; }
    .year-body { grid-template-columns: 1fr; }
    .footer-inner { flex-direction: column; text-align: center; }
    .results-count-bar { flex-direction: column; align-items: flex-start; gap: 4px; }
    .modal-box { max-height: 100vh; border-radius: 0; }
}

@media (max-width: 480px) {
    .logo-wrap img { height: 40px; }
    .logo-text .portal-name { font-size: 14px; }
    .header-hero h1 { font-size: 24px; }
    .main-wrapper { padding: 20px 16px 48px; }
    .year-header { padding: 14px 16px; }
    .year-body { padding: 14px; }
}
