@import url('https://fonts.googleapis.com/css2?family=Chiron+Hei+HK:ital,wght@0,200..900;1,200..900&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap');

/* COLOR PALETTES */
/* ============================================
   Define themes with CSS custom properties.
   Each [data-theme] block is one palette.
   Swapping the attribute on <html> repaints every element that uses these variables.
   ============================================ */
[data-theme = "default"] {
    --bg: #5FDCF7;
    --accent: #56c5de;
    --surface: #D6F9FF;
    --card: #ffffff;
    --header: #4baec4;
    --grid: #ADF3FF;
    --txt: #000000;
    --txt-accent: #ffffff;
    --links-hover: #56c5de;
    --cta: #4baec4;
}

[data-theme = "rainforest"] {
    --bg: #5ff780;
    --accent: #56de76;
    --surface: #d6ffd8;
    --card: #ffffff;
    --header: #4bc45f;
    --grid: #adffc0;
    --txt: #000000;
    --txt-accent: #ffffff;
    --links-hover: #56de76;
    --cta: #4bc45f;
}

[data-theme = "sunset"] {
    --bg: #f7bf5f;
    --accent: #dea556;
    --surface: #ffefd6;
    --card: #ffffff;
    --header: #c4984b;
    --grid: #ffd9ad;
    --txt: #000000;
    --txt-accent: #ffffff;
    --links-hover: #dea556;
    --cta: #c4984b;
}

[data-theme = "raspberry"] {
    --bg: #f75f9c;
    --accent: #de5695;
    --surface: #ffd6eb;
    --card: #ffffff;
    --header: #c44b80;
    --grid: #ffadd5;
    --txt: #000000;
    --txt-accent: #ffffff;
    --links-hover: #de5695;
    --cta: #c44b80;
}

/* LIGHT/DARK MODE */
[data-mode = "dark"] {
    --bg: #202020;
    --surface: #000000;
    --card: #505050;
    --grid: #242424;
    --txt: #ffffff;
    --txt-accent: #000000;
}

/* GENERAL SETTINGS */

html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg);
    color: var(--txt);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: "Nunito", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    margin: 0;
    transition: background-color 0.25s, color 0.25s;
}

h1, h2, h3 {
    font-family: "Chiron Hei HK", sans-serif;
}

p {
    font-size: 1.1em;
}

main {
    background-color: var(--surface);
    width: 80%;
    max-width: 1200px;
    margin: 0 auto;
    transition: background-color 0.25s;
}

header {
    background-color: var(--header);
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
    transition: background-color 0.25s;
}

nav {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--accent);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    transition: background-color 0.25s;
}

section {
    margin: 50px 20px;
}

.section-title {
    background-color: var(--accent);
    color: var(--txt-accent);
    padding: 0 20px;
    margin-bottom: 10px;
    margin-left: -20px;
    width: 75%;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0 100%);
    transition: background-color 0.25s, color 0.25s;
}

.section-title h2 {
    padding: 2px 0;
    margin: 0;
}

footer {
    background-color: var(--header);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 5px 0;
    transition: background-color 0.25s;
}

/* HEADER & NAVBAR */

header h1 {
    color: var(--txt-accent);
    font-size: 2.5em;
    transition: color 0.25s;
}

/* -- Name display in the Navbar -- */
#nav-name {
    background-color: var(--header);
    font-family: "Chiron Hei HK", sans-serif;
    font-size: 1.6em;
    font-weight: bold;
    color: var(--txt-accent);
    clip-path: polygon(0 0, 100% 0, 90% 100%, 0 100%);
    padding: 10px 30px;
    margin: 0;
    width: 0;
    white-space: nowrap; /* prevents the name from wrapping as width shrinks */
    overflow: hidden;
    transform: translateX(-20px);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s, width 0.3s;
}

/* - when .scrolled is added to the navbar, fade the name in - */
#navbar.scrolled #nav-name {
    opacity: 1;
    width: 20%;
    transform: translateX(0px);
}

/* -- Settings and links -- */
#settings-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

#settings-btn svg {
    width: 32px;
    height: 32px;
    fill: var(--txt-accent);
    transition: fill 0.25s;
}

nav a, #settings-btn {
    font-size: 1.3em;
    font-weight: bold;
    text-decoration: none;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0 100%);
    color: var(--txt-accent);
    padding: 10px 30px;
    margin: 3px auto;
    transition: color 0.25s;
}

#settings-btn {
    margin-right: 5px;
}

nav a:hover, #settings-btn:hover {
    background-color: var(--surface);
    color: var(--links-hover);
    transition: background-color 0.25s, color 0.25s;
}

#settings-btn:hover svg {
    fill: var(--links-hover);
    transition: fill 0.25s;
}

/* - Dropdown panel - */
.dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% - 3px);
    background-color: var(--surface);
    border: 3px solid var(--accent);
    border-radius: 0px 0px 10px 10px;
    padding: 10px;
    width: 200px;
    z-index: 10;
    transition: background-color 0.25s, border-color 0.25s;
}

.dropdown.open { display: block; }  /* JS adds/removes this */

.dropdown-label {
  text-transform: uppercase;
  color: var(--cta);
  opacity: 0.75;
  padding: 4px 8px 8px;
  transition: color 0.25s;
}

/* - Individual theme options inside the dropdown - */

.theme-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    border-radius: 10px;
    gap: 10px;
    padding: 5px 10px;
    margin: 5px auto;
    cursor: pointer;
}

.theme-option:hover {
    background-color: var(--grid);
    color: #000000;
    transition: background-color 0.25s, color 0.25s;
}

.theme-option.active {
    background-color: var(--grid);
    font-weight: 500;
    color: #000000;
    transition: background-color 0.25s, color 0.25s;
}

/* - Small color circle on each option - */
.swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

/* - Checkmark shown only on the active/saved theme - */
.checkmark {
    margin-left: auto;
    color: var(--accent);
    font-weight: 500;
    opacity: 0;
    transition: color 0.25s;
}

.theme-option.active .checkmark {
    opacity: 1;
}

/* -- Light/Dark Mode -- */
.mode-option {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    margin: 5px auto;
}

.mode-option svg {
    width: 22px;
    height: 22px;
    fill: var(--cta);
    transition: fill 0.25s;
}

#mode-toggle {
    appearance: none; /* hides the default checkbox */
    width: 40px;
    height: 22px;
    position: relative;
    cursor: pointer;
    background-color: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 20px;
    transition: background-color 0.25s, border-color 0.25s;
}

/* - The sliding circle — drawn with ::before pseudo-element - */
#mode-toggle::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: -1px;
    left: -1px;
    background-color: var(--bg);
    border: 2px solid var(--cta);
    border-radius: 50%;
    transition: background-color 0.25s, border-color 0.25s, transform 0.25s;
}

/* When checked, slide the circle to the right */
#mode-toggle:checked::before {
    transform: translateX(18px);
}

/* INTRODUCTION */

.intro-section h2 {
    font-family: "Nunito", sans-serif;
}

.intro-section p {
    font-size: 1.2em;
}

.intro-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.call-to-action {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-top: 20px;
}

.call-to-action svg {
    width: 24px;
    height: 24px;
    margin-right: 5px;
    fill: var(--cta);
    transition: fill 0.25s;
}

.call-to-action a{
    text-decoration: none;
    color: var(--cta);
    font-weight: bold;
    font-size: 1.1em;
    transition: color 0.25s;
}

.call-to-action a:hover {
    text-decoration: underline;
}

/* ABOUT ME */

.about-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding-top: 20px;
}

.portrait {
    border-radius: 50px;
    box-shadow: 5px 5px 10px #00000025;
    width: 25%;
}

.about-description {
    background-color: var(--grid);
    padding: 15px;
    border-radius: 15px;
    width: 70%;
    transition: background-color 0.25s;
}

/* SKILLS */

.skills-container, .projects-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 30px auto;
}

.skill-group-title {
    display: flex;
    font-size: 1.3rem;
    color: var(--cta);
    font-weight: 600;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    justify-content: center;
    align-items: center;
    background-color: var(--grid);
    border-radius: 15px;
    gap: 30px;
    padding: 20px;
    margin: 0 auto;
    width: 80%;
    transition: background-color 0.25s;
}

.skill {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    background-color: var(--card);
    border-radius: 15px;
    box-shadow: 5px 5px 10px #00000025;
    padding: 0 10px 25px 10px;
    margin: 10px auto;
    width: 80%;
    max-width: 110px;
    min-width: 100px;
    height: 90px;
    transition: background-color 0.25s;
}

.skill-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform .3s ease-in-out;
}

.skill-level {
    position: absolute;
    bottom: 0;
    transform: translateY(100%);
    transition: transform .3s ease-in-out;
}

.skill-level p {
    margin-top: 10px;
}

.skill:hover {
    box-shadow: 5px 5px 10px #00000055;
}

.skill:hover .skill-icon {
    transform: translateY(-10px) scale(0.85);
}

.skill:hover .skill-level {
    transform: translateY(10px);
}

.skill img {
    width: 40px;
}

.skill h3 {
    margin-bottom: 5px;
}

/* PROJECTS */

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(470px, 1fr));
    justify-content: center;
    align-items: center;
    background-color: var(--grid);
    border-radius: 15px;
    gap: 5px;
    padding: 10px;
    margin: 0 auto;
    width: 90%;
    transition: background-color 0.25s;
}

.project {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    background-color: var(--card);
    border-radius: 15px;
    box-shadow: 5px 5px 10px #00000025;
    padding: 0;
    margin: 15px auto;
    width: 80%;
    max-width: 450px;
    min-width: 450px;
    height: 350px;
    transition: background-color 0.25s;
}

.project img {
    width: 100%;
    max-height: 270px;
    border: 15px solid var(--cta);
}

.project-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.3s ease-in-out;
}

.project-stack p {
    margin: 5px 0;
    padding: 0 10px;
    line-height: 1.2;
    font-size: .9em;
}

.project-stack h3 {
    margin: 15px auto 5px auto;
}

.project-subtitle {
    display: inline-block;
    font-size: 1.1em;
    margin: 0 auto 15px auto;
}

.tags-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 3px;
    margin: 5px auto;
}

.tag {
    display: inline-block;
    background-color: var(--header);
    border: 1px solid var(--cta);
    border-radius: 5px;
    font-size: 0.7em;
    font-weight: 600;
    padding: 1px 3px;
}

.links-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    background-color: var(--surface);
    width: 100%;
    margin-top: 10px;
    transition: background-color 0.25s;
}

.project-links {
    display: flex;
    flex-direction: column;
    justify-content: left;
    margin: 10px auto;
    padding-bottom: 10px;
}

.project-links .link {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
}

.link svg {
    width: 20px;
    height: 20px;
    fill: var(--txt);
    transition: fill 0.25s;
}

.project-links a {
    text-decoration: none;
    font-weight: bold;
    color: var(--txt);
    transition: color 0.25s;
}

.project-links a:hover {
    text-decoration: underline;
}

.project:hover {
    box-shadow: 5px 5px 10px #00000055;
}

.project:hover .project-stack {
    transform: translateY(-225px);
}

/* CONTACT */

.contact-container {
    display: flex;
    flex-direction: row;
    justify-content: left;
    gap: 50px;
    margin: 30px auto;
}

.contact-links {
    display: flex;
    flex-direction: column;
}

.contact-link {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: left;
    margin: 10px;
}

.contact-link a {
    text-decoration: none;
    color: var(--txt);
    transition: color 0.25s;
}

.contact-link a:hover {
    text-decoration: underline;
}

.contact-icon {
    width: 28px;
    height: 28px;
    margin-right: 10px;
    fill: var(--txt);
    transition: fill 0.25s;
}

.contact-type {
    font-size: 1.2em;
    font-weight: bold;
    margin-right: 5px;
}

/* --- Contact Form --- */
.form-card {
    display: flex;
    flex-direction: column;
    background-color: var(--grid);
    border: 3px solid var(--accent);
    border-radius: 10px;
    padding: 15px;
    margin: 10px 20px;
    width: fit-content;
    min-width: 250px;
    transition: background-color 0.25s, border-color 0.25s;
}

.field {
    display: flex;
    flex-direction: column;
}

.field label {
    color: var(--cta);
    font-weight: bold;
    font-size: 1.1em;
    transition: color 0.25s;
    margin-top: 10px;
}

.field input, .field textarea {
    background-color: var(--card);
    border: 1px solid var(--accent);
    font-family: "Nunito", sans-serif;
    color: var(--txt);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

/* - Highlight the field the user is currently in - */
input:focus, textarea:focus {
    border: 3px solid var(--cta);
    background-color: var(--surface);
}

/* - Red border when validation fails - */
input.invalid, textarea.invalid {
    border-color: #b82222;
}

/* -- Inline validation error messages -- */
/* Hidden by default — JS adds .visible to show them */

.field-error {
    display: flex;
    flex-direction: row;
    font-size: 0.8em;
    font-style: italic;
    color: #b82222;
    margin: 1px 2px 5px 2px;
    opacity: 0;
    overflow: hidden;
    height: 0;
    transition: opacity 0.2s, height 0.2s;
}

.field-error.visible {
    opacity: 1;
    height: fit-content;
}

.form-warning {
    width: 15px;
    height: 15px;
    margin: 1px;
    fill: #b82222;
}

/* -- Submit button -- */
.submit-btn {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: var(--cta);
    border: 2px solid var(--cta);
    border-radius: 50px;
    font-size: 1.1em;
    color: var(--txt-accent);
    width: 100%;
    height: 38px;
    margin: 20px auto 10px auto;
    transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}

.submit-btn:hover {
    background-color: var(--surface);
    color: var(--cta);
}

.submit-btn svg {
    width: 22px;
    height: 22px;
    fill: var(--txt-accent);
    transition: fill 0.25s;
}

.submit-btn:hover svg {
    fill: var(--cta);
}

/* - Disabled during the fetch request - */
.submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* -- Status message shown after submission -- */
/* Hidden by default — JS adds .success or .error */
.status {
    display: none;
    border-radius: 10px;
    padding: 12px 14px;
    margin-top: 15px;
}

.status.success {
    display: block;
    background-color: #d0ffdb;
    border: 1px solid #3c804c;
    color: #22b857;
}

.status.error {
    display: block;
    background-color: #ff9b9b;
    border: 1px solid #bc3030;
    color: #b82222;
}

/* -- h-captcha -- */
.h-captcha {
    margin-top: 15px;
}

/* FOOTER */

.footer-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    color: var(--txt-accent);
    transition: color 0.25s;
}

.social-icon {
    width: 22px;
    height: 22px;
    margin: 0 5px;
    padding-top: 5px;
}

.footer-item span {
    display: inline-block;
}

/* BACK TO TOP */
#backToTop {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: fixed;
    bottom: 50px;
    right: 40px;
    z-index: 999;

    /* Styling */
    background-color: var(--accent);
    border: 3px solid var(--surface);
    border-radius: 70px;
    width: 50px;
    height: 50px;
    cursor: pointer;
    box-shadow: 5px 5px 10px #00000025;

    /* Hidden by default */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s, background-color 0.25s, border-color 0.25s;
}

#backToTop.visible {
    opacity: 1;
    visibility: visible;
}

#backToTop svg {
    width: 32px;
    height: 32px;
    fill: var(--surface);
    transition: fill 0.25s;
}

#backToTop:hover {
    background-color: var(--surface);
    border-color: var(--accent);
    box-shadow: 5px 5px 10px #00000055;
    transition: background-color 0.25s, border-color 0.25s;
}

#backToTop:hover svg{
    fill: var(--links-hover);
    transition: fill 0.25s;
}


/* RESPONSIVENESS */

/* --- Small Desktops --- */
@media screen and (max-width: 1200px) {
    main {
        width: 90%;
    }
}

@media screen and (max-width: 1100px) {
    main {
        width: 95%;
    }
}

@media screen and (max-width: 1000px) {
    main {
        width: 100%;
    }

    #navbar.scrolled #nav-name {
        font-size: 1.3em;
        padding: auto;
        min-width: fit-content;
    }
}

@media screen and (max-width: 890px) {
    .about-container {
        flex-direction: column;
    }

    .portrait {
        border-radius: 70px;
        width: 60%;
    }

    .about-description {
        width: 95%;
    }

    /* Skills */
    .skills-grid {
        width: 90%;
    }
}

/* --- Tablets --- */
@media screen and (max-width: 780px) {
    nav a {
        padding: 10px;
    }

    /* Skills */
    .skill {
        position: static;
        width: 90%;
    }

    .skill-icon {
        margin: auto;
        transition: none;
    }

    .skill-level {
        position: static;
        bottom: auto;
        transform: none;
        margin: auto;
    }

    .skill-level p {
        margin-top: auto;
    }

    .skill:hover .skill-icon {
        transform: none;
    }

    .skill:hover .skill-level {
        transform: none;
    }

    .skill img {
        width: 40px;
    }

    .skill h3 {
        font-size: 1.1em;
    }

    /* Projects */
    .projects-grid {
        padding: 20px 10px;
        margin: 0 auto;
        width: 95%;
    }

    .project {
        position: static;
        padding-bottom: 0;
        height: fit-content;
    }

    .project-stack {
        transition: none;
    }

    .project:hover .project-stack {
        transform: none;
    }

    /* Contact */
    .contact-container {
        flex-direction: column;
        align-items: center;
    }

    /* Footer */
    footer {
        font-size: .8em;
    }
}

@media screen and (max-width: 677px) {
    #navbar.scrolled #nav-name {
        display: none;
    }
}

/* --- Phones --- */
@media screen and (max-width: 480px) {
    /* Skills */
    .skills-grid {
        grid-template-columns: 1fr;
    }

    .skill {
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        padding: 0 auto;
        max-width: none;
        min-width: fit-content;
        height: fit-content;
    }

    .skill img {
        width: 40px;
    }

    .skill h3 {
        font-size: 1em;
    }

    .skill-level p {
        margin-top: 40px;
    }

    /* Projects */
    .projects-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    #footer-design {
        display: none;
    }
}