/*
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
*/

@import url("https://fonts.googleapis.com/css?family=Play");

/* --- CSS Variables for Easy Theme Customization --- */
:root {
    --bg-mask-color: #0a0e17; /* Dark Mask */
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.05);
    --card-hover-bg: rgba(255, 255, 255, 0.1);
    --card-hover-border: rgba(255, 255, 255, 0.15);
    --card-text-color: #ffffff;
    --toggle-btn-bg: rgba(255, 255, 255, 0.08);
    --toggle-btn-border: rgba(255, 255, 255, 0.15);
    --toggle-btn-color: #ffffff;
    --toggle-btn-hover-bg: rgba(255, 255, 255, 0.18);
    --reveal-bg-url: url("storage/bg/img_bg1.jpg");
}

/* Light Theme Variables */
body.light-theme {
    --bg-mask-color: #f2f4f7; /* Light Mask */
    --card-bg: rgba(255, 255, 255, 0.35);
    --card-border: rgba(0, 0, 0, 0.05);
    --card-hover-bg: rgba(255, 255, 255, 0.6);
    --card-hover-border: rgba(0, 0, 0, 0.1);
    --card-text-color: #1a202c;
    --toggle-btn-bg: rgba(0, 0, 0, 0.05);
    --toggle-btn-border: rgba(0, 0, 0, 0.1);
    --toggle-btn-color: #1a202c;
    --toggle-btn-hover-bg: rgba(0, 0, 0, 0.1);
    --reveal-bg-url: url("storage/bg/img_bg1.jpg");
}

/* --- Global styles --- */
html {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-mask-color);
    font-family: "Play", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--card-text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* --- Canvas Mask & Reveal Background Styles --- */
#tomcatMask {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    display: block;
}

#tomcatBg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--reveal-bg-url);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    pointer-events: none;
    transition: background 0.3s ease;
}

/* On non-hover or coarse pointer (touch) devices, hide mask so background is visible */
@media (hover: none), (pointer: coarse) {
    #tomcatMask {
        display: none !important;
    }
}

/* --- Theme Toggle Button --- */
.theme-toggle-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--toggle-btn-bg);
    border: 1px solid var(--toggle-btn-border);
    color: var(--toggle-btn-color);
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    transition: all 0.25s ease;
    touch-action: manipulation;
}

.theme-toggle-btn:hover {
    background-color: var(--toggle-btn-hover-bg);
    transform: scale(1.08) rotate(15deg);
}

/* Toggle icon display based on active class */
.sun-icon {
    display: block;
}
.moon-icon {
    display: none;
}

body.light-theme .sun-icon {
    display: none;
}
body.light-theme .moon-icon {
    display: block;
}

/* --- Content Wrapper --- */
#wrapper {
    position: relative;
    display: block;
    width: 100%;
    max-width: 1200px;
    box-sizing: border-box;
    z-index: 2;
    margin: auto 0;
    padding: 40px 20px;
}

/* --- Grid of Cards --- */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
    margin: 0 auto;
}

/* --- Media Queries for Responsiveness --- */
@media (max-width: 1024px) {
    #wrapper {
        padding: 60px 20px 30px 20px;
        margin: auto 0;
    }
    .grid-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .theme-toggle-btn {
        top: 15px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
    #wrapper {
        margin: 0 auto;
        padding: 70px 16px 30px 16px;
    }
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .card-item {
        padding: 14px 16px;
        border-radius: 12px;
    }
    .card-icon {
        width: 36px;
        height: 36px;
        margin-right: 12px;
    }
    .card-title {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    #wrapper {
        margin: 0 auto;
        padding: 70px 12px 30px 12px;
    }
    .grid-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .card-item {
        padding: 12px 10px;
        border-radius: 10px;
    }
    .card-icon {
        width: 32px;
        height: 32px;
        margin-right: 8px;
        border-radius: 8px;
    }
    .card-title {
        font-size: 12px;
        letter-spacing: 0;
        line-height: 1.2;
    }
}

@media (max-width: 340px) {
    .grid-container {
        grid-template-columns: 1fr;
    }
}

/* The card itself is the <a> link */
.card-item {
    display: flex;
    align-items: center;
    padding: 18px 22px;
    border-radius: 14px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    text-decoration: none;
    transition: background-color 0.25s ease, 
                border-color 0.25s ease,
                transform 0.15s ease;
    cursor: pointer;
    box-sizing: border-box;
    touch-action: manipulation;
}

.card-item:hover {
    background-color: var(--card-hover-bg);
    border-color: var(--card-hover-border);
}

.card-item:active {
    transform: scale(0.98);
}

.card-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    object-fit: contain;
    margin-right: 16px;
    background-color: transparent;
    flex-shrink: 0;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--card-text-color);
    letter-spacing: 0.5px;
    transition: color 0.3s ease;
    white-space: normal;
    word-break: break-word;
}
