/* =========================================================
   My HTML Portfolio: style.css
   Rules: animate only transform/opacity, no blur, no big
   shadows, no JS animation, respects reduced motion.
   ========================================================= */

/* ---------- Theme tokens ---------- */
:root {
    --bg: #ffffff;
    --bg-soft: #f6f6f9;
    --text: #25232f;
    --muted: #55535f;
    --primary: #6a0dff;
    /* accent text / icons */
    --btn: #6a0dff;
    /* button background */
    --primary-soft: rgba(106, 13, 255, 0.1);
    --line: rgba(0, 0, 0, 0.07);
    --line-strong: rgba(0, 0, 0, 0.28);
    --ring: rgba(106, 13, 255, 0.3);
    --card-bg: #b8b8bd;
    --swoosh: #6a0dff;
    --toggle-bg: #1d1d22;
    --toggle-fg: #ffffff;
    --ok: #15803d;
    --err: #dc2626;
    --backdrop: rgba(15, 12, 30, 0.55);
}

:root[data-theme="dark"] {
    --bg: #0f0f14;
    --bg-soft: #181821;
    --text: #f2f2f6;
    --muted: #a9a8b6;
    --primary: #a87cff;
    --btn: #6a0dff;
    --primary-soft: rgba(168, 124, 255, 0.16);
    --line: rgba(255, 255, 255, 0.09);
    --line-strong: rgba(255, 255, 255, 0.3);
    --ring: rgba(168, 124, 255, 0.35);
    --card-bg: #24242e;
    --swoosh: #6a0dff;
    --toggle-bg: #f2f2f6;
    --toggle-fg: #15151a;
    --ok: #4ade80;
    --err: #f87171;
    --backdrop: rgba(0, 0, 0, 0.7);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 4rem;
    scrollbar-gutter: stable;
    -webkit-text-size-adjust: 100%;
}

/* Lock page scroll while a modal is open */
html:has(dialog[open]) {
    overflow: hidden;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

img {
    display: block;
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

h1,
h2,
h3,
p {
    margin: 0;
}

button {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}

.container {
    width: min(100% - 2.5rem, 68rem);
    margin-inline: auto;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0.5rem;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: var(--btn);
    color: #fff;
    border-radius: 6px;
}

.skip-link:focus {
    left: 0.75rem;
}

/* ---------- Navbar ---------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    box-shadow: 0 1px 0 var(--line);
}

.navbar-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 4rem;
}

.logo {
    justify-self: start;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

/* NEW: short logo is hidden by default, shown only on small screens */
.logo-short {
    display: none;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-links a {
    color: var(--text);
}

.nav-links a:hover {
    color: var(--primary);
}

.nav-links a.active {
    color: var(--primary);
}

.theme-toggle {
    justify-self: end;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 50%;
    background: var(--toggle-bg);
    color: var(--toggle-fg);
    transition: transform 0.2s;
}

.theme-toggle:hover {
    transform: scale(1.08);
}

.theme-toggle:active {
    transform: scale(0.94);
}

/* Light mode shows the moon (switch to dark), dark mode shows the sun */
.icon-sun {
    display: none;
}

:root[data-theme="dark"] .icon-sun {
    display: block;
}

:root[data-theme="dark"] .icon-moon {
    display: none;
}

/* ---------- Buttons ---------- */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    transition: transform 0.15s, opacity 0.15s;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--btn);
    color: #fff;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-outline {
    background: transparent;
    border-color: var(--line-strong);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-block {
    width: 100%;
    margin-top: 1.1rem;
    padding: 0.8rem 1rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- Hero ---------- */
.hero {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2rem;
    padding-block: clamp(2.5rem, 7vw, 6rem);
}

.hero-hi {
    font-size: clamp(1.1rem, 2.6vw, 1.5rem);
    font-weight: 400;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.hero h1 {
    font-size: clamp(3rem, 9vw, 5rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.accent {
    color: var(--primary);
}

.hero-sub {
    max-width: 34rem;
    margin: 1.1rem 0 1.6rem;
    color: var(--muted);
    font-size: clamp(1rem, 2.2vw, 1.25rem);
    line-height: 1.5;
}

.hero-photo {
    width: clamp(14rem, 34vw, 23.5rem);
    aspect-ratio: 1;
    padding: 9%;
    border: 1px solid var(--ring);
    border-radius: 50%;
}

.hero-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* ---------- Sections ---------- */
.section {
    padding-block: clamp(2.5rem, 7vw, 5rem);
    scroll-margin-top: -1.5rem;
}

#about {
    scroll-margin-top: -2.5rem;
}

/* Skip rendering work for sections far below the fold */
#skills,
#about {
    content-visibility: auto;
    contain-intrinsic-size: auto 500px;
}

.section-title {
    margin-bottom: clamp(1.25rem, 3vw, 2rem);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.dot {
    color: var(--primary);
}

/* ---------- Projects ---------- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: clamp(1.75rem, 4vw, 2.5rem) clamp(1rem, 2.4vw, 1.75rem);
}

.card--5 {
    grid-column: span 5;
}

.card--7 {
    grid-column: span 7;
}

.card--12 {
    grid-column: span 12;
}

.card-media {
    position: relative;
    display: block;
    width: 100%;
    height: clamp(13rem, 24vw, 16rem);
    padding: 0;
    border: 0;
    border-radius: 16px;
    overflow: hidden;
    background: var(--card-bg);
}

/* Purple swoosh shapes: pure CSS, no image files */
.card-media::before,
.card-media::after {
    content: "";
    position: absolute;
    aspect-ratio: 1;
    border: clamp(12px, 2vw, 20px) solid var(--swoosh);
    border-radius: 50%;
    pointer-events: none;
}

.card-media::before {
    width: 55%;
    left: -14%;
    bottom: -42%;
}

.card-media::after {
    width: 60%;
    right: -18%;
    top: -48%;
}

.card--7 .card-media::before {
    width: 46%;
    left: 8%;
    bottom: auto;
    top: -58%;
}

.card--7 .card-media::after {
    width: 70%;
    right: -25%;
    top: auto;
    bottom: -52%;
}

.card--12 .card-media::before {
    width: 34%;
    left: 28%;
    bottom: -62%;
}

.card--12 .card-media::after {
    width: 30%;
    right: -6%;
    top: -45%;
}

.card-media img {
    position: absolute;
    inset: 0;
    z-index: 1;
    margin: auto;
    height: 84%;
    width: auto;
    max-width: 88%;
    aspect-ratio: 5 / 3;
    object-fit: cover;
    object-position: top;
    border-radius: 8px;
    border: 1px solid var(--line);
    transition: transform 0.3s;
}

.card-media:hover img {
    transform: translateY(-4px);
}

.card-title {
    margin: 1rem 0 0.35rem;
}

.card-name {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0;
    border: 0;
    background: none;
    font-size: clamp(1.15rem, 2.4vw, 1.4rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    text-align: left;
}

.card-name svg {
    color: var(--primary);
    flex-shrink: 0;
}

.card-name:hover {
    color: var(--primary);
}

.card-desc {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.55;
}

/* ---------- Skills ---------- */
.skills-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2rem 1.5rem;
}

.skills-grid h3 {
    margin-bottom: 0.7rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.skills-grid li {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ---------- My Story ---------- */
.story {
    max-width: 62rem;
}

.story p {
    margin-bottom: 0.9rem;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.65;
}

.hl {
    color: var(--primary);
}

/* ---------- Footer ---------- */
.footer {
    padding: clamp(2.5rem, 6vw, 3.5rem) 0 1.75rem;
}

.footer-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.footer-nav a:hover,
.footer-link:hover {
    color: var(--primary);
}

.footer-nav a.active {
    color: var(--primary);
}

.footer-link {
    padding: 0;
    border: 0;
    background: none;
    font-weight: 500;
}

.socials {
    display: flex;
    gap: 0.5rem;
}

.socials button {
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    transition: transform 0.2s;
}

.socials button:hover {
    transform: translateY(-3px);
    color: var(--primary);
}

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-top: clamp(2rem, 5vw, 3rem);
}

.footer-cta {
    margin-bottom: 0.9rem;
    font-size: clamp(1.1rem, 2.6vw, 1.3rem);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.copyright {
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.6;
    text-align: right;
}

/* ---------- Modals (native <dialog>) ---------- */
dialog.modal {
    width: min(100% - 2rem, 32rem);
    max-height: 90dvh;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    overflow: visible;
}

dialog.modal::backdrop {
    background: var(--backdrop);
}

.modal-box {
    position: relative;
    max-height: 90dvh;
    overflow-y: auto;
    padding: 1.75rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 16px;
}

dialog.modal[open] .modal-box {
    animation: pop 0.22s ease-out;
}

dialog.modal[open]::backdrop {
    animation: fade 0.22s ease-out;
}

@keyframes pop {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes fade {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 0.6rem;
    right: 0.7rem;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 1.7rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-tag {
    margin-bottom: 0.25rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.modal-box h2 {
    padding-right: 2rem;
    margin-bottom: 0.6rem;
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.modal-text {
    color: var(--muted);
    font-size: 0.95rem;
    line-height: 1.6;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 1rem 0 1.4rem;
}

.chips li {
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 500;
}

/* Contact form */
.modal-box label {
    display: block;
    margin: 0.9rem 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.modal-box input,
.modal-box textarea {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--bg-soft);
    color: var(--text);
    font: inherit;
    font-size: 0.92rem;
}

.modal-box input::placeholder,
.modal-box textarea::placeholder {
    color: var(--muted);
    opacity: 0.7;
}

.modal-box input:focus,
.modal-box textarea:focus {
    outline: 2px solid var(--ring);
    border-color: var(--primary);
}

.modal-box textarea {
    min-height: 6.5rem;
    resize: vertical;
}

.form-status {
    min-height: 1.4em;
    margin-top: 0.7rem;
    font-size: 0.88rem;
    text-align: center;
}

.form-status.is-success {
    color: var(--ok);
}

.form-status.is-error {
    color: var(--err);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .skills-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* NEW: small screens show the short logo "Hafiz." instead of "HafizA.Shams" */
@media (max-width: 600px) {
    .logo-full {
        display: none;
    }

    .logo-short {
        display: inline;
    }
}

@media (max-width: 720px) {
    .hero {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }

    .hero-photo {
        order: -1;
        justify-self: center;
        width: min(15rem, 70vw);
    }

    .hero-sub {
        max-width: none;
    }

    .card--5,
    .card--7,
    .card--12 {
        grid-column: span 12;
    }

    .card-media {
        height: clamp(11rem, 52vw, 15rem);
    }

    .footer-bottom {
        flex-direction: column;
        align-items: flex-start;
    }

    .copyright {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .container {
        width: min(100% - 2rem, 68rem);
    }

    .logo {
        font-size: 0.85rem;
    }

    .nav-links {
        gap: 1rem;
        font-size: 0.85rem;
    }

    .theme-toggle {
        width: 2rem;
        height: 2rem;
    }

    .modal-box {
        padding: 1.4rem 1.2rem;
    }
}

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

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}