/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Cascadia Code", monospace;
    background: #0a0a0a;
    color: #fff;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

html {
    overflow: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

.body-content {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Hide horizontal scrollbar on SimpleBar's scroll element */
.body-content .simplebar-content-wrapper {
    overflow-x: hidden !important;
}

/* Hide SimpleBar horizontal track */
.body-content .simplebar-track.simplebar-horizontal {
    display: none;
}

a {
    text-decoration: none;
    color: #04a5e5;
}

/* =============================================
   CRT Effect
   ============================================= */

.crt-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.crt-effect__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(
            ellipse at center,
            transparent 0%,
            transparent 40%,
            rgba(0, 0, 0, 0.2) 70%,
            rgba(0, 0, 0, 0.6) 100%
        ),
        linear-gradient(
            180deg,
            rgba(0, 50, 0, 0.03) 0%,
            transparent 50%,
            rgba(0, 30, 0, 0.05) 100%
        );
}

.crt-effect__scanlines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, 0.4) 1px,
        rgba(0, 0, 0, 0.4) 2px
    );
    animation: scanline-move 10s linear infinite;
}

.crt-effect__scanlines::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.1) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    animation: scanline-refresh 4s linear infinite;
}

@keyframes scanline-move {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 0 100px;
    }
}

@keyframes scanline-refresh {
    0% {
        top: -4px;
        opacity: 0;
    }
    5% {
        opacity: 1;
    }
    95% {
        opacity: 1;
    }
    100% {
        top: calc(100% + 4px);
        opacity: 0;
    }
}

.crt-effect__flicker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.02);
    animation: flicker 0.1s infinite;
}

@keyframes flicker {
    0%,
    100% {
        opacity: 0.02;
    }
    10% {
        opacity: 0.04;
    }
    20% {
        opacity: 0.01;
    }
    30% {
        opacity: 0.03;
    }
    40% {
        opacity: 0.02;
    }
    50% {
        opacity: 0.05;
    }
    60% {
        opacity: 0.01;
    }
    70% {
        opacity: 0.03;
    }
    80% {
        opacity: 0.02;
    }
    90% {
        opacity: 0.04;
    }
}

/* =============================================
   Terminal Header
   ============================================= */

.terminal-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    background: linear-gradient(
        180deg,
        rgba(20, 20, 20, 0.95),
        rgba(10, 10, 10, 0.9)
    );
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #666;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.terminal-header__prompt {
    color: #666;
}

.terminal-header__time {
    color: #888;
}

/* =============================================
   Terminal Footer
   ============================================= */

.terminal-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 5px 16px;
    background: linear-gradient(
        0deg,
        rgba(20, 20, 20, 0.95),
        rgba(10, 10, 10, 0.9)
    );
    border-top: 1px solid #333;
    font-size: 11px;
    color: #444;
    text-align: center;
    z-index: 100;
}

/* =============================================
   Main Layout
   ============================================= */

.site-main {
    position: relative;
}

/* =============================================
   Section Base Styles
   ============================================= */

.section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 32px 64px;
    position: relative;
    border-top: 1px solid #222;
}

.section:first-of-type {
    border-top: none;
}

.projects {
    align-items: flex-start;
    position: relative;
    padding-bottom: 160px;
}

.section__container {
    text-align: center;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.section__title {
    font-size: 24px;
    color: #888;
    margin-bottom: 16px;
    font-weight: normal;
    font-family: "Cascadia Code", monospace;
}

.projects .section__title {
    margin-bottom: 16px;
    text-align: left;
}

/* =============================================
   Terminal Animation
   ============================================= */

.terminal-animation {
    font-family: "Cascadia Code", monospace;
    font-size: 14px;
    color: #888;
    text-align: left;
    margin-bottom: 32px;
    line-height: 1.6;
}

.terminal-line {
    margin-bottom: 0;
}

.terminal-prompt {
    color: #666;
}

.terminal-command {
    color: #fff;
}

.terminal-output {
    color: #888;
    margin-bottom: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.terminal-animation .terminal-cursor {
    animation: blink 1s step-end infinite;
    display: inline-block;
    vertical-align: baseline;
    color: #666;
    background: #666;
    margin-left: 1px;
}

.section__description {
    font-size: 14px;
    color: #666;
    text-align: center;
    max-width: 600px;
    margin: 0 auto 48px auto;
    line-height: 1.6;
}

.section__content {
    max-width: 800px;
    margin: 0 auto;
}

.placeholder {
    color: #555;
    font-size: 14px;
}

/* =============================================
   About Section Layout
   ============================================= */

.about {
    align-items: flex-start;
    display: none; /* Hidden until projects section completes */
}

.about.visible {
    display: flex;
}

.about .section__title {
    margin-bottom: 32px;
    text-align: left;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.about__section {
    display: flex;
    flex-direction: column;
    margin-bottom: 64px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.about__section:last-child {
    margin-bottom: 0;
}

.about__text {
    text-align: left;
    width: 100%;
    margin-bottom: 32px;
}

.about__section-content {
    font-size: 14px;
    color: #888;
    line-height: 1.8;
}

.about__section-content p {
    margin-bottom: 16px;
}

.about__section-content p:last-child {
    margin-bottom: 0;
}

.about__visual {
    display: none; /* Hidden by default, shown after terminal animation */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    width: 100%;
}

.about__visual canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.about__thanks {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin-top: 64px;
    font-family: "Cascadia Code", monospace;
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.about__thanks.visible {
    opacity: 1;
}

/* Live2D TUI pane specific styles */
.tui-pane__content--live2d {
    min-height: 560px;
    height: 560px;
    padding: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tui-pane__content--live2d canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* =============================================
   Hero Section
   ============================================= */

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 32px 24px;
    position: relative;
}

.hero__container {
    text-align: center;
    width: 100%;
}

.hero__logo {
    color: #fff;
    font-size: 12px;
    line-height: 1.15;
    margin-bottom: 32px;
    white-space: pre;
    cursor: default;
    transition: height 0.4s ease;
    font-family: "Cascadia Code", monospace;
}

.hero__logo .char {
    display: inline-block;
    width: 1ch;
    text-align: center;
}

.hero__content {
    opacity: 0;
    transition: opacity 0.8s ease-out;
}

.hero__content.show {
    opacity: 1;
}

.hero__nav {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: center;
    justify-content: center;
    margin-bottom: 32px;
}

.nav-link-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: inline-block;
    padding: 10px 0;
    color: #555;
    text-decoration: none;
    transition:
        color 0.15s,
        opacity 0.3s;
    font-size: 14px;
    font-family: "Cascadia Code", monospace;
}

.nav-link:hover {
    color: #fff;
}

.nav-link.disabled {
    opacity: 0.3;
    pointer-events: none;
    color: #333;
}

.nav-link-info {
    display: none;
    background: transparent;
    border: none;
    color: #555;
    font-family: "Cascadia Code", monospace;
    font-size: 14px;
    padding: 10px 0;
    cursor: pointer;
    transition: color 0.15s;
}

.nav-link-info.active {
    color: #fff;
}

/* Mobile styles */
@media (max-width: 999px) {
    .hero__container {
        margin-top: -15vh;
    }

    .hero__nav {
        flex-direction: column;
        gap: 16px;
    }

    .nav-link-wrapper {
        justify-content: center;
    }

    .nav-link:hover {
        color: #555;
    }

    .nav-link-info {
        display: inline-block;
    }
}

.hero__description {
    color: #666;
    font-size: 0;
    font-family: "Cascadia Code", monospace;
    margin-top: 8px;
    height: 0;
    white-space: pre-wrap;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
    overflow: visible;
}

.hero__description-text,
.terminal-cursor {
    font-size: 14px;
}

.hero__description-text {
    display: inline;
}

.hero__description-text .highlighted {
    background: #444;
    color: #fff;
}

/* =============================================
   Scroll Indicator
   ============================================= */

.scroll-indicator {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    opacity: 0;
    transition:
        opacity 0.8s ease-out,
        color 0.15s;
    color: #555;
    font-family: "Cascadia Code", monospace;
    font-size: 12px;
}

.scroll-indicator.show {
    opacity: 1;
}

.scroll-indicator:hover {
    color: #888;
}

.scroll-indicator__text {
    text-align: center;
}

.scroll-indicator__arrow {
    font-size: 14px;
    line-height: 1;
}

/* =============================================
   Terminal Cursor
   ============================================= */

.terminal-cursor {
    animation: blink 1s step-end infinite;
    display: inline-block;
    vertical-align: baseline;
}

.terminal-cursor--block {
    background: #666;
    color: #666;
    padding: 0;
    margin: 0;
}

.terminal-cursor--insert {
    background: transparent;
    color: transparent;
    border-left: 3px solid #666;
    margin-left: 0;
    padding-left: 3px;
    animation: none;
    height: 16px;
    display: inline-block;
    vertical-align: bottom;
}

.terminal-cursor.animating {
    animation: none;
}

@keyframes blink {
    0%,
    50% {
        opacity: 1;
    }
    50.1%,
    100% {
        opacity: 0;
    }
}

/* =============================================
   Projects Section TUI Styles
   ============================================= */

.projects__layout {
    display: none; /* Hidden by default, shown after terminal animation */
    display: grid;
    grid-template-columns: min-content 1fr;
    gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
    text-align: left;
    align-items: stretch;
}

.projects__processes,
.projects__details {
    display: flex;
    flex-direction: column;
}

.projects__processes {
    gap: 16px;
}

.projects__processes .tui-pane {
    display: flex;
    flex-direction: column;
}

.projects__processes .tui-pane__content {
    overflow-x: hidden;
}

.projects__details {
    gap: 16px;
}

/* TUI Pane Styles */
.tui-pane {
    font-family: "Cascadia Code", monospace;
    font-size: 14px;
    line-height: 1.4;
    border: 1px solid #555;
    position: relative;
}

.tui-pane__border-top {
    position: relative;
    height: 0;
}

.tui-pane__border-bottom {
    display: none;
}

.tui-pane__title {
    color: #888;
    padding: 0 0.5ch;
    position: absolute;
    left: 1ch;
    top: -10px;
    background: #0a0a0a;
    font-size: 14px;
    z-index: 1;
}

.tui-pane__content {
    color: #888;
    padding: 13px;
    min-height: 60px;
    white-space: normal;
    word-wrap: break-word;
    text-align: left;
}

.tui-pane__content--small {
    min-height: 40px;
}

.tui-pane__content--medium {
    min-height: 120px;
}

.projects__details .tui-pane {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.projects__details .tui-pane:has(#projectDescription) {
    flex: 1 1 0;
    min-height: 0;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
}

.projects__details .tui-pane__content {
    display: block;
}

.projects__details .tui-pane:has(#projectDescription) .tui-pane__content {
    flex: 1;
    min-height: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.tui-pane__placeholder {
    color: #4f4f4f;
    font-style: italic;
    display: inline-block;
    text-align: left;
}

/* Process Table */
.process-table {
    width: 100%;
    border-collapse: collapse;
    font-family: "Cascadia Code", monospace;
    table-layout: auto;
}

/* Process List Header */
.process-header {
    color: #888;
    font-weight: bold;
    user-select: none;
}

.process-header th {
    padding: 5px 13px;
    text-align: left;
    font-weight: bold;
}

.process-header th:first-child {
    padding-left: 11px;
}

.process-header th:last-child {
    padding-right: 11px;
}

/* Process List Items */
.process-item {
    cursor: pointer;
    color: #666;
    user-select: none;
    line-height: 1.6;
}

.process-item.transitioning {
    transition: color 0.15s;
}

.process-item td {
    padding: 2px 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    position: relative;
}

.process-item td:first-child {
    padding-left: 11px;
}

.process-item td:last-child {
    padding-right: 11px;
}

/* Background highlight using ::after pseudo-element */
.process-item td::after {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    right: 0;
    background-color: transparent;
    pointer-events: none;
    z-index: -1;
}

.process-item.transitioning td::after {
    transition: background-color 0.15s;
}

.process-item.shown {
    color: #888;
}

.process-item.shown td::after {
    background-color: rgba(255, 255, 255, 0.05);
}

.process-item.selected td::after {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Left border indicator using ::before pseudo-element */
.process-item td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: transparent;
    pointer-events: none;
}

.process-item.transitioning td:first-child::before {
    transition: background-color 0.15s;
}

.process-item.selected td:first-child::before {
    background-color: rgba(255, 255, 255, 0.6);
}

/* Process columns - auto-size to content except COMMAND */
.process-table td,
.process-table th {
    width: 1%;
    white-space: nowrap;
}

/* COMMAND column can grow and shrink */
.process-table th:nth-child(3),
.process-table td:nth-child(3) {
    width: auto;
}

/* Project Links Container */
#projectLinks {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Project Links */
.project-link {
    display: block;
    color: #666;
    text-decoration: none;
    transition: color 0.15s;
    padding: 0;
    line-height: 1.6;
}

.project-link:hover {
    color: #fff;
}

/* =============================================
   SimpleBar Custom Scrollbar Styles
   ============================================= */

/* Body scrollbar */
#bodyContent .simplebar-scrollbar::before {
    background-color: #555;
    opacity: 1 !important;
    border-radius: 0;
    left: 0;
    right: 0;
}

#bodyContent .simplebar-track.simplebar-vertical {
    width: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    right: 0;
}

#bodyContent .simplebar-track.simplebar-vertical .simplebar-scrollbar {
    right: 0;
    width: 10px;
}

/* SimpleBar container needs fixed height */
#projectDescription {
    height: 100%;
    max-height: 100%;
}

/* Override SimpleBar styles for terminal aesthetic */
#projectDescription .simplebar-scrollbar::before {
    background-color: #555;
    opacity: 1 !important;
    border-radius: 0;
    left: 0;
    right: 0;
}

#projectDescription .simplebar-track.simplebar-vertical {
    width: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    right: 0;
}

#projectDescription .simplebar-track.simplebar-vertical .simplebar-scrollbar {
    right: 0;
    width: 10px;
}

/* Content padding */
.tui-pane__content--medium .tui-pane__placeholder {
    padding: 13px;
}

.tui-pane__content--medium .tui-pane__data {
    height: 100%;
}

#projectDescription {
    height: 100%;
}

#projectDescriptionContent {
    padding: 13px;
}

/* Rich content styles */
#projectDescriptionContent p {
    margin-bottom: 13px;
    line-height: 1.6;
}

#projectDescriptionContent p:last-child {
    margin-bottom: 0;
}

#projectDescriptionContent img {
    max-width: 100%;
    max-height: 260px;
    height: auto;
    display: block;
    margin: 13px auto;
    border: 1px solid #555;
    position: relative;
}

.image-enlarger-wrapper {
    position: relative;
    display: block;
    margin: 13px auto;
    width: fit-content;
    max-width: 100%;
}

.image-enlarger-wrapper img {
    display: block;
    margin: 0;
}

.image-enlarger-wrapper::after {
    content: "[ Click to Enlarge ]";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(40, 40, 40, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    font-family: "Cascadia Code", monospace;
    font-size: 14px;
    pointer-events: none;
    border: 1px solid #555;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-enlarger-wrapper.show::after {
    opacity: 1;
}

#projectDescriptionContent br {
    display: block;
    content: "";
    margin: 6px 0;
}

#projectDescriptionContent strong,
#projectDescriptionContent b {
    color: #fff;
    font-weight: bold;
}

#projectDescriptionContent em,
#projectDescriptionContent i {
    font-style: italic;
    color: #aaa;
}

#projectDescriptionContent code {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 2px;
    font-family: "Cascadia Code", monospace;
    font-size: 13px;
    color: #aaa;
}

#projectDescriptionContent ul,
#projectDescriptionContent ol {
    margin: 13px 0;
    padding-left: 26px;
}

#projectDescriptionContent li {
    margin-bottom: 6px;
    line-height: 1.6;
}

/* =============================================
   Projects Info and Placeholder Visibility
   ============================================= */

.info-text--mobile {
    display: none;
}

.placeholder-text--mobile {
    display: none;
}

.tui-pane.no-project .tui-pane__data {
    display: none;
}

.tui-pane:not(.no-project) .tui-pane__placeholder {
    display: none;
}

.tui-pane__placeholder {
    color: #4f4f4f;
    font-style: italic;
}

/* =============================================
   Projects Mobile Layout
   ============================================= */

@media (max-width: 999px) {
    .info-text {
        display: none;
    }

    .info-text--mobile {
        display: inline;
    }

    .placeholder-text {
        display: none;
    }

    .placeholder-text--mobile {
        display: inline;
    }

    .projects__layout {
        grid-template-columns: 1fr;
    }

    .projects__processes {
        display: contents;
    }

    .projects__details {
        display: contents;
    }

    .projects__processes .tui-pane:has(#projectsList) {
        order: 2;
    }

    .projects__processes .tui-pane:has(.tui-pane__content--small) {
        order: 1;
    }

    .projects__details .tui-pane:nth-child(1) {
        order: 3;
    }

    .projects__details .tui-pane:nth-child(2) {
        order: 4;
    }

    .projects__details .tui-pane:nth-child(3) {
        order: 5;
    }

    .projects__details .tui-pane:nth-child(4) {
        order: 6;
    }

    .process-header th:last-child,
    .process-item td:last-child {
        display: none;
    }

    .tui-pane__content {
        overflow-wrap: break-word;
        word-break: break-word;
    }

    .projects__processes .tui-pane:has(#projectsList) .tui-pane__content {
        overflow-x: hidden;
    }

    /* On mobile, set max-width on COMMAND column to enable truncation */
    .process-table th:nth-child(3),
    .process-table td:nth-child(3) {
        max-width: 0;
    }

    /* Constrain about section visuals to fit mobile screens */
    .about__visual .tui-pane {
        max-width: 100%;
    }

    .tui-pane__content--live2d {
        min-height: 400px;
        height: 400px;
    }

    .about__visual canvas {
        max-width: 100% !important;
    }
}

/* =============================================
   Video Controls Styles
   ============================================= */

.about__visual canvas {
    max-width: 100%;
    height: auto !important;
}

.video-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    margin-top: 36px;
}

.video-play-button {
    background: transparent;
    border: none;
    color: #555;
    font-family: "Cascadia Code", monospace;
    font-size: 14px;
    padding: 10px 0;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
    white-space: pre;
    font-variant-ligatures: none;
}

.video-play-button:hover {
    color: #fff;
}

.video-progress {
    color: #fff;
    font-family: "Cascadia Code", monospace;
    font-size: 12px;
    cursor: pointer;
    user-select: none;
    white-space: pre;
    font-variant-ligatures: none;
}

@media (max-width: 999px) {
    .video-play-button:hover {
        color: #555;
    }

    .video-play-button.playing {
        color: #fff;
    }
}
